贝宝付款自适应隐收费API [英] PayPal Adaptive Payments IMPLICIT Pay API

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

问题描述

我基本上想使用Adaptive支付的薪酬调用编程,并立即从我自己的支付宝账户资金发到其他帐户。 <一href=\"https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_APPayAPI\">According到文档,只要我指定的SENDEREMAIL(我自己的PayPal地址,用来设置Adaptive付款),这应该逐字工作。

然而,当我拨打电话,我总是导致创造,而不是完成。创造是指系统仍然要我手动登录到PayPal和批准付款。我真的需要当场自动发生营养费。任何帮助将是AP preciated。

下面是我的请求字符串:

 货币code = USD&安培;
RETURNURL = HTTP%3A%2F%2Fwww.website.com%2F&安培;
操作类型= PAY&安培;
cancelUrl = HTTP%3A%2F%2Fwww.website.com%2F&放大器;
receiverList.receiver%280%29.email =接收机%40gmail.com&安培;
receiverList.receiver%280%29.amount = 1.00安培;
requestEnvelope.senderEmail =我%40gmail.com&安培;
clientDetails.deviceId = mydevice在&放大器;
clientDetails.ipAddress = 127.0.0.1和放大器;
clientDetails.applicationId = APP-ZZZZZZZZZZZZZ&放大器;
requestEnvelope.errorLanguage = EN_US&安培;
备忘录=备忘录&安培;
feesPayer = EACHRECEIVER&安培;
ipnNotificationUrl = HTTP%3A%2F%2Fwww.website.com%2Fpay.php

这是来自PayPal的响应:

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


解决方案

忘记一切我前面说的。这个问题不是'SENDEREMAIL一个错误的参数,沙盒和现场之间的不一致或者,而是。

简单的改变:

  requestEnvelope.senderEmail=me@gmail.com&

要:

  senderEmail=me@gmail.com&

例如,下面的回报已完成隐性付款。

 &LT; PHP功能AdaptiveCall($ bodyparams,$方法,$ payKey){尝试
{    $ body_data = http_build_query($ bodyparams,,字符(38));
    $ URL = TRIM(https://svcs.sandbox.paypal.com/AdaptivePayments/$法。);
    $ PARAMS =阵列(HTTP=&GT;阵列(
                        办法=&GT; POST,
                        内容=&GT; $ body_data,
                            头=&GT; X-PAYPAL - 安全 - 用户名:XXXXXXXXX \\ r \\ n。
                                        X-PAYPAL-SECURITY-SIGNATURE:XXXXXXXXXXX \\ r \\ n。
                                        X-贝宝安全密码:XXXXXXX \\ r \\ n。
                                        X-PAYPAL-APPLICATION-ID:APP-80W284485P519543T \\ r \\ n。
                                        X-PAYPAL-REQUEST数据格式:NV \\ r \\ n。
                                        X-PAYPAL-RESPONSE数据格式:NV \\ r \\ n
                                    )
                    );
    //创建流上下文
     $ CTX = stream_context_create($ params)方法;
    //打开流并发送请求
     $计划生育= @fopen($网址,R,虚假,$环磷酰胺);    //获取响应
     $响应= stream_get_contents($ FP);    //检查,看看是否流是开放的
     如果($响应===假){
        抛出新的异常(PHP错误信息=$ php_errormsg中。);
     }    //关闭流
     FCLOSE($ FP);    //解析从响应AP的密钥    $ keyArray =爆炸(与&amp;,$响应);    的foreach($ keyArray为$ RVAL){
        列表($ qKey,$ qVal)=爆炸(=,$ RVAL);
            $ kArray [$ qKey] = $ qVal;
    } //打印响应以筛选测试目的
    如果($ kArray [responseEnvelope.ack] ==成功){
        回声&LT;强&gt;中$法&LT; / STRONG&GT;&LT; BR&gt;中。;
         的foreach($ kArray为$关键=&GT; $值){
        回声$键。 :。$的值。 &LT; BR /&gt;中;    }
    //返回payKey
    全球$ payKey;
    如果(空($ kArray ['payKey'])!){$ payKey = $ kArray ['payKey'];回报($ payKey); }     }
    其他{
        回声错误code:。 $ kArray [错误(0).errorId。 &LT; BR /&gt;中;
      回声'的错误信息:。 urlde code($ kArray [错误(0).message])。 &LT; BR /&gt;中;
    }   }
赶上(例外$ E){
    回声消息:|| 。$ E-&GT;的getMessage()||。
  }
}//创建付费体
$ bodyparams =阵列(requestEnvelope.errorLanguage=&gt;中EN_US
                        操作类型'=&GT; '工资',
                        货币code'=&GT; '美元',
                        receiverList.receiver(0).email'=&GT; another_account@domain.tld~~V',
                        receiverList.receiver(0).amount'=&GT; '1.00',
                        SENDEREMAIL'=&GT; XXXXXXXXX,
                        '备忘录'=&GT; 测试备忘录,
                        ipnNotificationUrl'=&GT;的http:// XXXXXXXX,
                        cancelUrl'=&GT;的http:// XXXXXXXXX,
                        RETURNURL'=&GT;的http:// XXXXXXXXXX
                    );                    //调用API付费
AdaptiveCall($ bodyparams,收费);?&GT;


  

工资回应:结果
  responseEnvelope.timestamp:2012-03-03T09%3A10%3A22.900-08%3A00结果
  responseEnvelope.ack:成功结果
  responseEnvelope.correlationId:4bc5cfc4a7514结果
  responseEnvelope.build:2486531结果
  payKey:AP-1XJ7636763429720C结果
  paymentExecStatus:已完成


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

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

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