Last active
June 30, 2020 10:50
-
-
Save ebinmanuval/78345995f0e93cf3ee00a1a34889a205 to your computer and use it in GitHub Desktop.
razor pay by link
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
protected function pay_by_link($data) | |
{ | |
$api = new \Razorpay\Api\Api( | |
$this->getSetting('api_publishable_key'), | |
$this->decryptSetting('api_secret_key') | |
); | |
$invoice = ($data['invoice']); | |
$amount = $data['amount'] * 100; | |
$link_array = array( | |
'type' => 'link', | |
'amount' => $amount, | |
'currency' => $invoice->currency_name, | |
'description' => 'For XYZ purpose', | |
'customer' => array(), | |
'callback_url' => site_url('haatch/payment_capture'), //http://localhost/dash/haatch/payment_capture | |
'callback_method' => 'get', | |
); | |
if (is_client_logged_in()) { | |
$contact = $this->ci->clients_model->get_contact(get_contact_user_id()); | |
$link_array['customer']['name'] = $contact->firstname . ' ' . $contact->lastname; | |
} else { | |
if (total_rows(db_prefix() . 'contacts', ['userid' => $invoice->clientid]) == 1) { | |
$contact = $this->ci->clients_model->get_contact(get_primary_contact_user_id($invoice->clientid)); | |
if ($contact) { | |
$link_array['customer']['name'] = $contact->firstname . ' ' . $contact->lastname; | |
} | |
} | |
} | |
if (isset($contact)) { | |
$link_array['customer']['email'] = $contact->email; | |
} | |
$link = $api->invoice->create($link_array); | |
//var_dump($link); | |
//var_dump($link_array); | |
//exit; | |
$this->store_payment($invoice, $link); | |
redirect($link->short_url); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment