Skip to content
Snippets Groups Projects
Commit 09481296 authored by drastik's avatar drastik
Browse files

* Switch to !empty instead of isset for the email checks and stripe_token check at the end.

* Handle proper stashing of token for "Go Back" action on Contrib and Event forms.
parent 39daca19
No related branches found
No related tags found
No related merge requests found
......@@ -249,13 +249,13 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
*/
// Check for existing customer, create new otherwise.
if (isset($params['email'])) {
if (!empty($params['email'])) {
$email = $params['email'];
}
elseif (isset($params['email-5'])) {
elseif (!empty($params['email-5'])) {
$email = $params['email-5'];
}
elseif (isset($params['email-Primary'])) {
elseif (!empty($params['email-Primary'])) {
$email = $params['email-Primary'];
}
// Prepare escaped query params.
......@@ -268,7 +268,7 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
WHERE email = %1", $query_params);
// Use Stripe.js instead of raw card details.
if (isset($params['stripe_token'])) {
if (!empty($params['stripe_token'])) {
$card_details = $params['stripe_token'];
}
else {
......
......@@ -117,15 +117,24 @@ function stripe_civicrm_upgrade($op, CRM_Queue_Queue $queue = NULL) {
function stripe_civicrm_buildForm($formName, &$form) {
if (isset($form->_paymentProcessor['payment_processor_type']) && $form->_paymentProcessor['payment_processor_type'] == 'Stripe') {
if (!stristr($formName, '_Confirm') && !stristr($formName, '_ThankYou')) {
// This is the 'Main', or first step of the form that collects CC data.
if (!isset($form->_elementIndex['stripe_token'])) {
$form->_attributes['class'] .= " stripe-payment-form";
$form->addElement('hidden', 'stripe_token', NULL, array('id' => 'stripe-token'));
stripe_add_stripe_js($form);
}
}
elseif (!empty($form->_params['stripe_token']) && !isset($form->_elementIndex['stripe_token'])) {
// Stash the token (including its value) in Confirm, in case they go backwards.
$form->addElement('hidden', 'stripe_token', $form->_params['stripe_token'], array('id' => 'stripe-token'));
else {
// This is a Confirm or Thank You (completed) form.
$params = $form->get('params');
// Contrib forms store this in $params, Event forms in $params[0].
if (!empty($params[0]['stripe_token'])) {
$params = $params[0];
}
if (!empty($params['stripe_token'])) {
// Stash the token (including its value) in Confirm, in case they go backwards.
$form->addElement('hidden', 'stripe_token', $params['stripe_token'], array('id' => 'stripe-token'));
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment