【问题标题】:PayPal - Get transaction details for recurring profilePayPal - 获取重复配置文件的交易详细信息
【发布时间】:2015-06-08 10:36:30
【问题描述】:

在发出 TransactionSearch 请求时,我收到交易列表,其中包含交易的 TRANSACTIONID 字段,对应于定期付款,格式为例如“I-BRPN2RUD8W0G”(电流是假的)。

对于其余交易 - 我得到通常的 17 个单字节字母数字字符串。这意味着,对于定期付款,PayPal 返回 ProfileID,而不是 TransactionID。

因此,当我请求 GetTransactionDetails 并将此交易 ID 传递给 PayPal 时,我会收到普通付款的有效详细信息,而对于经常性付款,我会收到错误消息“交易 ID 无效”。

【问题讨论】:

  • 你好,我也面临同样的问题。

标签: php paypal transactions


【解决方案1】:

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

【讨论】:

    【解决方案2】:

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

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

    $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 中,然后在您的 paypal 帐户中分配此文件的网络路径。

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

    【讨论】:

      猜你喜欢
      • 2013-06-05
      • 2016-10-24
      • 2013-05-29
      • 2016-06-07
      • 2016-01-26
      • 1970-01-01
      • 2013-09-10
      • 2013-08-07
      • 2016-09-24
      相关资源
      最近更新 更多