Payment Helper Functions
The helper you can use for payment transactions. And get, delete, update payment details.
Filter name: before_add_payment
Description: This filter would be executed before add payment into the database in add_payment helper.
Usage:
// The filter callback function is based on the filter.
add_filter( ‘before_add_payment’, ‘before_add_payment_callback_fun’, 10, 1 );
function before_add_payment_callback_fun($payment) {
// code
}
Filter name: should_add_payment
Description: This filter would be executed before add payment into database in add_payment helper.
Usage:
// The filter callback function is based on the filter.
add_filter( ‘should_add_payment’, ‘should_add_payment_callback_fun’, 10, 1 );
function should_add_payment_callback_fun($payment) {
// code
}
hook name: pre.add.payment
Description: This hook would be executed before add payment into the database in add_payment helper.
Usage:
// The filter callback function is based on the filter.
add_action('pre.add.payment', 'pre_add_payment_callback_fun', 10, 1);
function pre_add_payment_callback_fun($payment) {
// code
}
hook name: post.add.payment
Description: This hook would be executed after add payment into the database in add_payment helper.
Usage:
// The filter callback function is based on the filter.
add_action('post.add.payment', 'post_add_payment_callback_fun', 10, 1);
function post_add_payment_callback_fun($payment) {
// code
}
Usage
// for use payment helper you need to add this helper on controller or
// you can autoload this helper.
$this->load->helper('includes/payment');
// add a new payment in payment table.
$payment_id = add_payment($payment);
Request Parameters
Parameters in array format includes following attributes:
Param | Type | Required | Default | Description |
---|---|---|---|---|
description | Character | | Null | The description of a specific payment. |
booking_id | Integer | Yes | 0 | The booking_id for a specific payment. |
amount | Decimal Integer | Yes | 0 | The amount for a specific payment. |
is_captured | Integer | | 0 | The is_captured for a specific charge. |
selling_date | Date | Yes | Date | The selling_date for specific payment ( must provide date in gmdate() format). |
user_id | Integer | Yes | Null | The user_id for a specific payment. |
customer_id | Integer | | 0 | The customer_id for a specific payment. |
parent_charge_id | Integer | | Null | The parent_charge_id for specific payment. |
company_id | Integer | Yes | 0 | The company_id for specific payment. |
payment_type_id | Integer | | 0 | The payment_type_id for a specific payment. |
gateway_charge_id | Character | Yes | Null | The gateway charge_id for a specific payment. |
payment_gateway_used | Character | Yes | Null | The payment gateway is used for a specific payment. |
selected_gateway | Character | Yes | Null | The selected_gateway for a specific payment. |
cvc | Integer | Yes | Null | The CVC of the user for a specific payment. |
folio_id | Integer | | 0 | The folio_id for a specific payment. |
Response
Response includes the following attributes:
if data have been added successfully it would return the key of specific payment id.
return $payment_id;
if data does not add it will return null.
Filter name: before_get_payment
Description: This filter would be executed before retrieving payment details from database in get_payment helper.
Usage:
// The filter callback function is based on the filter.
add_filter( ‘before_get_payment’, ‘before_get_payment_callback_fun’, 10, 1 );
function before_get_payment_callback_fun($payment_id) {
// code
}
Filter name: should_get_payment
Description: This filter would be executed before retrieving payment details from database in get_payment helper.
Usage:
// The filter callback function is based on the filter.
add_filter( ‘should_get_payment’, ‘should_get_payment_callback_fun’, 10, 1 );
function should_get_payment_callback_fun($payment_id) {
// code
}
hook name: pre.get.payment
Description: This hook would be executed before retrieving payment details from database in get_payment helper.
Usage:
// The filter callback function is based on the filter.
add_action('pre.get.payment', 'pre_get_payment_callback_fun', 10, 1);
function pre_get_payment_callback_fun($payment_id) {
// code
}
hook name: post.get.payment
Description: This hook would be executed after retrieving payment details from database in get_payment helper.
Usage:
// The filter callback function is based on the filter.
add_action('post.get.payment', 'post_get_payment_callback_fun', 10, 1);
function post_get_payment_callback_fun($payment_id) {
// code
}
Usage
// Retrieves payment data based on a payment_id.
$payment_data = get_payment($payment_id);
Request Parameters
Param | Type | Required | Default | Description |
---|---|---|---|---|
$payment_id | Integer | Yes | Null | The primary id of the payment corresponds to the payment table |
Response
// $response array includes following attributes:
// $response['user_id'] : the user_id of specific payment.
// $response['booking_id'] : the booking_id for specific payment .
// $response['selling_date'] : the selling_date for specific payment.
// $response['company_id'] : the company_id for specific payment.
// $response['amount'] : the amount for specific payment.
// $response['customer_id'] : the customer_id for specific payment.
// $response['payment_type_id'] : the payment_type_id for specific payment.
// $response['description'] : the description for specific payment.
// $response['selected_gateway'] : the selected_gateway for specific payment.
// $response['capture_payment_type'] : the capture_payment_type for specific payment.
// and many more attributes for table payment.
// Successfully response giving you array of payment data.
Array
(
[payment_id] => 1
[description] => payment
[date_time] => 2022-01-26 17:19:53
[booking_id] => 1
[amount] => 100.00
[payment_type_id] => 1
[credit_card_id] => 1
[selling_date] =>
[is_deleted] => 0
[user_id] => 1
[customer_id] => 1
[payment_gateway_used] =>
[gateway_charge_id] =>
[read_only] =>
[payment_status] => charge
[parent_charge_id] =>
[is_captured] => 0
[logs] =>
[payment_link_id] =>
)
// if there is no payment data for any payment id provided in input or any error will return null.
Usage
// update payment data based on payment update data and payment_id.
update_payment($payment, $payment_id);
Supported hooks
Filter name: before_update_payment
Description: This filter would be executed before update payment into the database in update_payment helper.
Usage:
// The filter callback function is based on the filter.
add_filter( ‘before_update_payment’, ‘before_update_payment_callback_fun’, 10, 1 );