Skip to content
Snippets Groups Projects
Commit 66e674c7 authored by mattwire's avatar mattwire
Browse files

Don't take payment twice on recurring payments.

parent 3cfe9fb3
No related branches found
No related tags found
No related merge requests found
......@@ -367,7 +367,12 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
*/
public function doPayment(&$params, $component = 'contribute') {
$params = $this->beginDoPayment($params);
$params = $this->getTokenParameter('paymentIntentID', $params);
if (CRM_Utils_Array::value('is_recur', $params) && $this->getRecurringContributionId($params)) {
$params = $this->getTokenParameter('paymentMethodID', $params, TRUE);
}
else {
$params = $this->getTokenParameter('paymentIntentID', $params, TRUE);
}
$pendingStatusId = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Pending');
......@@ -446,17 +451,30 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
$params['description'] = E::ts('Contribution: %1', [1 => $this->getPaymentProcessorLabel()]);
}
// Handle recurring payments in doRecurPayment().
if (CRM_Utils_Array::value('is_recur', $params) && $this->getRecurringContributionId($params)) {
// This is where we save the customer card
// @todo For a recurring payment we have to save the card. For a single payment we'd like to develop the
// save card functionality but should not save by default as the customer has not agreed.
$paymentMethod = \Stripe\PaymentMethod::retrieve($params['paymentMethodID']);
$paymentMethod->attach(['customer' => $stripeCustomer->id]);
$stripeCustomer = \Stripe\Customer::retrieve($stripeCustomer->id);
// We set payment status as pending because the IPN will set it as completed / failed
$params['payment_status_id'] = $pendingStatusId;
return $this->doRecurPayment($params, $amount, $stripeCustomer, $paymentMethod);
}
$contactContribution = $this->getContactId($params) . '-' . ($this->getContributionId($params) ?: 'XX');
$intentParams = [
'customer' => $stripeCustomer->id,
'description' => "{$params['description']} {$contactContribution} #" . CRM_Utils_Array::value('invoiceID', $params),
'statement_descriptor_suffix' => "{$contactContribution} " . substr($params['description'],0,7),
];
$intentParams['statement_descriptor_suffix'] = "{$contactContribution} " . substr($params['description'],0,7);
$intentParams['statement_descriptor'] = substr("{$contactContribution} " . $params['description'], 0, 22);
$intentMetadata = [
'amount_to_capture' => $this->getAmount($params),
];
// This is where we actually charge the customer
try {
\Stripe\PaymentIntent::update($params['paymentIntentID'], $intentParams);
......@@ -473,19 +491,6 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
$this->handleError($e->getCode(), $e->getMessage(), $params['stripe_error_url']);
}
// Handle recurring payments in doRecurPayment().
if (CRM_Utils_Array::value('is_recur', $params) && $params['contributionRecurID']) {
// This is where we save the customer card
// @todo For a recurring payment we have to save the card. For a single payment we'd like to develop the
// save card functionality but should not save by default as the customer has not agreed.
$paymentMethod = \Stripe\PaymentMethod::retrieve($intent->payment_method);
$paymentMethod->attach(['customer' => $stripeCustomer->id]);
// We set payment status as pending because the IPN will set it as completed / failed
$params['payment_status_id'] = $pendingStatusId;
return $this->doRecurPayment($params, $amount, $stripeCustomer, $paymentMethod);
}
// Return fees & net amount for Civi reporting.
$stripeCharge = $intent->charges->data[0];
try {
......@@ -549,7 +554,10 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
'prorate' => FALSE,
'plan' => $planId,
'default_payment_method' => $stripePaymentMethod,
'metadata' => ['Description' => $params['description']],
'expand' => ['latest_invoice.payment_intent'],
];
// Create the stripe subscription for the customer
$stripeSubscription = $stripeCustomer->subscriptions->create($subscriptionParams);
$this->setPaymentProcessorSubscriptionID($stripeSubscription->id);
......@@ -582,7 +590,7 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
// Set the orderID (trxn_id) to the invoice ID
// The IPN will change it to the charge_id
$this->setPaymentProcessorOrderID($stripeSubscription->latest_invoice);
$this->setPaymentProcessorOrderID($stripeSubscription->latest_invoice['id']);
return $this->endDoPayment($params);
}
......
......@@ -70,8 +70,7 @@ class CRM_Stripe_AJAX {
// Setup the card to be saved and used later
'confirm' => TRUE,
]);
}
catch (Exception $e) {
} catch (Exception $e) {
CRM_Utils_JSON::output(['error' => ['message' => $e->getMessage()]]);
}
}
......@@ -85,21 +84,24 @@ class CRM_Stripe_AJAX {
* @param \Stripe\PaymentIntent $intent
*/
private static function generatePaymentResponse($intent) {
if ($intent->status == 'requires_action' &&
$intent->next_action->type == 'use_stripe_sdk') {
if ($intent->status === 'requires_action' &&
$intent->next_action->type === 'use_stripe_sdk') {
// Tell the client to handle the action
CRM_Utils_JSON::output([
'requires_action' => true,
'payment_intent_client_secret' => $intent->client_secret,
]);
} else if (($intent->status == 'requires_capture') || ($intent->status == 'requires_confirmation')) {
}
elseif (($intent->status === 'requires_capture') || ($intent->status === 'requires_confirmation')) {
// paymentIntent = requires_capture / requires_confirmation
// The payment intent has been confirmed, we just need to capture the payment
// Handle post-payment fulfillment
CRM_Utils_JSON::output([
'success' => true,
'paymentIntent' => ['id' => $intent->id],
]);
} else {
}
else {
// Invalid status
CRM_Utils_JSON::output(['error' => ['message' => 'Invalid PaymentIntent status']]);
}
......
......@@ -39,14 +39,14 @@ CRM.$(function($) {
// On initial run we need to call this now.
window.civicrmStripeHandleReload();
function paymentIntentSuccessHandler(paymentIntent) {
debugging('paymentIntent confirmation success');
function successHandler(type, object) {
debugging(type + ': success - submitting form');
// Insert the token ID into the form so it gets submitted to the server
var hiddenInput = document.createElement('input');
hiddenInput.setAttribute('type', 'hidden');
hiddenInput.setAttribute('name', 'paymentIntentID');
hiddenInput.setAttribute('value', paymentIntent.id);
hiddenInput.setAttribute('name', type);
hiddenInput.setAttribute('value', object.id);
form.appendChild(hiddenInput);
// Submit the form
......@@ -74,18 +74,23 @@ CRM.$(function($) {
displayError(result);
}
else {
// Send paymentMethod.id to server
var url = CRM.url('civicrm/stripe/confirm-payment');
$.post(url, {
payment_method_id: result.paymentMethod.id,
amount: getTotalAmount(),
currency: CRM.vars.stripe.currency,
id: CRM.vars.stripe.id,
recur: getIsRecur(),
}).then(function (result) {
// Handle server response (see Step 3)
handleServerResponse(result);
});
if (getIsRecur() === true) {
// Submit the form, if we need to do 3dsecure etc. we do it at the end (thankyou page) once subscription etc has been created
successHandler('paymentMethodID', result.paymentMethod);
}
else {
// Send paymentMethod.id to server
var url = CRM.url('civicrm/stripe/confirm-payment');
$.post(url, {
payment_method_id: result.paymentMethod.id,
amount: getTotalAmount(),
currency: CRM.vars.stripe.currency,
id: CRM.vars.stripe.id,
}).then(function (result) {
// Handle server response (see Step 3)
handleServerResponse(result);
});
}
}
});
}
......@@ -100,23 +105,22 @@ CRM.$(function($) {
handleAction(result);
} else {
// All good, we can submit the form
paymentIntentSuccessHandler(result.paymentIntent);
successHandler('paymentIntentID', result.paymentIntent);
}
}
function handleAction(response) {
stripe.handleCardAction(
response.payment_intent_client_secret
).then(function(result) {
if (result.error) {
// Show error in payment form
displayError(result);
} else {
// The card action has been handled
// The PaymentIntent can be confirmed again on the server
paymentIntentSuccessHandler(result.paymentIntent);
}
});
stripe.handleCardAction(response.payment_intent_client_secret)
.then(function(result) {
if (result.error) {
// Show error in payment form
displayError(result);
} else {
// The card action has been handled
// The PaymentIntent can be confirmed again on the server
successHandler('paymentIntentID', result.paymentIntent);
}
});
}
// Re-prep form when we've loaded a new payproc
......@@ -465,7 +469,7 @@ CRM.$(function($) {
function getIsRecur() {
if (document.getElementById('is_recur') !== null) {
return Boolean(document.getElementById('is_recur').value);
return Boolean(document.getElementById('is_recur').checked);
}
return false;
}
......
CRM.$(function(d){f("civicrm_stripe loaded, dom-ready function firing.");if(window.civicrmStripeHandleReload){f("calling existing civicrmStripeHandleReload.");window.civicrmStripeHandleReload();return}var p;var b;var c;var a;var o=false;window.onbeforeunload=null;window.civicrmStripeHandleReload=function(){f("civicrmStripeHandleReload");var z=document.getElementById("card-element");if((typeof z!=="undefined")&&(z)){if(!z.children.length){f("checkAndLoad from document.ready");m()}}};window.civicrmStripeHandleReload();function u(A){f("paymentIntent confirmation success");var z=document.createElement("input");z.setAttribute("type","hidden");z.setAttribute("name","paymentIntentID");z.setAttribute("value",A.id);c.appendChild(z);c.submit()}function h(z){f("error: "+z.error.message);var A=document.getElementById("card-errors");A.style.display="block";A.textContent=z.error.message;document.querySelector("#billing-payment-block").scrollIntoView();window.scrollBy(0,-50);c.dataset.submitted=false;a.removeAttribute("disabled")}function x(){f("handle card payment");p.createPaymentMethod("card",b).then(function(z){if(z.error){h(z)}else{var A=CRM.url("civicrm/stripe/confirm-payment");d.post(A,{payment_method_id:z.paymentMethod.id,amount:q(),currency:CRM.vars.stripe.currency,id:CRM.vars.stripe.id,recur:g()}).then(function(B){v(B)})}})}function v(z){f("handleServerResponse");if(z.error){h(z)}else{if(z.requires_action){r(z)}else{u(z.paymentIntent)}}}function r(z){p.handleCardAction(z.payment_intent_client_secret).then(function(A){if(A.error){h(A)}else{u(A.paymentIntent)}})}d(document).ajaxComplete(function(B,C,A){if((A.url.match("civicrm(/|%2F)payment(/|%2F)form")!==null)||(A.url.match("civicrm(/|%2F)contact(/|%2F)view(/|%2F)participant")!==null)){if(typeof CRM.vars.stripe==="undefined"){return}var z=k();if(z!==null){if(z!==parseInt(CRM.vars.stripe.id)){f("payment processor changed to id: "+z);if(z===0){return l()}CRM.api3("PaymentProcessor","getvalue",{"return":"user_name",id:z,payment_processor_type_id:CRM.vars.stripe.paymentProcessorTypeID}).done(function(D){var E=D.result;if(E){f("Setting new stripe key to: "+E);CRM.vars.stripe.publishableKey=E}else{return l()}f("checkAndLoad from ajaxComplete");m()})}}}});function l(){f("New payment processor is not Stripe, clearing CRM.vars.stripe");if((typeof b!=="undefined")&&(b)){f("destroying card element");b.destroy();b=undefined}delete (CRM.vars.stripe)}function m(){if(typeof CRM.vars.stripe==="undefined"){f("CRM.vars.stripe not defined! Not a Stripe processor?");return}if(typeof Stripe==="undefined"){if(o){return}o=true;f("Stripe.js is not loaded!");d.getScript("https://js.stripe.com/v3",function(){f("Script loaded and executed.");o=false;e()})}else{e()}}function e(){f("loadStripeBillingBlock");if(typeof p==="undefined"){p=Stripe(CRM.vars.stripe.publishableKey)}var F=p.elements();var C={base:{fontSize:"20px"}};b=F.create("card",{style:C});b.mount("#card-element");f("created new card element",b);document.getElementsByClassName("billing_postal_code-"+CRM.vars.stripe.billingAddressID+"-section")[0].setAttribute("hidden",true);b.addEventListener("change",function(G){t(G)});c=j();if(typeof c.length==="undefined"||c.length===0){f("No billing form!");return}a=y();c.dataset.submitdontprocess=false;var z=c.querySelectorAll('[type="submit"][formnovalidate="1"], [type="submit"][formnovalidate="formnovalidate"], [type="submit"].cancel, [type="submit"].webform-previous'),B;for(B=0;B<z.length;++B){z[B].addEventListener("click",E())}function E(){f("adding submitdontprocess");c.dataset.submitdontprocess=true}a.addEventListener("click",A);function A(G){if(c.dataset.submitted===true){return}c.dataset.submitted=true;if(typeof CRM.vars.stripe==="undefined"){return c.submit()}f("clearing submitdontprocess");c.dataset.submitdontprocess=false;return D(G)}a.removeAttribute("onclick");n();if(w()){d("[type=submit]").click(function(){s(this.value)});c.addEventListener("keydown",function(G){if(G.keyCode===13){s(this.value);D(event)}});d("#billingcheckbox:input").hide();d('label[for="billingcheckbox"]').hide()}function D(I){I.preventDefault();f("submit handler");if(d(c).valid()===false){f("Form not valid");return false}if(typeof CRM.vars.stripe==="undefined"){f("Submitting - not a stripe processor");return true}if(c.dataset.submitted===true){f("form already submitted");return false}var K=CRM.vars.stripe.id;var H=null;if(w()){K=CRM.vars.stripe.id;if(!d('input[name="submitted[civicrm_1_contribution_1_contribution_payment_processor_id]"]').length){H=K}else{H=c.querySelector('input[name="submitted[civicrm_1_contribution_1_contribution_payment_processor_id]"]:checked').val()}}else{if((c.querySelector(".crm-section.payment_processor-section")!==null)||(c.querySelector(".crm-section.credit_card_info-section")!==null)){K=CRM.vars.stripe.id;if(c.querySelector('input[name="payment_processor_id"]:checked')!==null){H=c.querySelector('input[name="payment_processor_id"]:checked').value}}}if((H===0)||(K===null)||((H===null)&&(K===null))){f("Not a Stripe transaction, or pay-later");return true}else{f("Stripe is the selected payprocessor")}if(typeof CRM.vars.stripe.publishableKey==="undefined"){f("submit missing stripe-pub-key element or value");return true}if(c.dataset.submitdontprocess===true){f("non-payment submit detected - not submitting payment");return true}if(w()){if(d("#billing-payment-block").is(":hidden")){f("no payment processor on webform");return true}var J=d('[name="submitted[civicrm_1_contribution_1_contribution_payment_processor_id]"]');if(J.length){if(J.filter(":checked").val()==="0"||J.filter(":checked").val()===0){f("no payment processor selected");return true}}}var G=q();if(G=="0"){f("Total amount is 0");return true}if(c.dataset.submitted===true){alert("Form already submitted. Please wait.");return false}else{c.dataset.submitted=true}a.setAttribute("disabled",true);x();return true}}function w(){if(c!==null){return c.classList.contains("webform-client-form")||c.classList.contains("webform-submission-form")}return false}function j(){var z=d("div#card-element").closest("form").prop("id");if((typeof z==="undefined")||(!z.length)){z=d("input[name=hidden_processor]").closest("form").prop("id")}return document.getElementById(z)}function y(){var z=null;if(w()){z=c.querySelector('[type="submit"].webform-submit');if(!z){z=c.querySelector('[type="submit"].webform-button--submit')}}else{z=c.querySelector('[type="submit"].validate')}return z}function q(){var z=null;if(typeof calculateTotalFee=="function"){z=calculateTotalFee()}else{if(w()){d(".line-item:visible","#wf-crm-billing-items").each(function(){z+=parseFloat(d(this).data("amount"))})}else{if(document.getElementById("total_amount")){return document.getElementById("total_amount").value}}}return z}function g(){if(document.getElementById("is_recur")!==null){return Boolean(document.getElementById("is_recur").value)}return false}function t(z){if(!z.complete){return}document.getElementById("billing_postal_code-"+CRM.vars.stripe.billingAddressID).value=z.value.postalCode}function n(){cividiscountElements=c.querySelectorAll("input#discountcode");var z=function(A){if(A.keyCode===13){A.preventDefault();f("adding submitdontprocess");c.dataset.submitdontprocess=true}};for(i=0;i<cividiscountElements.length;++i){cividiscountElements[i].addEventListener("keydown",z)}}function f(z){if((typeof(CRM.vars.stripe)==="undefined")||(Boolean(CRM.vars.stripe.jsDebug)===true)){console.log(new Date().toISOString()+" civicrm_stripe.js: "+z)}}function s(A){var z=null;if(document.getElementById("action")!==null){z=document.getElementById("action")}else{z=document.createElement("input")}z.setAttribute("type","hidden");z.setAttribute("name","op");z.setAttribute("id","action");z.setAttribute("value",A);c.appendChild(z)}function k(){if((typeof c==="undefined")||(!c)){c=j();if(!c){return null}}var z=c.querySelector('input[name="payment_processor_id"]:checked');if(z!==null){return parseInt(z.value)}return null}});
\ No newline at end of file
CRM.$(function(d){f("civicrm_stripe loaded, dom-ready function firing.");if(window.civicrmStripeHandleReload){f("calling existing civicrmStripeHandleReload.");window.civicrmStripeHandleReload();return}var p;var b;var c;var a;var o=false;window.onbeforeunload=null;window.civicrmStripeHandleReload=function(){f("civicrmStripeHandleReload");var z=document.getElementById("card-element");if((typeof z!=="undefined")&&(z)){if(!z.children.length){f("checkAndLoad from document.ready");m()}}};window.civicrmStripeHandleReload();function u(B,z){f(B+": success - submitting form");var A=document.createElement("input");A.setAttribute("type","hidden");A.setAttribute("name",B);A.setAttribute("value",z.id);c.appendChild(A);c.submit()}function h(z){f("error: "+z.error.message);var A=document.getElementById("card-errors");A.style.display="block";A.textContent=z.error.message;document.querySelector("#billing-payment-block").scrollIntoView();window.scrollBy(0,-50);c.dataset.submitted=false;a.removeAttribute("disabled")}function x(){f("handle card payment");p.createPaymentMethod("card",b).then(function(z){if(z.error){h(z)}else{if(g()===true){u("paymentMethodID",z.paymentMethod)}else{var A=CRM.url("civicrm/stripe/confirm-payment");d.post(A,{payment_method_id:z.paymentMethod.id,amount:q(),currency:CRM.vars.stripe.currency,id:CRM.vars.stripe.id}).then(function(B){v(B)})}}})}function v(z){f("handleServerResponse");if(z.error){h(z)}else{if(z.requires_action){r(z)}else{u("paymentIntentID",z.paymentIntent)}}}function r(z){p.handleCardAction(z.payment_intent_client_secret).then(function(A){if(A.error){h(A)}else{u("paymentIntentID",A.paymentIntent)}})}d(document).ajaxComplete(function(B,C,A){if((A.url.match("civicrm(/|%2F)payment(/|%2F)form")!==null)||(A.url.match("civicrm(/|%2F)contact(/|%2F)view(/|%2F)participant")!==null)){if(typeof CRM.vars.stripe==="undefined"){return}var z=k();if(z!==null){if(z!==parseInt(CRM.vars.stripe.id)){f("payment processor changed to id: "+z);if(z===0){return l()}CRM.api3("PaymentProcessor","getvalue",{"return":"user_name",id:z,payment_processor_type_id:CRM.vars.stripe.paymentProcessorTypeID}).done(function(D){var E=D.result;if(E){f("Setting new stripe key to: "+E);CRM.vars.stripe.publishableKey=E}else{return l()}f("checkAndLoad from ajaxComplete");m()})}}}});function l(){f("New payment processor is not Stripe, clearing CRM.vars.stripe");if((typeof b!=="undefined")&&(b)){f("destroying card element");b.destroy();b=undefined}delete (CRM.vars.stripe)}function m(){if(typeof CRM.vars.stripe==="undefined"){f("CRM.vars.stripe not defined! Not a Stripe processor?");return}if(typeof Stripe==="undefined"){if(o){return}o=true;f("Stripe.js is not loaded!");d.getScript("https://js.stripe.com/v3",function(){f("Script loaded and executed.");o=false;e()})}else{e()}}function e(){f("loadStripeBillingBlock");if(typeof p==="undefined"){p=Stripe(CRM.vars.stripe.publishableKey)}var F=p.elements();var C={base:{fontSize:"20px"}};b=F.create("card",{style:C});b.mount("#card-element");f("created new card element",b);document.getElementsByClassName("billing_postal_code-"+CRM.vars.stripe.billingAddressID+"-section")[0].setAttribute("hidden",true);b.addEventListener("change",function(G){t(G)});c=j();if(typeof c.length==="undefined"||c.length===0){f("No billing form!");return}a=y();c.dataset.submitdontprocess=false;var z=c.querySelectorAll('[type="submit"][formnovalidate="1"], [type="submit"][formnovalidate="formnovalidate"], [type="submit"].cancel, [type="submit"].webform-previous'),B;for(B=0;B<z.length;++B){z[B].addEventListener("click",E())}function E(){f("adding submitdontprocess");c.dataset.submitdontprocess=true}a.addEventListener("click",A);function A(G){if(c.dataset.submitted===true){return}c.dataset.submitted=true;if(typeof CRM.vars.stripe==="undefined"){return c.submit()}f("clearing submitdontprocess");c.dataset.submitdontprocess=false;return D(G)}a.removeAttribute("onclick");n();if(w()){d("[type=submit]").click(function(){s(this.value)});c.addEventListener("keydown",function(G){if(G.keyCode===13){s(this.value);D(event)}});d("#billingcheckbox:input").hide();d('label[for="billingcheckbox"]').hide()}function D(I){I.preventDefault();f("submit handler");if(d(c).valid()===false){f("Form not valid");return false}if(typeof CRM.vars.stripe==="undefined"){f("Submitting - not a stripe processor");return true}if(c.dataset.submitted===true){f("form already submitted");return false}var K=CRM.vars.stripe.id;var H=null;if(w()){K=CRM.vars.stripe.id;if(!d('input[name="submitted[civicrm_1_contribution_1_contribution_payment_processor_id]"]').length){H=K}else{H=c.querySelector('input[name="submitted[civicrm_1_contribution_1_contribution_payment_processor_id]"]:checked').val()}}else{if((c.querySelector(".crm-section.payment_processor-section")!==null)||(c.querySelector(".crm-section.credit_card_info-section")!==null)){K=CRM.vars.stripe.id;if(c.querySelector('input[name="payment_processor_id"]:checked')!==null){H=c.querySelector('input[name="payment_processor_id"]:checked').value}}}if((H===0)||(K===null)||((H===null)&&(K===null))){f("Not a Stripe transaction, or pay-later");return true}else{f("Stripe is the selected payprocessor")}if(typeof CRM.vars.stripe.publishableKey==="undefined"){f("submit missing stripe-pub-key element or value");return true}if(c.dataset.submitdontprocess===true){f("non-payment submit detected - not submitting payment");return true}if(w()){if(d("#billing-payment-block").is(":hidden")){f("no payment processor on webform");return true}var J=d('[name="submitted[civicrm_1_contribution_1_contribution_payment_processor_id]"]');if(J.length){if(J.filter(":checked").val()==="0"||J.filter(":checked").val()===0){f("no payment processor selected");return true}}}var G=q();if(G=="0"){f("Total amount is 0");return true}if(c.dataset.submitted===true){alert("Form already submitted. Please wait.");return false}else{c.dataset.submitted=true}a.setAttribute("disabled",true);x();return true}}function w(){if(c!==null){return c.classList.contains("webform-client-form")||c.classList.contains("webform-submission-form")}return false}function j(){var z=d("div#card-element").closest("form").prop("id");if((typeof z==="undefined")||(!z.length)){z=d("input[name=hidden_processor]").closest("form").prop("id")}return document.getElementById(z)}function y(){var z=null;if(w()){z=c.querySelector('[type="submit"].webform-submit');if(!z){z=c.querySelector('[type="submit"].webform-button--submit')}}else{z=c.querySelector('[type="submit"].validate')}return z}function q(){var z=null;if(typeof calculateTotalFee=="function"){z=calculateTotalFee()}else{if(w()){d(".line-item:visible","#wf-crm-billing-items").each(function(){z+=parseFloat(d(this).data("amount"))})}else{if(document.getElementById("total_amount")){return document.getElementById("total_amount").value}}}return z}function g(){if(document.getElementById("is_recur")!==null){return Boolean(document.getElementById("is_recur").checked)}return false}function t(z){if(!z.complete){return}document.getElementById("billing_postal_code-"+CRM.vars.stripe.billingAddressID).value=z.value.postalCode}function n(){cividiscountElements=c.querySelectorAll("input#discountcode");var z=function(A){if(A.keyCode===13){A.preventDefault();f("adding submitdontprocess");c.dataset.submitdontprocess=true}};for(i=0;i<cividiscountElements.length;++i){cividiscountElements[i].addEventListener("keydown",z)}}function f(z){if((typeof(CRM.vars.stripe)==="undefined")||(Boolean(CRM.vars.stripe.jsDebug)===true)){console.log(new Date().toISOString()+" civicrm_stripe.js: "+z)}}function s(A){var z=null;if(document.getElementById("action")!==null){z=document.getElementById("action")}else{z=document.createElement("input")}z.setAttribute("type","hidden");z.setAttribute("name","op");z.setAttribute("id","action");z.setAttribute("value",A);c.appendChild(z)}function k(){if((typeof c==="undefined")||(!c)){c=j();if(!c){return null}}var z=c.querySelector('input[name="payment_processor_id"]:checked');if(z!==null){return parseInt(z.value)}return null}});
\ No newline at end of file
......@@ -141,6 +141,7 @@ function stripe_civicrm_postProcess($formName, &$form) {
if (empty($form->get('paymentProcessor')) || ($form->get('paymentProcessor')['class_name'] !== 'Payment_Stripe')) {
return;
}
CRM_Core_Payment_Stripe::setTokenParameter('paymentMethodID', $form);
CRM_Core_Payment_Stripe::setTokenParameter('paymentIntentID', $form);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment