【问题标题】:Use Angelleye Paypal Express Checkout Class for Parallel Payments使用 Angelleye Paypal Express Checkout Class 进行并行支付
【发布时间】:2015-04-07 11:12:29
【问题描述】:

我正在使用 Angelleye Paypal 类设置快速结帐。 使用演示,我可以接受自己支付多件商品的费用。 我有一个代表人们做广告的网站,并且构建了购物车并将值分解为每个卖家的数组。

如何使用 SetExpressCheckout.php 为接收器创建数组。

这是我从购物车中获得的数组的演示

Array
(
[102340] => Array
    (
        [name] => Mandy
        [paypal] => sales@one.co.uk
        [artwork] => Array
            (
                [data_id] => Array
                    (
                        [0] => 1034
                        [1] => 1038
                    )

                [name] => Array
                    (
                        [0] => Pink Foxgloves
                        [1] => Big Red Poppies
                    )

                [qty] => Array
                    (
                        [0] => 1
                        [1] => 1
                    )

                [price] => Array
                    (
                        [0] => 260
                        [1] => 288
                    )

            )

        [amount] => 548
    )

[102341] => Array
    (
        [name] => John C
        [paypal] => sales@two.co.uk
        [artwork] => Array
            (
                [data_id] => Array
                    (
                        [0] => 1052
                    )

                [name] => Array
                    (
                        [0] => Success
                    )

                [qty] => Array
                    (
                        [0] => 1
                    )

                [price] => Array
                    (
                        [0] => 46.75
                    )

            )

        [amount] => 46.75
    )

)

所以 bascally mandy 已经卖出了 2 件商品:

id:1034 名称:Pink Foxgloves 数量:1 小计:260.00

id:1038 名称:大红罂粟数量:1 小计:288.00

约翰卖掉了

id:1052 名称:成功数量:1 小计:46.75

我也有总数:594.75

如果我能在快速结账时得到收货人,那就太好了,如果我也能得到他们的物品,那就太好了。

提前致谢。

【问题讨论】:

    标签: php paypal


    【解决方案1】:

    所以经过研究并没有太多帮助,我通过反复试验找到了答案。

    在 setexpresscheckout 脚本中,我必须围绕支付数组区域进行 foreach 循环。

    然后,该区域将具有收件人电子邮件/贝宝 ID、货币、金额和唯一的付款请求 ID。

    然后我在这个循环中围绕物品运行另一个循环并生成从该卖家购买的物品列表。

    然后,我将这一切设置到一个数组中,该数组按照通常发送给单个卖家的方式发送。

    这是我的代码,但显然这是我的任务所特有的。

    // setup the holding array for all the details
    $Payments = array();
    foreach ($seller as $key => $value) {
            // reset the items array for each recipient
            $PaymentOrderItems = array();
            // setup each recipient details
            $Payment = array(
                'currencycode'          => 'GBP',
                'amt'                   => $value['amount'],
                'sellerpaypalaccountid' => $value['paypal'],    
                'paymentrequestid'      => 'Payment'.$key
            );
    
            // loop through the products for each seller
            foreach ($value['artwork'] as $akey) {
                $Item = array(
                    'number'    => $akey['data_id'],
                    'desc'      => $akey['name'],
                    'qty'       => $akey['qty'],
                    'amt'       => round($akey['price'],2)
                );
                // push this item into the item array for this recipient
                array_push($PaymentOrderItems, $Item);
            }
    
            // add the item array to the payment array
            $Payment['order_items'] = $PaymentOrderItems;
    
            // push the payment array to the main payments array
            array_push($Payments, $Payment);
        }
    

    我希望这可以帮助那些想使用快速结帐而不是自适应付款的人。

    【讨论】:

      猜你喜欢
      • 2016-09-01
      • 1970-01-01
      • 2014-11-22
      • 2014-08-21
      • 2017-01-04
      • 2015-11-11
      • 2017-06-10
      • 1970-01-01
      • 2012-09-30
      相关资源
      最近更新 更多