贝宝自适应支付 IMPLICIT Pay API [英] PayPal Adaptive Payments IMPLICIT Pay API

查看:51
本文介绍了贝宝自适应支付 IMPLICIT Pay API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我基本上是在尝试使用自适应支付的 PAY 调用以编程方式立即将资金从我自己的贝宝账户发送到其他账户.根据文档,所以只要我指定了 senderEmail(我自己的贝宝地址,用于设置自适应付款),这应该可以一字不差.

但是,当我拨打电话时,我总是得到已创建"而不是已完成"的结果.Created 意味着系统仍要我手动登录 PayPal 并批准付款.我真的需要这些付款当场自动发生.任何帮助将不胜感激.

这是我的请求字符串:

currencyCode=USD&returnUrl=http%3A%2F%2Fwww.website.com%2F&actionType=PAY&cancelUrl=http%3A%2F%2Fwww.website.com%2F&receiverList.receiver%280%29.email=receiver%40gmail.com&receiverList.receiver%280%29.amount=1.00&requestEnvelope.senderEmail=me%40gmail.com&clientDetails.deviceId=mydevice&clientDetails.ipAddress=127.0.0.1&clientDetails.applicationId=APP-ZZZZZZZZZZZZZ&requestEnvelope.errorLanguage=en_US&备忘录=备忘录&feePayer=EACHRECEIVER&ipnNotificationUrl=http%3A%2F%2Fwww.website.com%2Fpay.php

以下是 PayPal 的回复:

[responseEnvelope.timestamp] =>2012-03-01T19:09:57.290-08:00[responseEnvelope.ack] =>成功[responseEnvelope.correlationId] =>71efd416a2100[responseEnvelope.build] =>2486531[payKey] =>AP-ZZZZZZZZZZZZZZZ[paymentExecStatus] =>创建

解决方案

忘记我之前说过的一切.问题也不是 Sandbox 和 Live 之间的不一致,而是senderEmail"的错误参数.

简单的改变:

requestEnvelope.senderEmail=me@gmail.com&

致:

senderEmail=me@gmail.com&

例如,以下返回已完成"隐式付款.

 array(方法" =>邮政",内容"=>$body_data,标题" =>"X-PAYPAL-SECURITY-USERID: xxxxxxxxx\r\n" ."X-PAYPAL-安全-签名:xxxxxxxxxxx\r\n"."X-PAYPAL-安全-密码:xxxxxxx\r\n"."X-PAYPAL-APPLICATION-ID: APP-80W284485P519543T\r\n"."X-PAYPAL-REQUEST-DATA-FORMAT: NV\r\n" ."X-PAYPAL-响应-数据-格式:NV\r\n"));//创建流上下文$ctx = stream_context_create($params);//打开流并发送请求$fp = @fopen($url, "r", false, $ctx);//得到响应$response = stream_get_contents($fp);//检查流是否打开if ($response === false) {throw new Exception("php 错误信息 = " . "$php_errormsg");}//关闭流fclose($fp);//从响应中解析ap键$keyArray = expand("&", $response);foreach ($keyArray 作为 $rVal){列表($qKey,$qVal)=爆炸(=",$rVal);$kArray[$qKey] = $qVal;}//将响应打印到屏幕以进行测试如果 ( $kArray["responseEnvelope.ack"] == "Success") {echo "<strong>".$method ."</strong><br>";foreach ($kArray as $key =>$value){回声 $key .":" .$value ."<br/>";}//返回payKey全球 $payKey;if(!empty($kArray['payKey'])) { $payKey = $kArray['payKey'];返回($payKey);}}别的 {echo '错误代码:'.$kArray["error(0).errorId"] ." <br/>";回声'错误消息:'.urldecode($kArray["error(0).message"]) ." <br/>";}}捕获(异常 $e){回声消息:||".$e->getMessage()."||";}}//创建支付主体$bodyparams = array ( "requestEnvelope.errorLanguage" => "en_US",'动作类型' =>'支付','货币代码' =>'美元','receiverList.receiver(0).email' =>'another_account@domain.tld','receiverList.receiver(0).amount' =>'1.00','发件人电子邮件' =>'xxxxxxxxx','备忘录' =>'测试备忘录','ipnNotificationUrl' =>'http://xxxxxxxx','cancelUrl' =>'http://xxxxxxxxx','returnUrl' =>'http://xxxxxxxxxx');//调用支付接口AdaptiveCall($bodyparams, "Pay");?>

<块引用>

付款回复:
responseEnvelope.timestamp: 2012-03-03T09%3A10%3A22.900-08%3A00
responseEnvelope.ack:成功
responseEnvelope.correlationId:4bc5cfc4a7514
responseEnvelope.build:2486531
payKey:AP-1XJ7636763429720C
付款执行状态:已完成

I am basically trying to use the PAY call of Adaptive Payments to programmatically and immediately send funds from my own paypal account to other accounts. According to the documentation, so long as I specify the senderEmail (my own paypal address, used to set up the Adaptive Payments), this should work verbatim.

