我正在使用ci-merchant,我想用PayPal Express结账。
这是我正在使用的代码:
$this->load->library('merchant');
$this->merchant->load('paypal_express');
$settings = $this->merchant->default_settings();
$settings = array(
'username' => 'bla bla bla.gmail.com',
'password' => 'bla bla bla',
'signature' => 'bla bla bla',
'test_mode' => true);
$this->merchant->initialize($settings);
$params =array(
'amount' => $this->cart->format_number($this->cart->total()),
'currency' => 'EUR',
'return_url' => 'https://www.example.com/checkout/payment_return/123',
'cancel_url' => 'https://www.example.com/checkout',
'description' => 'Esto es desc'
);
$response = $this->merchant->purchase($params);
使用上面的代码我被重定向到PayPal就好了,但在items列中我只看到一个唯一的项目。
现在我想添加每件商品说明,数量和价格。但我不知道在哪里包含我的items数组,我应该使用哪种格式。我在ci-merchant docs上找不到它。有人可以解释一下吗?
答案 0 :(得分:2)
您只需设置$ params以包含使其工作所需的所有字段,并且您需要确保使用的是63.0或更高版本。
但是,这可能有点棘手,因为任何快速结账流程都可能包含超过1个付款,并且每个付款可能包含多个项目,因此您最终会添加0,1,2等。参考。以下是SetExpressCheckout的示例,其中包含1个付款,其中包含2个项目。
[REQUESTDATA] => Array
(
[USER] => ***
[PWD] => ***
[VERSION] => 97.0
[BUTTONSOURCE] => AngellEYE_PHPClass
[SIGNATURE] => ***
[METHOD] => SetExpressCheckout
[MAXAMT] => 200.00
[RETURNURL] => http://paypal.angelleye.com/standard/samples/DoExpressCheckoutPayment.php
[CANCELURL] => http://paypal.angelleye.com/paypal/class/cancel.php
[ALLOWNOTE] => 1
[HDRIMG] => http://paypal.angelleye.com/images/hdrimg.jpg
[SOLUTIONTYPE] => Sole
[LANDINGPAGE] => Billing
[BRANDNAME] => Angell EYE
[CUSTOMERSERVICENUMBER] => 555-555-5555
[BUYEREMAILOPTIONENABLE] => 1
[PAYMENTREQUEST_0_AMT] => 100.00
[PAYMENTREQUEST_0_CURRENCYCODE] => USD
[PAYMENTREQUEST_0_ITEMAMT] => 80.00
[PAYMENTREQUEST_0_SHIPPINGAMT] => 15.00
[PAYMENTREQUEST_0_TAXAMT] => 5.00
[PAYMENTREQUEST_0_DESC] => This is a test order.
[PAYMENTREQUEST_0_NOTETEXT] => This is a test note before ever having left the web site.
[PAYMENTREQUEST_0_PAYMENTACTION] => Sale
[L_PAYMENTREQUEST_0_NAME0] => Widget 123
[L_PAYMENTREQUEST_0_DESC0] => Widget 123
[L_PAYMENTREQUEST_0_AMT0] => 40.00
[L_PAYMENTREQUEST_0_NUMBER0] => 123
[L_PAYMENTREQUEST_0_QTY0] => 1
[L_PAYMENTREQUEST_0_ITEMURL0] => http://www.angelleye.com/products/123.php
[L_PAYMENTREQUEST_0_ITEMCATEGORY0] => Digital
[L_PAYMENTREQUEST_0_NAME1] => Widget 456
[L_PAYMENTREQUEST_0_DESC1] => Widget 456
[L_PAYMENTREQUEST_0_AMT1] => 40.00
[L_PAYMENTREQUEST_0_NUMBER1] => 456
[L_PAYMENTREQUEST_0_QTY1] => 1
[L_PAYMENTREQUEST_0_ITEMURL1] => http://www.angelleye.com/products/456.php
[L_PAYMENTREQUEST_0_ITEMCATEGORY1] => Digital
)
重定向到PayPal时会导致以下情况。
答案 1 :(得分:0)
CI Merchant不支持开箱即用的PayPal中的商品订单商品。有pull request支持这一点,但在我们解决一些税收计算和四舍五入问题之前,它不会合并为主。
在正式支持之前,您可能需要尝试使用分叉版本来实现此目的,或者只是自己编辑PayPal驱动程序以传递项目数据。