PayPal-获取定期配置文件的交易详细信息


PayPal - Get transaction details for recurring profile

在发出TransactionSearch请求时,我会收到带有交易的TRANSACTIONID字段的交易列表,对应于经常性付款,格式为"I-BRPN2RUD8W0G"(当前为假)。

对于其余事务,我得到通常的17个单字节字母数字字符串。这意味着,对于经常性支付,PayPal返回ProfileID,但不返回TransactionID。

因此,当我请求将此交易id传递给PayPal的GetTransactionDetails时,我会收到普通付款的有效详细信息,而对于重复付款,则会收到错误消息"交易id无效"。

您需要按照Sanjiv的建议设置IPN。您可以根据IPN变量获取字段。如果退款,您还需要使用parent_txn_id

如果你是新手,并且觉得很难,你可以使用IPN监听器类,然后集成下面的代码

$listener = new IpnListener();
try {
    $verified = $listener->processIpn();
} catch (Exception $e) {
    return Log::error($e->getMessage());
}
if ($verified) {
$data = $_POST;
$user_id = json_decode($data['custom'])->user_id;
$subscription = ($data['mc_gross_1'] == '10') ? 2 : 1;
$txn = array(
    'txn_id'       => $data['txn_id'],
    'user_id'      => $user_id,
    'paypal_id'    => $data['subscr_id'],
    'subscription' => $subscription,
    'expires'      => date('Y-m-d H:i:s', strtotime('+1 Month')),
);
Payment::create($txn);
} else {
    Log::error('Transaction not verified');
}

将此文件代码保存在文件中,比如ipn.php,现在在您的贝宝帐户中为该文件分配web路径。

PS:请确保您的IPN文件位于可公开访问的URL上。不要使用本地或受限制的服务器。

您必须在您的Paypal商家帐户中设置IPN(专门用于经常性付款),当经常性付款发生时,它会向您发送交易详细信息,从那里您可以获得$_POST['txn_id'],如果$_POST['txn_type']recurring_payment,它就是您的TRANSACTIONID。将详细信息保存在数据库中,然后在需要交易详细信息时可以调用GetTransactionDetails方法。更多