Created
December 16, 2019 13:32
-
-
Save New0/cabd1c334410150a129cb1b9ad5aabeb to your computer and use it in GitHub Desktop.
Filter examples for Caldera Forms Stripe https://calderaforms.com/downloads/caldera-forms-stripe-add-on/ https://calderaforms.com/doc/controlling-stripe-charge-data/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//this applies change when creating plans | |
add_filter( 'cf_stripe_recurring_args', 'my_cf_stripe_recurring_filter', 10, 2 ); | |
//this applies change when creating one time payments | |
add_filter( 'cf_stripe_charge_args', 'my_cf_stripe_single_filter', 10, 2 ); | |
//this is the callback to change arguments sent to API | |
//Be careful not to set a field that isn't supported or the API will reject the charge. | |
//Description for single payments | |
function my_cf_stripe_single_filter( $args, $form ){ | |
/* Change this to the right field ID */ | |
$field_id = 'fld_13345'; | |
$args['line_items'][0][ 'description' ] = Caldera_Forms::get_field_data( $field_id, $form ); | |
return $args; | |
} | |
//Description for plans | |
function my_cf_stripe_recurring_filter( $args, $form ){ | |
/* Change this to the right field ID */ | |
$field_id = 'fld_13345'; | |
$args['subscription_data']['metadata'][ 'description' ] = Caldera_Forms::get_field_data( $field_id, $form ); | |
return $args; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment