Callback
This is the step that allows the invoice's status to be processed as "paid" upon notification by the payment service provider that the payment has been completed.
Here are the cases where you should use the function:
- Forwarding the status of the payment to the "callback" link if using the "Third Party" method.
- Forwarding the status of the payment to the "callback" link after the 3D verification stage.
- Forwarding the status of payment for IPN messages to the "callback" connection.
If the purpose of the function is to approve the payment, first of all, the "checkout" variable should be defined as stated in the sample codes.
"get_checkout" Function
Two parameters are entered into the function.
The first parameter is the "checkout ID" number. The second parameter means the payment status of the "checkout" item is "unpaid" or "paid".
If you leave the second parameter blank, it will return the "checkout" item regardless. (This may cause duplicate invoices/services when duplicate requests are received. It is recommended to use the blank only when the payment is in the "approval" process.)
"set_checkout" Function
You can define a parameter to the function. The value you define should be the value returned from the "get_checkout" function.
Return Value
The return value of the function must be "array". Array keys and values are described below:
Name | Type | Mandatory | Explanation |
status | string | Yes | The status of the payment may include the following: --- successful : Indicates that the payment was successful. pending: Indicates that payment is pending. error: Indicates that the payment was unsuccessful. |
message | string or array | No | Used when you need to inform the admin about the payment. (Eg: The number related to the tracking of the payment) Acceptable value: "array" and "string" |
callback_message | string | No | If it is defined, the value you entered will appear in front of the client. If it is not defined, the client will be directed to the "successful" or "failed" page, depending on the status of the payment. |
paid | Array | No | Info of the fee paid [amount] [currency] |
paid [amount] | Float | Yes | Amount of fee paid |
paid[currency] | String | Yes | Currency of the amount paid, eg: "USD,EUR,GBP,TRY" |
Sample Usage
public function callback()
{
$custom_id = (int) Filter::init("POST/custom_id","numbers");
if(!$custom_id){
$this->error = 'ERROR: Custom id not found.';
return false;
}
$checkout = $this->get_checkout($custom_id);
// Checkout invalid error
if(!$checkout)
{
$this->error = 'Checkout ID unknown';
return false;
}
// You introduce checkout to the system
$this->set_checkout($checkout);
// You decide the status of the payment.
return [
/* You can define it as 'successful' or 'pending'.
* 'successful' : Write if the payment is complete.
* 'pending' : Write if the payment is pending confirmation.
*/
'status' => 'successful',
/*
* If there is anything you need to inform the manager about the payment, please fill it out.
* Acceptable value : 'array' and 'string'
*/
'message' => [
'Merchant Transaction ID' => '[email protected]',
],
// Write if you want to show a message to the person on the callback page.
'callback_message' => 'Transaction Successful',
];
}