0

我正在使用 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 文档上找不到它。有人可以解释一下吗?

4

2 回答 2

2

您只需要设置您的 $params 以包含使其工作所需的所有字段,并且您需要确保您使用的是 63.0 或更高版本。

不过,这可能有点棘手,因为任何 Express Checkout 流程都可能包含超过 1 笔付款,并且包含的​​每笔付款可能包含超过 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 时导致以下结果。

在此处输入图像描述

于 2013-01-26T22:29:59.787 回答
0

CI Merchant 不支持开箱即用地在 PayPal 中列出订单项目。有一个pull request支持这一点,但在我们解决一些税收计算和舍入问题之前,它不会合并到 master 中。

在正式支持之前,您可能想尝试使用分叉版本来实现这一点,或者只是自己编辑 PayPal 驱动程序以传递项目数据。

于 2013-01-27T00:53:17.963 回答