Ram
Ram

Reputation: 595

Funds not getting transferred between paypal sandbox accounts

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

    }

}

Upvotes: 3

Views: 1651

Answers (3)

Adrian Macneil
Adrian Macneil

Reputation: 13263

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.

Upvotes: 0

PP_MTS_Chad
PP_MTS_Chad

Reputation: 7329

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.

Upvotes: 1

Shina
Shina

Reputation: 2064

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.

Upvotes: 0

Related Questions