|
/ Documentation /Integrations/ How to Add the Custom Support of any Payment Gateway for One-Click Upsell & Downsell in the CartFlows?

How to Add the Custom Support of any Payment Gateway for One-Click Upsell & Downsell in the CartFlows?

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.
                'path'  => 'FullDirectoryPathofTheFile', // Full directory path of the custom code's file.
	);

	return $supported_gateways; // Adding the payment gateway name.
}

Note: The path variable should only be used if you want to add custom support for the gateway from your theme or plugin. If you are adding your custom code file in the CartFlows Pro directory then follow Step 3.

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.

Note: We have a sample plugin for your reference to add a custom integration of payment gateways of your choice, you can download the sample plugin from Here.

Was this doc helpful?
What went wrong?

We don't respond to the article feedback, we use it to improve our support content.

Need help? Contact Support
On this page
Download is Just A Click Away!

Enter your email address and be the first to learn about updates and new features.

Free Cartflows Form - Popup

Download is Just A Click Away!

Enter your email address and be the first to learn about updates and new features.