However, when I make the call, I always get result "CREATED" instead of "COMPLETED". Created means the system still wants me to manually log into PayPal and approve the payments. I really need these payments to occur automatically on the spot. Any help would be appreciated.

Here is my request string:

currencyCode=USD&
returnUrl=http%3A%2F%2Fwww.website.com%2F&
actionType=PAY&
cancelUrl=http%3A%2F%2Fwww.website.com%2F&
receiverList.receiver%280%29.email=receiver%40gmail.com&
receiverList.receiver%280%29.amount=1.00&
requestEnvelope.senderEmail=me%40gmail.com&
clientDetails.deviceId=mydevice&
clientDetails.ipAddress=127.0.0.1&
clientDetails.applicationId=APP-ZZZZZZZZZZZZZ&
requestEnvelope.errorLanguage=en_US&
memo=memo&
feesPayer=EACHRECEIVER&
ipnNotificationUrl=http%3A%2F%2Fwww.website.com%2Fpay.php

And here is the response from PayPal:

[responseEnvelope.timestamp] => 2012-03-01T19:09:57.290-08:00
[responseEnvelope.ack] => Success
[responseEnvelope.correlationId] => 71efd416a2100
[responseEnvelope.build] => 2486531
[payKey] => AP-ZZZZZZZZZZZZZZZ
[paymentExecStatus] => CREATED

解决方案

Forget everything I said earlier. The problem isn't an inconsistency between Sandbox and Live either, but rather a wrong parameter for 'senderEmail'.

Simply change:

requestEnvelope.senderEmail=me@gmail.com&

To:

senderEmail=me@gmail.com&

For example, the following returns a 'COMPLETED' implicit payment.

<?php

function AdaptiveCall($bodyparams, $method, $payKey) {

try
{

    $body_data = http_build_query($bodyparams, "", chr(38));
    $url = trim("https://svcs.sandbox.paypal.com/AdaptivePayments/".$method."");
    $params = array("http" => array( 
                        "method" => "POST",
                        "content" => $body_data,
                            "header" => "X-PAYPAL-SECURITY-USERID: xxxxxxxxx\r\n" .
                                        "X-PAYPAL-SECURITY-SIGNATURE: xxxxxxxxxxx\r\n" .
                                        "X-PAYPAL-SECURITY-PASSWORD: xxxxxxx\r\n" .
                                        "X-PAYPAL-APPLICATION-ID: APP-80W284485P519543T\r\n" .
                                        "X-PAYPAL-REQUEST-DATA-FORMAT: NV\r\n" .
                                        "X-PAYPAL-RESPONSE-DATA-FORMAT: NV\r\n" 
                                    )
                    );


    //create stream context
     $ctx = stream_context_create($params);


    //open the stream and send request
     $fp = @fopen($url, "r", false, $ctx);

    //get response
     $response = stream_get_contents($fp);

    //check to see if stream is open
     if ($response === false) {
        throw new Exception("php error message = " . "$php_errormsg");
     }

    //close the stream
     fclose($fp);

    //parse the ap key from the response

    $keyArray = explode("&", $response);

    foreach ($keyArray as $rVal){
        list($qKey, $qVal) = explode ("=", $rVal);
            $kArray[$qKey] = $qVal;
    }

 //print the response to screen for testing purposes
    If ( $kArray["responseEnvelope.ack"] == "Success") {
        echo "<strong>".$method ."</strong><br>";
         foreach ($kArray as $key =>$value){
        echo $key . ": " .$value . "<br/>";

    }
    // Return payKey
    global $payKey;
    if(!empty($kArray['payKey'])) { $payKey = $kArray['payKey']; return($payKey); }

     }
    else {
        echo 'ERROR Code: ' .  $kArray["error(0).errorId"] . " <br/>";
      echo 'ERROR Message: ' .  urldecode($kArray["error(0).message"]) . " <br/>";
    }

   }


catch(Exception $e) {
    echo "Message: ||" .$e->getMessage()."||";
  }
}



//Create Pay body
$bodyparams = array (   "requestEnvelope.errorLanguage" => "en_US",
                        'actionType' => 'PAY',
                        'currencyCode' => 'USD',
                        'receiverList.receiver(0).email' => 'another_account@domain.tld',
                        'receiverList.receiver(0).amount' => '1.00',
                        'senderEmail' => 'xxxxxxxxx',
                        'memo' => 'Test memo',
                        'ipnNotificationUrl' => 'http://xxxxxxxx',
                        'cancelUrl' => 'http://xxxxxxxxx',
                        'returnUrl' => 'http://xxxxxxxxxx'
                    );

                    // Call Pay API
AdaptiveCall($bodyparams, "Pay");

?>

Pay response:
responseEnvelope.timestamp: 2012-03-03T09%3A10%3A22.900-08%3A00
responseEnvelope.ack: Success
responseEnvelope.correlationId: 4bc5cfc4a7514
responseEnvelope.build: 2486531
payKey: AP-1XJ7636763429720C
paymentExecStatus: COMPLETED

这篇关于贝宝自适应支付 IMPLICIT Pay API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