PayPal快速结账即时更新回调未被调用[沙箱]

时间:2016-06-13 19:36:13

标签: paypal paypal-sandbox

我遇到了PayPal回拨功能的麻烦,我无法让我的生活完全发挥作用。我已经仔细检查了回调URL路径,这是正确的。当用户登录到paypal时,它始终只返回默认运费。我真的不确定我在这里缺少什么,如果有人可以提供帮助的话。此外,我将回调超时设置为6,但它似乎只需要3-4秒就可以失败并返回默认运费。

我已按照此处的文档https://developer.paypal.com/docs/classic/express-checkout/integration-guide/ECInstantUpdateAPI/将其应用到我的网站。我也确定我也登录了沙箱。

SetExpressCheckout参数:

// SetExpressCheckout
$params = array (
    'METHOD' => 'SetExpressCheckout',
    'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale',
    'VERSION' => $version,                // 124.0
    'USER' => $paypal_user,
    'PWD' => $paypal_password,
    'SIGNATURE' => $signature,
    'L_SHIPPINGOPTIONNAME0' => 'Flat',
    'L_SHIPPINGOPTIONLABEL0' => 'N/A',
    'L_SHIPPINGOPTIONAMOUNT0' => '6.99',
    'L_SHIPPINGOPTIONISDEFAULT0' => 'true',
    'PAYMENTREQUEST_0_INSURANCEOPTIONSOFFERED' => 'false',
    'PAYMENTREQUEST_0_SHIPPINGAMT' => $shipping_default,    // 6.99
    'PAYMENTREQUEST_0_ITEMAMT' => $cart_total,
    'PAYMENTREQUEST_0_AMT' => $cart_total + $shipping_default,
    'MAXAMT' => $cart_total + 30, // 30 is the total possible shipping amount
    'PAYMENTREQUEST_0_CURRENCYCODE' => $paypal_currency,  // AUD
    'RETURNURL' => $paypal_return,
    'CANCELURL' => $paypal_cancel,
    'CALLBACK' => 'HTTP://localhost/moes/php/paypal_callback_php.php',
    'CALLBACKTIMEOUT' => 6,
    'CALLBACKVERSION' => '61.0',
    'ALLOWNOTE' => 1,
    'PAYMENTREQUEST_0_INVNUM' => '123' /*$invoice_number*/,
    'PAYMENTREQUEST_0_TAXAMT' => $tax,    // 0.00
);

// List each product and add to exress check-out array
foreach ($paypal_products as $k => $product){
    $params["L_PAYMENTREQUEST_0_NAME$k"] = $product['name'];
    $params["L_PAYMENTREQUEST_0_AMT$k"] = number_format($product['price'],2);
    $params["L_PAYMENTREQUEST_0_QTY$k"] = $product['qty'];
    $params["L_PAYMENTREQUEST_0_NUMBER$k"] = $product['code'];
    $params["L_PAYMENTREQUEST_0_DESC$k"] = '1';
    /* Optional shipping options to calculate shipping costs on callback
    Option weight (L_PAYMENTREQUEST_n_ITEMWEIGHTVALUEm, L_PAYMENTREQUEST_n_ITEMWEITHTUNITm)
    Option height (L_PAYMENTREQUEST_n_ITEMHEIGHTVALUEm, L_PAYMENTREQUEST_n_ITEMHEIGHTUNITm)
    Option length (L_PAYMENTREQUEST_n_ITEMLENGTHVALUEm, L_PAYMENTREQUEST_n_ITEMLENGTHUNITm)
    Option width (L_PAYMENTREQUEST_n_ITEMWIDTHVALUEm, L_PAYMENTREQUEST_n_ITEMWIDTHUNITm)*/
}

回调脚本:

<?php

// Populate variables into local variables
$method = $_POST['METHOD'];
$version = $_POST['CALLBACKVERSION'];
$token = $_POST['TOKEN'];
$currencycode = $_POST['CURRENCYCODE'];
$localecode = $_POST['LOCALECODE'];
$street = $_POST['SHIPTOSTREET'];
$street2 = $_POST['SHIPTOSTREET2'];
$city = $_POST['SHIPTOCITY'];
$state = $_POST['SHIPTOSTATE'];
$country = $_POST['SHIPTOCOUNTRY'];
$zip = $_POST['SHIPTOZIP'];

// Setting shipping rate based on country [Test only]
if ($country == "US"){
    echo "METHOD=CallbackResponse&OFFERINSURANCEOPTION=false&L_SHIPPINGOPTIONNAME0=FLat&L_SHIPPINGOPTIONLABEL0=N/A&L_SHIPPINGOPTIONAMOUNT0=10.00&L_TAXAMT0=1.00&L_INSURANCEAMOUNT0=9.00&L_SHIPPINGOPTIONISDEFAULT0=true";
} else {
    echo "METHOD=CallbackResponse&OFFERINSURANCEOPTION=false&L_SHIPPINGOPTIONNAME0=FLat&L_SHIPPINGOPTIONLABEL0=N/A&L_SHIPPINGOPTIONAMOUNT0=30.00&L_TAXAMT0=1.00&L_INSURANCEAMOUNT0=9.00&L_SHIPPINGOPTIONISDEFAULT0=true";
}

?>

我猜我在这里遗漏了一些基本的东西,或者我的方式完全是错误的。

1 个答案:

答案 0 :(得分:0)

我的问题的解决方案是:

  

本地主机/ MOES / PHP / paypal_callback_php.php

显然,PayPal无法向