paypal PHP并行支付期间如何显示物品描述和送货地址?

Posted

技术标签:

【中文标题】paypal PHP并行支付期间如何显示物品描述和送货地址?【英文标题】:How to display item description and shipping address during paypal PHP parallel payment? 【发布时间】:2016-02-17 07:58:09 【问题描述】:

我必须实现一个商家网站,客户通过贝宝向卖家支付一些材料商品和服务费,如图所示。

我知道我需要使用自适应支付(并行或链式)并且 REST API 还不支持这些支付(如果我错了,请纠正我)。

经典 API (NVP/SOAP) 的问题是,在支付过程中,当网页将客户重定向到 paypal 时,paypal 不显示任何项目名称或描述。另一个问题是,当客户登录时,没有显示送货信息,并且在购买后没有向卖家发送送货地址。

感谢任何帮助。谢谢。

注意:照片显示了我的网站没有达到的预期结果。

注意 2: 我想使用用户在设置 paypal 帐户时使用的送货地址,而不是在我从 php 进行 API 调用时再次发送它

谢谢!

附:一些进行这种支付的网站,在他们重定向到贝宝的网址上有https://www.paypal.com/us/cgi-bin/merchantpaymentweb?cmd=_flow&SESSION=.....

【问题讨论】:

【参考方案1】:

您可以在不使用 Adaptive Payments API 的情况下进行并行支付Express Checkout API 让您可以选择添加多个接收者。

如果您在 API 调用中使用 NVP 字符串,您可以执行以下操作以获得 2 个接收器:

$nvpreq="METHOD=" . $METHOD //required
. "&VERSION=" . $VERSION  //required
. "&PWD=" . $PWD  //required
. "&USER=" . $USER  //required
. "&SIGNATURE=" . $SIGNATURE  //required
. "&RETURNURL=" . $RETURNURL  //required
. "&CANCELURL=" . $CANCELURL  //required    

. "&PAYMENTREQUEST_0_DESC=" . $OVERALLDESCRIPTION  //optional but best practices
. "&PAYMENTREQUEST_0_PAYMENTACTION=" . $PAYMENTACTION //optional but best practices
. "&PAYMENTREQUEST_0_AMT=" . $TOTALAMT //required = PAYMENTREQUEST_0_ITEMAMT + PAYMENTREQUEST_0_SHIPPINGAMT + PAYMENTREQUEST_0_TAXAMT + PAYMENTREQUEST_0_INURANCEAMT
. "&PAYMENTREQUEST_0_ITEMAMT=" . $TOTALITEMAMT  //optional but best practice = (L_PAYMENTREQUEST_0_AMT0 x L_PAYMENTREQUEST_0_QTY0) + (L_PAYMENTREQUEST_0_AMT1 x L_PAYMENTREQUEST_0_QTY1)
. "&PAYMENTREQUEST_0_SHIPPINGAMT=" . $SHIPPINGAMOUNT  //optional but best practices
. "&PAYMENTREQUEST_0_CURRENCYCODE=" . $CURRENCYCODE  //optional but best practices
. "&PAYMENTREQUEST_0_TAXAMT=" . $TAX  //optional but best practices

//1st seller information, specific to parallel payment
. "&PAYMENTREQUEST_0_SELLERPAYPALACCOUNTID=" . $SELLER1
. "&PAYMENTREQUEST_0_PAYMENTREQUESTID=" . $UNIQUESELLERID1

. "&PAYMENTREQUEST_0_NOTIFYURL=" . $IPNURL  //optional but best practices

//Line items - (optional)
. "&L_PAYMENTREQUEST_0_NAME0=" . $DESCRIPTION1 //optional but best practices
. "&L_PAYMENTREQUEST_0_DESC0=" . $DESCRIPTION1 //optional but best practices
. "&L_PAYMENTREQUEST_0_AMT0=" . $PAYMENTREQUEST_AMT1 //optional but best practices
. "&L_PAYMENTREQUEST_0_QTY0=" . $PAYMENTQUANTITY1 //optional but best practices

