In this article, we will see the step-by-step guide to add your Custom Support for your Payment Gateway in the CartFlows for the Upsell & Downsell.
To add the custom support of your Payment Gateway below are the few simple steps to follow –
Step 1: Adding the Class & file name in the CartFlows gateway’s library.
In this step, you need to decide the file name and the Class name which you want to use in the Custom Support for your Payment Gateway. After deciding the name of the file & class you need to add those names in the CartFlows Gateway library.
To add it navigate to the CartFlows Pro’s directory then into Classes folder and open a class-cartflows-pro-gateways.php file.
Now, find the function named as “get_supported_gateways” and add your class & files name in the already provided array. OR you can use the following filter to add your class & file name without touching the CartFlows Code.
add_filter( 'cartflows_offer_supported_payment_gateways', 'your_function_name' );
/**
* Add new payment gateway in Supported Gateways.
*
* @param array $supported_gateways Supported Gateways by CartFlows.
* @return array.
*/
function your_function_name( $supported_gateways ){
$supported_gateways['payment_gateway_slug'] = array(
'file' => 'yourfilename.php', // Your Custom code's file name
'class' => 'YourClassName', // Class name used in the Custom Code's file.
);
return $supported_gateways; // Adding the payment gateway name.
}
Step 2: What to write in the custom code’s file
Create a function named as “process_offer_payment”. This function will be called automatically by the CartFlows in order to process the charge for Upsell & Downsell if they are accepted by the user.
So, all your business logic should be added in this function.
Step 3: Add your custom code’s file at the right place
To add the custom code’s file where you have written the code to add the support for Upsell & Downsell. So navigate to the cartflows-pro/modules/gateways directory and place your file.
For the reference on what is written in the “process_offer_payment” function you can take a look at the other payment gateway files that are currently available in the cartflows-pro/modules/gateways directory.
In this way you can add your payment gateway’s Custom Support in the CartFlows so that you can add the support for Upsell & Downsell.