PayPal Checkout Pages Automatically using In CI-Merchant

231 Views Asked by At

I am trying to integrate Paypal payment gateway in my website. I used codeigniter ci-merchant library. But i an not able to filled billing details in PayPal Checkout Pages Automatically. I passed all the details like below:

       $params = array(
          'amount' => 1,
          'item' => 'myitem',
          'description' => 'Your_item_description',
          'currency' => $this->config->item('currency'),
          'return_url' => base_url() . 'payment/payment_return',
          'cancel_url' => base_url() . 'payment/cancel',
          'first_name' => 'myname',
          'last_name' => 'mynamelast',
          'address1' => 'btm',
          'address2' => 'bangare',
          'city' => 'bangalore',
          'state' => 'karnataka',
          'zip' => '460078'
    ); 

Is this the correct way? Please help.

1

There are 1 best solutions below

0
On

Yes the correct way is below

$this->load->library('merchant');
$this->merchant->load('paypal_express');

and then use default setting

$settings = $this->merchant->default_settings();

$params = array(
    'amount' => 100.00,
    'currency' => 'USD',
    'return_url' => 'https://www.example.com/checkout/payment_return/123',
    'cancel_url' => 'https://www.example.com/checkout');

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

This will create a payment request with PayPal, and immediately redirect the customer away from your site. When the customer has completed their payment, they will be sent to the return URL you specified. Some payment gateways accept credit cards directly on your site (on-site gateways), and you will receive a $response immediately without the customer being redirected.

so then print_r($response) ; die() ; and check response.

for details http://ci-merchant.org/

Handling the response

The $response object returned from either the purchase() or purchase_return() method will be an instance of the Merchant_response class. The response will have one of 5 statuses, representing the state the payment is in:

Merchant_response::AUTHORIZED
Merchant_response::COMPLETE
Merchant_response::FAILED
Merchant_response::REDIRECT
Merchant_response::REFUNDED

So here is full payment process of paypal express using Ci merchant

and if you want to use it with out redirect then use authorize.net or paypal pro.