Open gvanhoy opened 4 years ago
Additional information: By flushing the cache and deleting all transients, this error does not occur for at least one form submission.
on line 608 of class-order-processor.php $transdata['stripe']->balance_transaction is accessed.
But nowhere else in the code is the value of $transdata['stripe'] set to a thing... What is going on with this variable?
We found an older version of cf-stripe 1.4.7 on a client's server so looked at its code.
They have updated cf-stripe, so it no longer stores its data in $transdata. Here's an example of old version (1.4.7 can work with cf-civicrm) and new version (1.4.11, utterly broken with cf-civicrm)
1.4.7: cf_stripe_process_token assigns $transdata: $transdata['stripe'] = $charge; 1.4.11: No assignment of anything to $transdata['stripe']
/**
* Returns the Stripe payment data if successful
*
* @since 1.0.0
*
*
* @param array $config processors config array
* @param array $form forms full config array
*
* @return array transaction data
*/
function cf_stripe_return_charge( $config, $form ){
global $transdata;
if( !empty( $transdata['stripe'] ) ){
// is a recurring
if( $config['type'] == 'plan' ){
$return_charge = array(
'ID' => $transdata['stripe']->id,
'live' => ( $transdata['stripe']->livemode ? 'Yes' : 'No' ),
'Plan' => $transdata['stripe']->subscriptions->data[0]->plan->name,
'Amount' => $transdata['stripe']->subscriptions->data[0]->plan->amount / 100,
'Currency' => $transdata['stripe']->subscriptions->data[0]->plan->currency,
'Interval' => $transdata['stripe']->subscriptions->data[0]->plan->interval,
'Count' => $transdata['stripe']->subscriptions->data[0]->plan->interval_count,
'Trial_Days'=> $transdata['stripe']->subscriptions->data[0]->plan->trial_period_days,
'Created' => date( 'r', $transdata['stripe']->subscriptions->data[0]->plan->created ),
'subscription_id' => $transdata['stripe']->subscriptions->data[0]->id,
);
}else{
$return_charge = array(
'ID' => $transdata['stripe']->id,
'live' => ( $transdata['stripe']->livemode ? 'Yes' : 'No' ),
'Amount' => $transdata['stripe']->amount / 100,
'Currency' => $transdata['stripe']->currency,
'Created' => date( 'r', $transdata['stripe']->created ),
);
}
/**
* Runs after a successful charge is made.
*
* Note: Use $return_charge[ 'ID' ] for the customer ID.
* Note: For recurring charges, use $return_charge[ 'subscription_id' ] for subscription plan ID.
*
* @since 1.4.0
*
* @param array $return_charge Data about the successful charge, returned from stripe.
* @param array $transdata Data used to create transaction.
* @param array $config The processor's configuration.
* @param array $form The current form.
*/
do_action( 'cf_stripe_post_successful_charge', $return_charge, $transdata, $config, $form );
return $return_charge;
}
}
Version: 1.4.11 file cf-stripe/includes/functions.php - Lines 817-829
/**
* Returns the Stripe payment data if successful
*
* @since 1.0.0 @updated 1.4.8
*
*
* @param array $config processors config array
* @param array $form forms full config array
*
* @return array transaction data
*/
function cf_stripe_return_charge($config, $form)
{
global $transdata;
if (cf_stripe_processor_config($form['ID']) && !empty($_GET['cf_entry_id'])) {
//Retrieve submission data set before checkout
$processed_data = Caldera_Forms_transient::get_transient('cf_stripe_' . $_GET['cf_entry_id']);
$config = cf_stripe_processor_config($form['ID']);
// Set your secret key: remember to change this to your live secret key in production
// See your keys here https://dashboard.stripe.com/account
\Stripe\Stripe::setApiKey($config['secret']);
//Retrieve Stripe session
$session = \Stripe\Checkout\Session::retrieve($processed_data['session_id']);
if (!empty($processed_data)) {
// is a recurring
if ($config['type'] == 'plan' && !empty($session->subscription)) {
$subscription = \Stripe\Subscription::retrieve($session->subscription);
if (!empty($subscription)) {
$return_charge = array(
'ID' => $session->subscription,
'live' => ($subscription->livemode ? 'Yes' : 'No'),
'Plan' => $subscription->plan->nickname,
'Amount' => $subscription->plan->amount / 100,
'Currency' => $subscription->plan->currency,
'Interval' => $subscription->plan->interval,
'Count' => $subscription->plan->interval_count,
'Trial_Days' => $subscription->plan->trial_period_days,
'Created' => date('r', $subscription->plan->created),
'subscription_id' => $subscription->id,
);
}
} else if ($config['type'] == 'single' && !empty($session->payment_intent)) {
$payment_intent = \Stripe\PaymentIntent::retrieve($session->payment_intent);
if (!empty($payment_intent)) {
$return_charge = array(
'ID' => $session->payment_intent,
'live' => ($payment_intent->livemode ? 'Yes' : 'No'),
'Amount' => $payment_intent->amount / 100,
'Currency' => $payment_intent->currency,
'Created' => date('r', $payment_intent->created),
);
}
}
}
}
if (!empty($return_charge)) {
/**
* Runs after a successful charge is made.
*
* Note: Use $return_charge[ 'ID' ] for the customer ID.
* Note: For recurring charges, use $return_charge[ 'subscription_id' ] for subscription plan ID.
*
* @since 1.4.0
*
* @param array $return_charge Data about the successful charge, returned from stripe.
* @param array $transdata Data used to create transaction.
* @param array $config The processor's configuration.
* @param array $form The current form.
*/
do_action('cf_stripe_post_successful_charge', $return_charge, $transdata, $config, $form);
return $return_charge;
}
}
Stripe\BalanceTransaction::retrieve(NULL)
This line of the output shows that there's no Stripe data in $transdata['stripe']
Is there another branch of the repo that handles this plugin? Not really clear from the Readme if cf-stripe 1.4.9+ is not supported.
Describe the bug Using Stripe Payment Processor on any form yields an error after submitting payment.
Other Information The payment successfully goes through, but redirecting back to the form causes a critical error on the site. I am not redirecting using a processor. I only have a stripe payment processor. The only reason I am posting here is because disabling this plugin allows payments to successfully redirect back to pages.
To Reproduce Steps to reproduce the behavior:
Expected behavior I expect to be redirected back to the form page after successful payment.
Errors
Full Stack-Trace
Software Versions WordPress Version: 5.4.2 PHP Version: 7.3.19 MySQL Version: 5.5.5 Server Software: nginx/1.17.6 Your User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36 Session Save Path: Session Save Path Exists: No Session Save Path Writeable: No Session Max Lifetime: 1440 Opcode Cache: Apc: No Memcached: No Redis: No Object Cache: Apc: No Apcu: No Memcache: No Memcached: No Redis: No WPDB Prefix: wp_
WP Multisite Mode: No WP Memory Limit: 40M Currently Active Theme: Divi: 4.5.1
Plugins: Caldera Forms: 1.9.1 Active Caldera Forms Stripe: 1.4.11 Active Caldera Forms Style Customizer (CFSC) for Divi & Extra: 1.0.3 Active Caldera Forms Users: 1.3.10 Active CalderaWP License Manager: 1.2.10 Active CF CiviCRM: 1.0.5 Active CiviCRM: 5.27.0 Active Mail Templates For Caldera Forms: 1.0.4 Active Really Simple SSL: 3.3.4 Active WP Mail SMTP: 2.2.1 Active WP Rollback: 1.7.0 Active