Last active
February 13, 2017 20:27
-
-
Save Shelob9/65cf3d9f2c5e6aef31cd494b3edb276a to your computer and use it in GitHub Desktop.
Filters for Caldera Forms Authorize.net subscriptions (eCheck and Credit Card) -- REQUIRES version 2.1.0 or later -- https://calderaforms.com/downloads/authorize-net-for-caldera-forms/
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 | |
/** | |
* Change billing interval for Caldera Forms Authorize.net subscriptions | |
* | |
* @param \net\authorize\api\contract\v1\PaymentScheduleType\IntervalAType $type | |
* @param Caldera_Forms_Processor_Get_Data $data_object | |
* @param array $form | |
*/ | |
add_filter( 'cf_auth_net_arb_interval', function( $interval, $data_object, $form ){ | |
$interval->setUnit( 'daily' ); | |
return $interval; | |
}, 10, 3 ); |
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 | |
/** | |
* Make Caldera Forms Authorize.net subscription start one week later | |
* | |
* @param \net\authorize\api\contract\v1\PaymentScheduleType $subscription | |
* @param Caldera_Forms_Processor_Get_Data $data_object | |
* @param array $form | |
*/ | |
add_filter( 'cf_auth_net_arb_payment_schedule', function( $paymentSchedule, $data_object, $form ){ | |
//Update for your form ID | |
if ( 'cf12332' === $form[ 'ID' ] ) { | |
//You must pass a valid DateTime object! | |
//See- http://php.net/manual/en/datetime.construct.php | |
$paymentSchedule->setStartDate( new DateTime( date( "Y-m-d", strtotime( "+1 week" ) ) ) ); | |
} | |
return $paymentSchedule; | |
}, 10, 3 ); | |
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 | |
/** | |
* Change the reference ID for a Caldera Forms subscription plan created with Authorize.net | |
*/ | |
add_filter( 'cf_auth_net_ref_id', function( $refId, $form ){ | |
//make sure to change field value | |
$field_id = 'fld_134'; | |
$value = Caldera_Forms::get_field_data( $field_id, $form ); | |
if( ! empty( $value ) ){ | |
$refId = $value; | |
} | |
return $refId; | |
}, 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment