在 Payflow 定期付款中被批准为 [RESPMSG],但 PayPal 帐户中没有交易历史记录

Posted

技术标签:

【中文标题】在 Payflow 定期付款中被批准为 [RESPMSG],但 PayPal 帐户中没有交易历史记录【英文标题】:Getting Approved as [RESPMSG] in Payflow recurring payment, but no transaction history in PayPal account 【发布时间】:2017-05-01 23:43:34 【问题描述】:

我正在尝试在沙盒模式下使用 Payflow 进行一次性和定期付款。

这是我的代码:

$sandbox = TRUE;
$api_endpoint = 'https://pilot-payflowpro.paypal.com';

$VENDOR = '***abcd';
$PARTNER = 'PayPal';
$PWD = '**ab#$12345';
$USER = '***abcd';
$secureTokenId = uniqid('', true);

if ($payment_type == 'Non Recurring') 
    // Store request params in an array
    $request_params = array
    (
        'USER' => $USER,
        'PWD' => $PWD, 
        'PARTNER' => $PARTNER,
        'VENDOR' => $VENDOR,
        'TRXTYPE' => 'A',  
        'TENDER'=> 'C',
        'ACTION' => 'A',  
        'ACCT' => $results[0]->cerditcardno, 
        'AMT' => $price, 
        'EXPDATE' => $results[0]->cardexpiresmounth.$results[0]->cardexpiresyear, 
        'CVV2' => $results[0]->cvc,            
        'IPADDRESS' => $_SERVER['REMOTE_ADDR'],
        'FIRSTNAME' => $results[0]->display_name, 
        'LASTNAME' =>  $results[0]->lastname, 
        'STREET' => $results[0]->Address, 
        'CITY' => $results[0]->city,
        'STATE' => $results[0]->state,                     
        'COUNTRYCODE' => 'US', 
        'ZIP' => $results[0]->zipcode, 
        );

    // Loop through $request_params array to generate the NVP string.
    $nvp_string1 = '';
    foreach($request_params as $var=>$val)
        $nvp_string1 .= '&'.$var.'='.$val;
    
    $nvp_string = substr($nvp_string1, 1);

    // Send NVP string to PayPal and store response
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_VERBOSE, 1);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); 
    curl_setopt($curl, CURLOPT_TIMEOUT, 60);
    curl_setopt($curl, CURLOPT_URL, $api_endpoint);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl, CURLOPT_POST, true);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $nvp_string);

    $result = curl_exec($curl); 
    curl_close($curl);

    $paypalResponse = array();
    parse_str($result, $paypalResponse);

    $paypal_result = $paypalResponse['RESULT'];
    $securetoken = $paypalResponse['SECURETOKEN'];
    $securetoken_id = $paypalResponse['SECURETOKENID'];
    $respmsg = $paypalResponse['RESPMSG'];
    $payload=json_encode($paypalResponse);

    $paymenttable=$wpdb->prefix."payments";
    $insert_txn = "INSERT INTO $paymenttable(`txn_id`,`status`,`booking_id`,`amount`,`payload`,`timestamp`) VALUES ('$txn_id','$respmsg','$book_id','$amount','$payload',UNIX_TIMESTAMP(NOW()))";

    $insert_txn_query = $wpdb->query($insert_txn);

    // Parse the API response

    if($respmsg == 'Approved')
        $bookingtable=$wpdb->prefix."booking";
        $wpdb->query("UPDATE $bookingtable SET subscription_status='Active' WHERE id='$booking_id'");
        $payment_success = 1;
    
    else
        $payment_success = 0;   
    

else

    if ($_POST['frequency_id'] == 'Every week' ) 
        $billing_period = 'Week';
        $billing_frequency = 52;
    
    elseif ($_POST['frequency_id'] == 'Every 2 weeks') 
        $billing_period = 'SemiMonth';
        $billing_frequency = 1;
    
    elseif ($_POST['frequency_id'] == 'Every 4 weeks') 
        $billing_period = 'Month';
        $billing_frequency = 12;
    
    // Store request params in an array
    $request_params = array
    (
        'TRXTYPE' => 'A',
        'TENDER'=> 'C',
        'ACTION' => 'A',
        'VERBOSITY' => 'MEDIUM',
        'USER' => $USER,
        'PWD' => $PWD,
        'PARTNER' => $PARTNER,
        'VENDOR' => $VENDOR,
        'PROFILENAME' => 'RegularSubscription',
        'ACCT' => $results[0]->cerditcardno,
        'AMT' => $price,
        'EXPDATE' => $results[0]->cardexpiresmounth.$results[0]->cardexpiresyear,
        'CVV2' => $results[0]->cvc,
        'START' => date("mdY"),
        'TERM' => '0',
        'PAYPERIOD' => $billing_period, #Period of time between billings
        'MAXFAILEDPAYMENTS' => 3,    #Maximum failed payments before suspension of the profile
        'OPTIONALTRX' => 'S',
        'OPTIONALTRXAMT' => '2.00',
        'IPADDRESS' => $_SERVER['REMOTE_ADDR'],               
        'CREATESECURETOKEN' => 'Y',
        'SECURETOKENID' => $secureTokenId,
        'FIRSTNAME' => $results[0]->display_name, 
        'LASTNAME' =>  $results[0]->lastname, 
        'STREET' => $results[0]->Address, 
        'CITY' => $results[0]->city,
        'STATE' => $results[0]->state,                     
        'COUNTRYCODE' => 'US', 
        'ZIP' => $results[0]->zipcode,
    );

    // Loop through $request_params array to generate the NVP string.
    $nvp_string1 = '';
    foreach($request_params as $var=>$val)
        $nvp_string1 .= '&'.$var.'='.$val;
    
    $nvp_string = substr($nvp_string1, 1);

    // setting the curl parameters.
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, $api_endpoint);
    curl_setopt($curl, CURLOPT_VERBOSE, 1);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); // Make it true for live url.
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
    curl_setopt($curl, CURLOPT_TIMEOUT, 60);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl, CURLOPT_POST, true);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $nvp_string);

    $result = curl_exec($curl); 
    // Check if any error occurred
    if(curl_errno($curl))
    
        echo 'Curl error: ' . curl_error($curl);
    
    curl_close($curl);

    $paypalResponse = array();
    parse_str($result, $paypalResponse);

    $paypal_result = $paypalResponse['RESULT'];
    $securetoken = $paypalResponse['SECURETOKEN'];
    $securetoken_id = $paypalResponse['SECURETOKENID'];
    $respmsg = $paypalResponse['RESPMSG'];


这是我收到的 PayPal 回复:

Array
(
    [RESULT] => 0
    [RESPMSG] => Approved
    [SECURETOKEN] => 9vaaCvieCA0arm7qBM87FrAgw
    [SECURETOKENID] => 5853a15a7716b1.59486056
)

但是,我没有收到任何交易 ID,也无法在 PayPal 沙盒帐户中看到任何交易。此外,当我登录经理帐户时,服务设置下没有定期计费的配置文件。

我做错了什么?

【问题讨论】:

【参考方案1】:

我认为您正在传递 CREATESECURETOKEN=Y 来创建您不需要的配置文件。甚至是安全令牌 ID。以下是用于创建循环配置文件的示例负载

有效载荷:

TRXTYPE=R&TENDER=C&PARTNER=PayPal&VENDOR=Acme&USER=Acme&PWD=a1b2c3d4&ACTION=A
&PROFILENAME=RegularSubscription&AMT=42.00&ACCT=4012888888881881&EXPDATE=0203
&START=12012013&PAYPERIOD=WEEK&TERM=12&OPTIONALTRX=S&OPTIONALTRXAMT=2.00
&COMMENT1=First-time customer

文档: https://developer.paypal.com/docs/classic/payflow/recurring-billing/

【讨论】:

以上是关于在 Payflow 定期付款中被批准为 [RESPMSG],但 PayPal 帐户中没有交易历史记录的主要内容,如果未能解决你的问题,请参考以下文章

Payflow 使用 PayPal 帐户创建定期付款

使用 Payflow Pro 进行定期付款 - 交易类型无效

Paypal 高级付款和 PayFlow 链接与重复付款

Paypal payflow 在一笔交易中有两个定期订阅

自适应付款和预先批准/定期付款

paypal定期支付解决方案