phpcodeigniterpayment-gatewayci-merchant

ci-merchant.org - Add custom data to paypal express transaction


Im using the ci-merchant library ci-merchant and it all works fine except that Im just passing the order total to paypal.

Is there a way to specify the shipping amount, and /or other custom attributes so when customers get referred to Paypal there is an itemized list so they know what they are paying for.

This is my existing code:

    $params = array(
            'amount' => 50.00,
            'currency' =>  'USD',
            'return_url' => 'mysite.com/return/' . $order_id,
            'notify_url' => 'mysite.com/notify/' . $order_id,
            );


    $response  = $this->merchant->purchase($params);

What I would like to do is something like:

    $params = array(
            'amount' => 40.00,
            'shipping' => 10.00,
            'currency' =>  'USD',
            'return_url' => 'mysite.com/return/' . $order_id,
            'notify_url' => 'mysite.com/notify/' . $order_id,
            );


    $response  = $this->merchant->purchase($params);

Solution

  • Modify a file into the library like specified here, and it allows you to pass an array of items with the classic data required when calling purchase() method.

    https://github.com/guillermofr/ci-merchant/commit/70ea1a2864971078b3b67e5ca1051be174f23fa0#commitcomment-3642787

    The array is formatted like this :

    $params = array(
            'amount' => 40.00,
            'currency' =>  'USD',
            'return_url' => 'mysite.com/return/' . $order_id,
            'notify_url' => 'mysite.com/notify/' . $order_id,
            'items' => array(
                array(  
                  'name'=>'',
                  'desc'=>'',
                  'amt'=>,
                  'qty'=>
               )
            )
     );
    

    But remember that ci-merchant is no longer supported. You better use Omnipay.