4

几个小时以来,我试图在贝宝快速结账中列出多种产品。必须这样做才能增加客户对他们购买的东西的信任。

我如何创建波纹管阵列以便被贝宝重新识别为多种产品?

列出 1 个产品不是问题。这是代码:

$requestParams = array(
       'RETURNURL' => '***',
       'CANCELURL' => '***'
    );

    $item = array('L_PAYMENTREQUEST_0_NAME0' => 'Test product ',
                  'L_PAYMENTREQUEST_0_DESC0' => 'Description of my item',
                  'L_PAYMENTREQUEST_0_AMT0' => '0.01',
                  'L_PAYMENTREQUEST_0_QTY0' => '1'
                 );

    $orderParams = array(
       'PAYMENTREQUEST_0_AMT' => '0.01',
       'PAYMENTREQUEST_0_CURRENCYCODE' => 'USD',
       'PAYMENTREQUEST_0_ITEMAMT' => '0.01',
       'PAYMENTREQUEST_0_SHIPPINGAMT' => '0'
    );


$response = $core->paypal->request('SetExpressCheckout',$requestParams + $item + $orderParams);

我尝试了很多组合,例如将键和值添加到 $item 数组中,以便添加更多要列出的产品:

我还尝试以类似的方式将键添加到 $orderParams 数组,但没有成功。要么我从贝宝 api 得到错误,要么贝宝只列出了第一个产品。

$item = array('L_PAYMENTREQUEST_0_NAME0' => 'Test product ',
              'L_PAYMENTREQUEST_0_DESC0' => 'Description of my item',
              'L_PAYMENTREQUEST_0_AMT0' => '0.01',
              'L_PAYMENTREQUEST_0_QTY0' => '1',

              'L_PAYMENTREQUEST_1_NAME1' => 'Test product 1',
              'L_PAYMENTREQUEST_1_DESC1' => 'Description of my next item',
              'L_PAYMENTREQUEST_1_AMT1' => '0.01',
              'L_PAYMENTREQUEST_1_QTY1' => '1'
             );

这是我的第一次集成,我了解贝宝的流程,但我无法解决这个问题。谢谢。

4

1 回答 1

6

好的,这是一个简单的技巧。对于那些可能需要它的人:

L_PAYMENTREQUEST_n_NAMEm - “n”是交易的数量,0代表1单交易 - “m”是产品的数量

$item = array('L_PAYMENTREQUEST_0_NAME0' => 'Test product ', //title of the first product
                  'L_PAYMENTREQUEST_0_DESC0' => 'Description of my item', //description of the forst product
                  'L_PAYMENTREQUEST_0_AMT0' => '0.01', //amount first product
                  'L_PAYMENTREQUEST_0_QTY0' => '1', //qty first product

                  'L_PAYMENTREQUEST_0_NAME1' => 'Test ', // title of the second product
                  'L_PAYMENTREQUEST_0_DESC1' => 'Description item',//description of the second product
                  'L_PAYMENTREQUEST_0_AMT1' => '0.01',//amount second product
                  'L_PAYMENTREQUEST_0_QTY1' => '1'//qty second product
                 );

    $orderParams = array(
       'PAYMENTREQUEST_0_PAYMENTACTION'=>'Sale', //becouse we want to sale something
       'PAYMENTREQUEST_0_AMT' => '0.02', //total amount (items amount+shipping..etc)
       'PAYMENTREQUEST_0_CURRENCYCODE' => 'USD', //curency code
       'PAYMENTREQUEST_0_ITEMAMT' => '0.02', //total amount items, without shipping and other taxes
       'PAYMENTREQUEST_0_SHIPPINGAMT' => '0' //the shipping amount, will be 0 coz we sell digital products
    );

上面您可以看到两个产品的示例。这些键和值将被发送到 express checkout api 以传递令牌。变量将与 GET 一起发送。

于 2013-09-09T13:48:54.200 回答