PayPal payment integration in php codeigniter

SKGupta
Contributor
Contributor

Hi guys,
I am integrating paypal in my site for first time an I am having difficulty in integration. I am using php codeigniter for development. In my site there is a feature in which seller can add there paypal emailID and buyer have to pay their respective account. For now this is what I have done for the payment:

controller index method:


class makeOnlinePayment extends CI_Controller
{
public function __construct()
{
parent::__construct();
if (!$this->session->userdata('studentLoggedIn')) {
redirect('teacher/login');
}
$this->load->model('student_paypal_model');
}

public function index()
{

$data['css'] = $this->layout->includeCSSStudent();
$data['js'] = $this->layout->includeJSStudent(array('js/payment'));


$data['header'] = $this->load->view(VIEW_FOLDER . '/templates/headerInStudent', $data, TRUE);
$data['footer'] = $this->load->view(VIEW_FOLDER . '/templates/footerInStudent', $data, TRUE);

$teacherID = $this->session->userdata('studentDetails')->teacher;
$studentID = $this->session->userdata('studentDetails')->id;

//start paypal data
$paypalConfig = $this->student_paypal_model->getPaypalConfig($teacherID)[0];
$data['paypalUrl'] = $paypalConfig->paypalUrl;
$data['paypalId'] = $paypalConfig->paypalId;
// delete these hardcoded url before make it live
$data['paypalCancelUrl'] = base_url() . 'makeOnlinePayment';
$data['paypalSuccessUrl'] = base_url() . 'makeOnlinePayment/success';
$data['paypalCurCode'] = $paypalConfig->paypalCurCode;

$this->load->view(VIEW_FOLDER . '/makeOnlinePayment', $data);

}

public function success()
{
if($_GET['success'])
echo "Successfully paid!";exit();
}else{
die();
}
}
}

 

 

Now View Page:


<div class="section-btn-grp hide" id="paymentPaypal">
<form action="<?php echo $paypalUrl; ?>" method="post">

<!-- Identify your business so that you can collect the payments. -->
<input type="hidden" name="business" value="<?php echo $paypalId; ?>">

<!-- Specify a Buy Now button. -->
<input type="hidden" name="cmd" value="_xclick">

<!-- Specify details about the item that buyers will purchase. -->
<input type="hidden" name="item_name"
value="<?php echo 'Fee: ' . $amountPayable >= 0 ? number_format($amountPayable, 0) : 0; ?>">

<div class="row">
<div class="col-md-12">
<div class="form-group">
<label>Amount <span class="mandatory">$*</span> : <span class="error"
id="useraddress_error"> &nbsp; </span></label>
<input type="number" name="amount"
value="<?php echo $amountPayable >= 0 ? number_format($amountPayable, 0) : 0; ?>">
</div>
</div>
</div>

<input type="hidden" name="currency_code" value="<?php echo $paypalCurCode; ?>">

<!-- Specify URLs -->
<input type='hidden' name='cancel_return' value='<?php echo $paypalCancelUrl; ?>'>
<input type='hidden' name='return' value='<?php echo $paypalSuccessUrl; ?>'>

<!-- Display the payment button. -->
<input class="btn btn-primary" type="submit" name="submit" value="Pay">
</form>

 

</div>

 

Now I am wondering how I should give seller and buyer information and also why I am not able to make payment. Every time I login to paypal account it's saying "Return to Sonu Sonu's Test Store At this time, we are unable to process your request. Please return to Sonu Sonu's Test Store and try another option." can any one help me out?


Thanks

Login to Me Too
0 REPLIES 0

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.