. "&L_PAYMENTREQUEST_0_NAME1=" . $DESCRIPTION2 //optional but best practices
. "&L_PAYMENTREQUEST_0_DESC1=" . $DESCRIPTION2 //optional but best practices
. "&L_PAYMENTREQUEST_0_AMT1=" . $PAYMENTREQUEST_AMT2 //optional but best practices
. "&L_PAYMENTREQUEST_0_QTY1=" . $PAYMENTQUANTITY2 //optional but best practices

. "&L_PAYMENTREQUEST_0_NAME2=" . $DISCOUNTTXT //optional but best practices
. "&L_PAYMENTREQUEST_0_DESC2=" . $DISCOUNTTXT //optional but best practices
. "&L_PAYMENTREQUEST_0_AMT2=" . $DISCOUNTAMT //optional but best practices
. "&L_PAYMENTREQUEST_0_QTY2=" . $DISCOUNTQTY //optional but best practices

//Address information
. "&PAYMENTREQUEST_0_SHIPTONAME=" . $SHIPPINGNAME
. "&PAYMENTREQUEST_0_SHIPTOSTREET=" . $SHIPPINGSTREET
. "&PAYMENTREQUEST_0_SHIPTOSTREET2=" . $SHIPPINGSTREET2
. "&PAYMENTREQUEST_0_SHIPTOCITY=" . $SHIPPINGCITY
. "&PAYMENTREQUEST_0_SHIPTOSTATE=" . $SHIPPINGSTATE
. "&PAYMENTREQUEST_0_SHIPTOZIP=" . $SHIPPINGZIPCODE
. "&PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE=" . $SHIPPINGCOUNTRYCODE
. "&PAYMENTREQUEST_0_SHIPTOPHONENUM=" . $SHIPTOPHONENUM

//2nd seller information
. "&PAYMENTREQUEST_1_DESC=" . $DESCRIPTIONSELLER2
. "&PAYMENTREQUEST_1_PAYMENTACTION=" . $PAYMENTACTIONSELLER2
. "&PAYMENTREQUEST_1_AMT=" . $AMOUNTSELLER2
. "&PAYMENTREQUEST_1_ITEMAMT=" . $AMOUNTSELLER2
. "&PAYMENTREQUEST_1_CURRENCYCODE=" . $CURRENCYCODESELLER2
. "&PAYMENTREQUEST_1_SELLERPAYPALACCOUNTID=" . $SELLER2
. "&PAYMENTREQUEST_1_PAYMENTREQUESTID=" . $UNIQUESELLERID2

. "&L_PAYMENTREQUEST_1_NAME0=" . $DESCRIPTIONSELLER2
. "&L_PAYMENTREQUEST_1_DESC0=" . $DESCRIPTIONSELLER2
. "&L_PAYMENTREQUEST_1_AMT0=" . $AMOUNTSELLER2
. "&L_PAYMENTREQUEST_1_QTY0=" . $QUANTITYSELLER2
. "&L_PAYMENTREQUEST_1_ITEMCATEGORY0=Digital"


//Payment page settings
. "&ALLOWNOTE=" . $ALLOWNOTE
. "&ADDROVERRIDE=" . $ADDROVERRIDE
. "&NOSHIPPING=" . $NOSHIPPING
. "&LOCALECODE=" . $LOCALECODE
. "&LANDINGPAGE=" . $LANDINGPAGE;

如您所见,我们有两个接收器,但您可以添加更多。对于每个收款人,您可以添加将显示在付款页面上的行项目。

在此示例中,我仅为第一个接收方添加行项目。如果您想为第二个接收者添加行项目,只需将以下内容添加到 NVP 字符串中:

