我想创建一个用户可以列出商品并让买家直接通过PayPal付款的市场。
我的代码为:
$config = $config = vn3dUtil::getPaypalConfig();
$paypalService = new PayPalAPIInterfaceServiceService($config);
$setECReqDetails = new SetExpressCheckoutRequestDetailsType();
$cart=$this->ZendCart()->cart();
//for
$k=0;
foreach ($cart as $key => $po) {
$itemDetails = new PaymentDetailsItemType();
$itemDetails->Name = $po['name'];
$itemAmount = $po['price'];
$itemDetails->Amount = $itemAmount;
// $itemQuantity = $po['qty'];
$itemQuantity = '1';
$itemDetails->Quantity = $itemQuantity;
//add one product
$paymentDetails= new PaymentDetailsType();
$paymentDetails->PaymentDetailsItem[$k] = $itemDetails;
//set total
$orderTotal = new BasicAmountType();
$orderTotal->currencyID = 'USD';
$orderTotal->value = $itemAmount * $itemQuantity;
$paymentDetails->OrderTotal = $orderTotal;
$paymentDetails->PaymentAction = 'Sale';
$setECReqDetails->PaymentDetails[$k] = $paymentDetails;
//end for
$k++;
}
//
$setECReqDetails->CancelURL = vn3dUtil::DOMAIN;
$setECReqDetails->ReturnURL = vn3dUtil::DOMAIN."/store/checkout-detail";
$setECReqType = new SetExpressCheckoutRequestType();
$setECReqType->Version = '104.0';
$setECReqType->SetExpressCheckoutRequestDetails = $setECReqDetails;
$setECReq = new SetExpressCheckoutReq();
$setECReq->SetExpressCheckoutRequest = $setECReqType;
// var_dump($setECReq);
$setECResponse = $paypalService->SetExpressCheckout($setECReq);
var_dump($setECResponse->Token);
var_dump($setECResponse);
if($setECResponse->Ack=="Success"){
$this->redirect()->toUrl("https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=".$setECResponse->Token);
}
Paypal回复“并行付款必须使用卖家ID。”
你会建议这样做吗?
object(SetExpressCheckoutResponseType)[259]
public 'Token' => null
public 'Timestamp' => string '2014-02-15T20:47:42Z' (length=20)
public 'Ack' => string 'Failure' (length=7)
public 'CorrelationID' => string '412c6c6aa36c1' (length=13)
public 'Errors' =>
array (size=1)
0 =>
object(ErrorType)[268]
public 'ShortMessage' => string 'Seller ID Missing.' (length=18)
public 'LongMessage' => string 'Seller ID is mandatory for parallel payments.' (length=45)
public 'ErrorCode' => string '13115' (length=5)
public 'SeverityCode' => string 'Error' (length=5)
public 'ErrorParameters' => null
public 'Version' => string '104.0' (length=5)
public 'Build' => string '9720069' (length=7)