PayPal NVP快速结账运送选项

时间:2016-09-30 10:12:32

标签: paypal-sandbox paypal

我正在尝试使用PayPal NVP API进行上下文快速结账。我需要使用Instant Update Callback,因为运费是按地理区域计算的,PayPal Express Checkout按钮用作快速结账,然后才能获得客户的任何信息。

问题在于它似乎无法正常工作或调用回调URL。我使用以下方式开始付款:

$currencyCode = $this->currency_model->code();
$cost = $this->basket_model->get_cart_total(false, true, false, false);
$shippingCost = number_format($this->basket_model->cart_calc_delivery(), 2);

$finalCost = number_format(((float) $cost) + ((float) $shippingCost), 2);

$transaction = [
    'USER' => $username,
    'PWD' => $password,
    'SIGNATURE' => $signature,
    'VERSION' => '124.0',
    'METHOD' => 'SetExpressCheckout',
    'RETURNURL' => 'https://'.$siteUrl.'/checkout/pp/process/',
    'CANCELURL' => 'https://'.$siteUrl.'/basket/',
    'PAYMENTREQUEST_0_PAYMENTACTION' => 'SALE',
    'PAYMENTREQUEST_0_ITEMAMT' => $cost,
    //'PAYMENTREQUEST_0_TAXAMT' => '0.00',
    'MAXAMT' => number_format(((float) $finalCost) + 5, 2),
    'PAYMENTREQUEST_0_SHIPPINGAMT' => $shippingCost,
    'PAYMENTREQUEST_0_AMT' => $finalCost,
    'PAYMENTREQUEST_0_CURRENCYCODE' => $currencyCode,
    'CALLBACK' => 'https://'.$siteUrl.'/checkout/pp/options/',
    //'CALLBACKVERSION' => '204.0',
    'CALLBACKTIMEOUT' => '3',
    'L_SHIPPINGOPTIONISDEFAULT0' => 'true',
    'L_SHIPPINGOPTIONNAME0' => 'Shipping1',
    'L_SHIPPINGOPTIONAMOUNT0' => $shippingCost,
    'L_SHIPPINGOPTIONISDEFAULT1' => 'false',
    'L_SHIPPINGOPTIONNAME1' => 'Shipping2',
    'L_SHIPPINGOPTIONAMOUNT1' => number_format(((float) $shippingCost) + 5, 2),
];
$itemIndex = 0;

foreach ($_SESSION['basket'] as $key => $item) {
    $transaction['L_PAYMENTREQUEST_0_NAME'.$itemIndex] = $item->name;
    $transaction['L_PAYMENTREQUEST_0_AMT'.$itemIndex] = number_format($item->unit_price, 2);
    $transaction['L_PAYMENTREQUEST_0_QTY'.$itemIndex] = $item->quantity;
    $transaction['L_PAYMENTREQUEST_0_TAXAMT'.$itemIndex] = '0.00';
    $transaction['L_PAYMENTREQUEST_0_NUMBER'.$itemIndex] = $item->sku;
    $itemIndex++;
}

回调中的回答是这样的:

echo 'METHOD=CallbackResponse'.
    '&OFFERINSURANCEOPTION=false'.
    '&L_SHIPPINGOPTIONNAME0=Shipping'.
    '&L_SHIPPINGOPTIONAMOUNT0=20.00'.
    '&L_TAXAMT0=0'.
    '&L_SHIPPINGOPTIONISDEFAULT0=true';

只是为了测试它是否有效。即使我提供了2种初始发货方式,也没有选择器让客户选择发货方式。并且永远不会调用回调URL,并且邮件永远不会更新。

0 个答案:

没有答案