Print

Using a Filter Hook

For developers looking to trigger a Stripe Checkout session programmatically, the plugin provides the {mswr-initiate-stripe-payment} filter hook. This method offers maximum flexibility, allowing you to initiate payments from within your theme or plugin code.

How It Works

  • Trigger the Action – Call apply_filters( 'mswr-initiate-stripe-payment', $args ); where $args is an associative array of parameters.
  • The filter returns a WP_Error object if any errors occurred.
  • Modify Parameters (Optional) – The {mswr-pre-stripe-checkout} filter will be triggered, providing an additional opportunity to modify parameters before passing them to Stripe.

 

Example Usage

$args = array(

'amount' => 5000, // Amount in cents (e.g., 5000 = $50.00)

'currency' => 'NZD',

'product' => 'Membership Payment',

'success_url' => site_url('/payment-success'),

'cancel_url' => site_url('/payment-cancel'),

$result=apply_filters( 'mswr-initiate-stripe-payment', $args );

Parameters

The parameters available for this method are the same as those outlined in the Technical Reference section.

Page Navigation