我试图让自适应支付工作正常工作(一次性支付多个用户)。我正在尝试以下SOAP请求:
my $content = sprintf( $format, qq|<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<actionType>PayRequest</actionType>
<PayRequest>
<requestEnvelope>
<errorLanguage>en_US</errorLanguage>
<currencyCode>USD</currencyCode>
<receiverList>
<receiver>
<amount>5</amount>
<email>test email here -but wont let me post it!</email>
</receiver>
</receiverList>
<returnUrl>silly forum wont let me post a test link here???</returnUrl>
<cancelUrl>silly forum wont let me post a test link here???</cancelUrl>
</requestEnvelope>
<payKey>AP-xxxxxxxxxxxxx</payKey>',
</PayRequest>
</soapenv:Body>
</soapenv:Envelope>|);
这给了我很多错误:
'error' => [
{
'parameter' => [
'requestEnvelope',
'null'
],
'domain' => 'PLATFORM',
'category' => 'Application',
'subdomain' => 'Application',
'errorId' => '580022',
'severity' => 'Error',
'message' => 'Invalid request parameter: requestEnvelope cannot be null'
},
{
'parameter' => [
'actionType',
'null'
],
'domain' => 'PLATFORM',
'category' => 'Application',
'subdomain' => 'Application',
'errorId' => '580022',
'severity' => 'Error',
'message' => 'Invalid request parameter: actionType cannot be null'
},
{
'parameter' => [
'cancelUrl',
'null'
],
'domain' => 'PLATFORM',
'category' => 'Application',
'subdomain' => 'Application',
'errorId' => '580022',
'severity' => 'Error',
'message' => 'Invalid request parameter: cancelUrl cannot be null'
},
{
'parameter' => [
'currencyCode',
'null'
],
'domain' => 'PLATFORM',
'category' => 'Application',
'subdomain' => 'Application',
'errorId' => '580022',
'severity' => 'Error',
'message' => 'Invalid request parameter: currencyCode cannot be null'
},
{
'parameter' => [
'receiverList',
'null'
],
'domain' => 'PLATFORM',
'category' => 'Application',
'subdomain' => 'Application',
'errorId' => '580022',
'severity' => 'Error',
'message' => 'Invalid request parameter: receiverList cannot be null'
},
{
'parameter' => [
'returnUrl',
'null'
],
'domain' => 'PLATFORM',
'category' => 'Application',
'subdomain' => 'Application',
'errorId' => '580022',
'severity' => 'Error',
'message' => 'Invalid request parameter: returnUrl cannot be null'
}
],
我有点困惑的是,为什么它说所有这些价值都是不合格的,即使我明确地传递了它们?它检测到我传入的不同参数,但它似乎并不喜欢从中获取值
任何人都可以建议我做错了什么吗?
更新2:
我仍然无法让SetPaymentOptions
功能完全适合我。
以下是我正在制作的JSON请求示例,以更新单位/运费等:
{
"receiverOptions": [
{
"receiver":{
"email":"andyxxx@gmail.com"
},
"invoiceData":{
"totalShipping":10,
"totalTax":5,
"item":[
{
"itemPrice":25,
"name":"ITEM1",
"price":50,
"itemCount":2
}
]
},
"SenderOptions":{
"requireShippingAddressSelection":1,
"addressOverride":1
},
"customId":"foo123"
}
],
"requestEnvelope":{
"errorLanguage":"en_US",
"detailLevel":"ReturnAll"
},
"payKey":"AP-8AK803068V089131W"
}
然后,当您使用 PaymentDetails 重新获取交易时,它没有任何新的送货/税/单位更改:
'paymentInfoList' => {
'paymentInfo' => [
{
'pendingRefund' => 'false',
'receiver' => {
'accountId' => 'AH92SPWMDXTHJ',
'email' => 'andyxxx@gmail.com',
'amount' => '65.00',
'primary' => 'false',
'paymentType' => 'GOODS'
}
}
]
},
真正令人讨厌的部分,就是如果我更改运费/总额/税金值,那么这个数字就不会与原来的数字相匹配&#34; Pay&# 34;请求...然后我收到错误:
ERROR: The total invoiced amount for andyxxx@gmail.com does not match the amount in the pay request at test.cgi line 127.
因此必须提取值 - 但它只是拒绝在具有相同PaymentDetails
的{{1}}请求中显示它们
请帮助 - 因为我现在已经结束了这个!#/ p>
答案 0 :(得分:1)
我认为您需要将namespace属性添加到XML参数中。看看这个样本请求可以正常工作。
<?xml version="1.0" encoding="utf-8"?>
<PayRequest xmlns="http://svcs.paypal.com/types/ap">
<requestEnvelope xmlns="">
<detailLevel>ReturnAll</detailLevel>
<errorLanguage>en_US</errorLanguage>
</requestEnvelope>
<actionType xmlns="">PAY</actionType>
<cancelUrl xmlns="">http://paypal.angelleye.com/paypal/class/1.2/Pay_Cancel.php</cancelUrl>
<clientDetails xmlns="">
<applicationId xmlns="">APP-80W284485P519543T</applicationId>
<ipAddress xmlns="">37.187.79.225</ipAddress>
<partnerName xmlns="">Always Give Back</partnerName>
</clientDetails>
<currencyCode xmlns="">USD</currencyCode>
<receiverList xmlns="">
<receiver xmlns="">
<amount xmlns="">10.00</amount>
<email xmlns="">sandbo_1204199080_biz@angelleye.com</email>
</receiver>
<receiver xmlns="">
<amount xmlns="">5.00</amount>
<email xmlns="">usb_1329725429_biz@angelleye.com</email>
<invoiceId xmlns="">123-ABCDEF</invoiceId>
</receiver>
</receiverList>
<sender>
<useCredentials xmlns=""></useCredentials>
</sender>
<account xmlns="">
<phone xmlns=""></phone>
</account>
<returnUrl xmlns="">http://paypal.angelleye.com/paypal/class/1.2/Pay_Return.php</returnUrl>
</PayRequest>
答案 1 :(得分:1)
使用设置为CREATE的操作调用Pay API,然后将您从中获得的paykey传递给SetPaymentOptions。这样,您就可以为交易中的每个接收者设置其他参数,例如项目,送货信息等。
答案 2 :(得分:0)
好的,所以最后我发现我可以使用JSON(出于某种原因,SOAP请求只是不想为我工作 - 它一直在呻吟我需要使用SOAP11或SOAP12,这是!)< / p>
以下是我使用JSON方法处理PayPal并行付款的原因:
use HTTP::Request::Common;
use LWP::UserAgent;my $user = 'foobar.user';
my $password = '1396280437';
my $signature = 'the secret sig';
my $application_id = 'APP-80W284485P519543T';
my $url = 'https://svcs.sandbox.paypal.com/AdaptivePayments/Pay';
my $ua = LWP::UserAgent->new();
my $headers = HTTP::Headers->new(
'X-PAYPAL-SECURITY-USERID' => $user,
'X-PAYPAL-SECURITY-PASSWORD' => $password,
'X-PAYPAL-SECURITY-SIGNATURE' => $signature,
'X-PAYPAL-APPLICATION-ID' => $application_id,
'X-PAYPAL-DEVICE-IPADDRESS' => $ENV{REMOTE_ADDR},
'X-PAYPAL-REQUEST-DATA-FORMAT' => 'JSON',
'X-PAYPAL-RESPONSE-DATA-FORMAT' => 'JSON'
);
my $json_var = {
requestEnvelope => {
detailLevel => "ReturnAll",
errorLanguage => "en_US",
},
actionType => "PAY",
currencyCode => "USD",
receiverList => {
receiver => [
{
amount => 5,
email => 'testing@gmail.com'
},
{
amount => 15,
email => 'foobar@gmail.com'
}
],
},
returnUrl => 'http://sitexx.com/return.cgi',
cancelUrl => 'http://sitexx.com/cancel.html'
};
use JSON;
my $new_json = JSON::to_json($json_var);
my $request = HTTP::Request->new( 'POST', $url, $headers, $new_json );
my $response = $ua->request( $request );
my $json_returned = decode_json($response->decoded_content);
print qq|Location: https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_ap-payment&paykey=$json_returned->{payKey} \n\n|;
我唯一无法解决的问题是如何为每个人提供不同的运费价格。使用普通的HTML表单,您可以这样做:
<input type="hidden" name="shipping" value="9">
但是,尝试在“接收器”部分内传递“送货”作为值似乎不起作用。不确定是否有人对此有任何建议?
更新:
实际上,嗯,也许它不起作用。根据此页面:https://developer.paypal.com/docs/classic/api/adaptive-payments/SetPaymentOptions_API_Operation/,格式应为:&receiverOptions[0].receiver.email=test@test.com&receiverOptions[0].invoiceData.item[0].name=ITEM1&receiverOptions[0].invoiceData.item[0].price=50.0&receiverOptions[0].invoiceData.item[0].itemCount=2&receiverOptions[0].invoiceData.item[0].itemPrice=25.0&receiverOptions[0].invoiceData.totalTax=25.0&receiverOptions[0].invoiceData.totalShipping=25.0
我传递的JSON如下:
{"receiverOptions":[{"receiver":{"email":"andyxxx@gmail.com"},"invoiceData":{"item":[{"name","ITEM1","price",50,"itemCount",2,"itemPrice",25,"totalTax",5,"totalShipping",10}]}},{"receiver":{"email":"foobar@gmail.com"},"invoiceData":{"item":[{"name","ITEM2","price",15,"itemCount",1,"itemPrice",15,"totalTax",0,"totalShipping",20}]}}],"requestEnvelope":{"errorLanguage":"en_US","detailLevel":"ReturnAll"},"payKey":"AP-2LN695598Y955615N"}
回复如下:
'responseEnvelope' => {
'correlationId' => '0ba8c3bf33425',
'timestamp' => '2014-04-01T07:10:07.752-07:00',
'ack' => 'Success',
'build' => '10273932'
}
...所以它不致命......但是当我转到付款页面时,我看不到任何运费,数量(或我在这里添加的任何其他内容)。我有点困惑为什么会这样呢?
JSON的更漂亮版本(在转换为JSON之前的perl变量中),更容易阅读:
receiverOptions => [
{
receiver => {
email => 'andyxxx@gmail.com'
},
invoiceData => {
item => [{
name => "ITEM1",
price => 50,
itemCount => 2,
itemPrice => 25,
totalTax => 5,
totalShipping => 10,
}]
}
},{
receiver => {
email => 'foobar@gmail.com'
},
invoiceData => {
item => [{
name => "ITEM2",
price => 15,
itemCount => 1,
itemPrice => 15,
totalTax => 0,
totalShipping => 20,
}]
}
}
]
有什么建议吗?