简体   繁体   中英

Use Angelleye Paypal Express Checkout Class for Parallel Payments

I am using the Angelleye Paypal class to setup express checkout. Using the demo I can accept a payment to myself for multiple items. I have a site that advertises on behalf of people and the shopping cart is built and breaks the values into an array per seller.

How do i use the SetExpressCheckout.php to create the array for the receivers.

This is a demo of the array i have from the cart

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
    )

)

So baiscally mandy has sold 2 items:

id: 1034 name: Pink Foxgloves qty: 1 subtotal : 260.00

id: 1038 name : Big red poppies qty: 1 subtotal : 288.00

And John has sold

id: 1052 name : Success qty:1 subtotal : 46.75

I also have the total of :594.75

If i can get the receivers in the express checkout it would be good and if i can also get their items as well this would be excellent.

Thanks in Advance.

So after research and not much help anywhere i found the answer through trial and error.

In the setexpresscheckout script i had to do a foreach loop around the payment array area.

This area will then have the recipent email/paypal id the currency the amount and a unique payment request id.

within this loop i then run another loop around the items and generate a list of items purchased from that seller.

I then set this all into an array which is sent through as normally it would be for a single seller.

Heres my code but obviously this is quite specific to my task.

// 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);
    }

I hope this helps anyone else that is stuck with this class that wants to use express checkout instead of adaptive payments.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM