我必须实施一个商家网站,客户通过PayPal向网站支付一些物质商品和服务费,如图所示。
我知道我需要使用自适应支付(并行或链接),并且REST API还不支持这些付款(如果我错了,请纠正我)。
经典API(NVP / SOAP)的问题在于,在网页将客户重定向到paypal时付款,paypal不会显示任何项目名称或描述。另一个问题是,当客户登录时,没有显示送货信息,并且在购买后没有向卖家发送送货地址。
感谢任何帮助。谢谢。
注意:照片显示的是我网站无法达到的效果。
注2:我想使用用户在设置paypal帐户时使用的送货地址,而不是在我从PHP进行API调用时再次发送
谢谢!
P.S。一些进行此类付款的网站,在他们的重定向网址上有https://www.paypal.com/us/cgi-bin/merchantpaymentweb?cmd=_flow&SESSION=.....
答案 0 :(得分:0)
您可以在没有自适应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
用户返回您的网站(返回网址)后,请调用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);
}
}