|
/ Documentation /CartFlows/Integrations/ How to Add Custom Payment Gateway Support for One-Click Upsell and Downsell in CartFlows

How to Add Custom Payment Gateway Support for One-Click Upsell and Downsell in CartFlows

You can integrate your own payment gateway with CartFlows to support one-click Upsell and Downsell functionality. This requires a few steps to register your gateway and handle the payment process through code.

Follow the steps below to add custom support:

Step 1: Register Your Payment Gateway

You’ll need to define a custom class and file name, then register them with CartFlows.

To do this, either:

Option A: Manually add them inside the CartFlows Pro plugin

  • Go to the cartflows-pro/classes/class-cartflows-pro-gateways.php file
  • Find the get_supported_gateways function
  • Add your class and file to the returned array

Option B: Use the available filter (recommended if adding support via a plugin or theme):

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: Use the path only if your file is located outside the CartFlows Pro plugin directory.

Step 2: Write the Payment Processing Function

Inside your custom file, create a function named process_offer_payment. CartFlows will call this automatically when processing the Upsell or Downsell.

This is where your payment logic goes. It should handle charging the customer after the main checkout is completed and the offer is accepted.

Step 3: Place the Custom File in the Correct Directory

If you’re not using a custom path, place your file in:

cartflows-pro/modules/gateways/

You can refer to existing gateway files in that directory to understand how to structure your implementation.

Note: We also offer a sample plugin you can use as a reference when building your own custom gateway integration. Download Sample Plugin

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