3

I am trying to integrate ci-merchant with codeigniter by using paypal express driver. I followed the steps as given in the document. I am able to get my site redirected to paypal sandbox payment site where the Total cost and everything is available. But when I try paying using paypal sandbox account by logging in, it does not show me the paypal balance even though I have enough in my account. When I click pay now, It redirects me to the return url successfully with token and payer ID in the url. But no fund is getting transferred.Not sure where I am going wrong.

url : ../retSuccess?token=EC-01M80248BN787213M&PayerID=9WLBBV9LM6TPA

    $this->load->model('mainmodel');
    $this->mainmodel->orderDetails();

    $query = $this->mainmodel->retrieveOrder();

    foreach ($query as $row){
        $transaction_id = $row['transaction_id'];
    }    
          $this->load->library('merchant');
    $this->merchant->load('paypal_express');

    $settings = array(
            'username' => 'merchant_api1.canada.com',
            'password' => '1369782104',
            'signature' =>'AmTaSH3lkRIYxxjxUjB.1zqxD0cRA1hfMGBX2dV9h4DkcYQcjGtqDaYa',
            'test_mode' => true);

    $this->merchant->initialize($settings);

    $params = array(
             'amount' => $this->input->post('price'),
             'currency' => 'CAD',
             'description'=> $this->input->post('model_no'),
             'return_url' => base_url('payment/transaction/'.$transaction_id),
             'cancel_url'=> base_url('payment/cancel'));

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

}

public function transaction(){

    $transaction_id = $this->uri->segment(3);

    $this->load->model('mainmodel');
    $query = $this->mainmodel->loadTransaction($transaction_id);

    foreach ($query as $row){
        $price = $row['price'];
        $desc = $row['model_no'];
        $trans_id = $row['transaction_id'];
    }

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

    $params = array(
            'amount' => '21.3',
            'currency' => 'CAD',
            'description' => 'SP66');

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


    if ($response->success())
    {
        $data['gateway_reference'] = $response->reference();
        $data['model_no'] = $this->session->userdata('model_no');
        $data['category'] = $this->session->userdata('category');
        $data['specs'] = $this->session->userdata('specs');
        $data['quantity'] = $this->session->userdata('quantity');

        $newData = array('status'=>'complete',
                'reference'=>$data['gateway_reference']);
        $this->db->where('transaction_id',$trans_id);
        $this->db->update('transactions',$newData);

        $this->load->view('templates/success',$data);

    }else{

        $data['message'] = $response->message();

        //$this->db->where('transaction_id',$trans_id);
        //$this->db->delete('transactions');

        $this->load->view('templates/failure',$data);

    }

}
Ram
  • 575
  • 2
  • 8
  • 18

3 Answers3

0

If I understand you correctly, the sandbox account should have a buy and seller account. You need to check the seller account to see the purchase from the buyer account.

I don't think the problem is from CI Merchant.

Shina
  • 2,019
  • 2
  • 19
  • 25
  • I have double checked on that. I do have a buyer and a seller account which are active and verified. Funds are getting transfered when I do it in paypal sandbox site but not when using this Ci-merchant. – Ram May 27 '13 at 23:26
  • Now this is my response. Merchant_response Object ( [_status:protected] => failed [_message:protected] => You do not have permissions to make this API call [_reference:protected] => [_data:protected] => [_redirect_url:protected] => [_redirect_method:protected] => GET [_redirect_message:protected] => [_redirect_data:protected] => ) Do you think this is a ci-merchant issue or a paypal issue? – Ram May 28 '13 at 22:43
0

Make sure that the CI Merchant is calling PayPal's DoExpressCheckout API. This is the last API call of the Express Checkout, and this is the API that actually completes the payment and transfers the money.

PP_MTS_Chad
  • 7,311
  • 1
  • 15
  • 20
  • Now I also have an error message getting displayed saying -'You do not have permissions to make this API call ' I guess this may be the reason for fund issue as well. How do I grant permission? – Ram May 28 '13 at 07:14
  • If you are trying to run this API call on your account, you should have permissions. If you are trying to run this on a different account using 3rd party permissions, you need to make sure the account that you are trying to process this on has granted you the correct permissions in their account. If you are still getting an error, can you provide the full API response you are getting back and I can look it up in the logs on my side to see what may be causing the error. – PP_MTS_Chad May 29 '13 at 11:46
  • I am trying to run this in my own sandbox account. I created 2 accounts a buyer and a seller account under my PayPal login. Then I added the seller API credentials to my code as shown above. Then in my webpage when I try to make purchase using my buyer account, I get this permission error. Do I need to grant some special permission? if so how? This is my seller account (merchant@ Canada.com Will u be able to check for the permissions? – Ram May 29 '13 at 14:10
  • I apologize in the delay in getting back to you, but I was out for a couple of weeks. Are you still having issues with this? I checked your account and I see payments going through. – PP_MTS_Chad Jun 11 '13 at 14:03
  • Sorry for the delay. Finally I had to change the API. No issues with the paypal account. For some reason the previous API did not work for me. Thanks for looking into this :) – Ram Oct 06 '13 at 17:35
0

With ci-merchant you need to call purchase_return on your return page to complete the payment, it looks like you just put everything on the initial (pre-paypal) page which won't do anything.

Adrian Macneil
  • 13,017
  • 5
  • 57
  • 70
  • Yes I modified my code. I have provided my current code. Actually the current code is based upon your idea. But Now the response I get is "You do not have permissions to make this API call ". I have checked all my API credentials, deleted and recreated seller account but no improvement. – Ram May 29 '13 at 00:24