. "&L_PAYMENTREQUEST_1_NAME0=" . $DESCRIPTION1 //optional but best practices
    . "&L_PAYMENTREQUEST_1_DESC0=" . $DESCRIPTION1 //optional but best practices
    . "&L_PAYMENTREQUEST_1_AMT0=" . $PAYMENTREQUEST_AMT1 //optional but best practices
    . "&L_PAYMENTREQUEST_1_QTY0=" . $PAYMENTQUANTITY1 //optional but best practices

一旦用户返回您的网站(返回 url),调用 GetExpressCheckout API 并将结果存储在一个变量中:

$nvpreq="USER=" . $_SESSION['USER'] 
. "&PWD=" . $_SESSION['PWD'] 
. "&SIGNATURE=" . $_SESSION['SIGNATURE']
. "&METHOD=GetExpressCheckoutDetails"
. "&VERSION=" . $_SESSION['VERSION']      
. "&TOKEN=" . $_SESSION['PP_TOKEN']
;
//Send the NVP string to the PayPal server, store the result in a variable.
$resultECD = ....

最终使用 GetExpressCheckout 结果构建 NVP 字符串并调用 DoExpressCheckoutPayment:

$nvpDoECReq="USER=" . $_SESSION['USER'] 
. "&PWD=" . $_SESSION['PWD'] 
. "&SIGNATURE=" . $_SESSION['SIGNATURE']
. "&METHOD=DoExpressCheckoutPayment"      
. "&PAYMENTREQUEST_0_PAYMENTACTION=" . $_SESSION['PAYMENT_ACTION'];     // payment type

//Build the DoExpressCheckout request
foreach ($resultECD as $i => $value)   
//Ignore some elements of the GetExpressCheckoutDetails answer
    if ((!($i == "CHECKOUTSTATUS")) && (!($i == "TIMESTAMP")) && (!($i == "CORRELATIONID")) && (!($i == "ACK")) && (!($i == "BUILD"))) 
                    $nvpDoECReq = $nvpDoECReq . "&" . urldecode($i) . "=" . urldecode($value);
    
   

【讨论】:

非常感谢。我不知道我可以通过快速结账进行并行付款,你救了我的命。虽然,当我调用 DoExpressCheckoutPayment 时,只完成了“服务”付款,但对于其他主要付款,它说它是重复付款(此令牌的成功交易已经完成。)并且有一个内部错误。这是因为我要进行两次付款(并行)吗?再次感谢您。 不客气,很高兴我能提供帮助。 DoExpressCheckoutPayment 应该可以工作。你传递的是什么 nvp 字符串?在我的代码中,我传递了与 SetExpressCheckout 中内置的变量相同的变量,包括行项目和所有内容。你也调用 GetExpressCheckoutDetails 吗? 感谢您的快速回复。是的,在 returnUrl 之后,我使用相同的 nvp 字符串调用 GetExpressCheckoutDetails 和 DoExpressCheckoutPayment,但我添加了从 paypal 返回的令牌和 PayerId。在这两种情况下,我都会收到带有 [L_SHORTMESSAGE0] => 重复请求的 SuccessWithWarning;由于内部错误,必须支付给卖方的第一笔付款失败,而用于服务的第二笔付款成功。感谢您的宝贵时间。 请看我更新的帖子。我添加了另一个 API 调用。它应该对你有所帮助。 谢谢,这是生成字符串的好方法,我发现了问题,但找不到解决方案。 GetExpressCheckoutDetails 不会为两次付款(仅针对第二次付款)返回 TransactionId,这可能是因为向第一个接收方付款失败。如果我能对这个问题有任何帮助,我将不胜感激。谢谢。

以上是关于paypal PHP并行支付期间如何显示物品描述和送货地址?的主要内容,如果未能解决你的问题,请参考以下文章

PayPal 如何计算和分配并行支付交易费用?

在android中使用PayPal实现并行支付

php并行支付-交易手续费

paypal, php - 将贝宝支付整合到网站中

使用非托管 PayPal 按钮时如何使用 IPN 验证 PayPal 数据

Paypal自适应支付(并行)550001错误