Skip to content
Snippets Groups Projects
Commit 9f840628 authored by Eran's avatar Eran
Browse files

Fix merge conflicts

parents 76fd1788 a239e3d1
No related branches found
No related tags found
No related merge requests found
......@@ -8,6 +8,7 @@
// Response from Stripe.createToken.
function stripeResponseHandler(status, response) {
var submitButton = $("form.stripe-payment-form input[type='submit']:last");
if (response.error) {
$('html, body').animate({scrollTop: 0}, 300);
// Show the errors on the form.
......@@ -22,19 +23,14 @@
+ '</ul>'
+ '</div>');
$submit.removeAttr("disabled").attr('value', buttonText);
$submit.removeAttr('disabled').attr('value', buttonText);
}
else {
var token = response['id'];
// Update form with the token & submit.
$form.find("input#stripe-token").val(token);
// clear actual credit card information and set dummy cc details
// we are setting dummy cc details to prevent validation errors
// this is a work around so that we don't transmit sensitive data
$('#credit_card_number').val('4111111111111111');
$('#cvv2').val('111');
$submit.prop('disabled', false);
window.onbeforeunload = null;
$form.get(0).submit();
}
......@@ -51,12 +47,16 @@
$submit.removeAttr('onclick');
$form.unbind('submit');
// Intercept form submission.
$form.submit(function (event) {
event.preventDefault();
event.stopPropagation();
// Disable the submit button to prevent repeated clicks, keep old button text to restore if Stripe returns error
// Disable the submit button to prevent repeated clicks, cache button text, restore if Stripe returns error
buttonText = $submit.attr('value');
$submit.attr('disabled', true).attr('value', 'Processing');
$submit.prop('disabled', true).attr('value', 'Processing');
if ($form.find("#priceset input[type='radio']:checked").data('amount') == 0) {
return true;
......@@ -92,9 +92,7 @@
exp_year: cc_year
}, stripeResponseHandler);
// Prevent the form from submitting with the default action.
return false;
});
});
}(jQuery));
}(CRM.$));
......@@ -69,9 +69,20 @@ function stripe_civicrm_uninstall() {
* Implementation of hook_civicrm_enable().
*/
function stripe_civicrm_enable() {
$UF_webhook_paths = array(
"Drupal" => "/civicrm/stripe/webhook",
"Drupal6" => "/civicrm/stripe/webhook",
"Joomla" => "/index.php/component/civicrm/?task=civicrm/stripe/webhook",
"WordPress" => "/?page=CiviCRM&q=civicrm/stripe/webhook"
);
// Use Drupal path as default if the UF isn't in the map above
$webookhook_path = (array_key_exists(CIVICRM_UF, $UF_webhook_paths)) ?
CIVICRM_UF_BASEURL . $UF_webhook_paths[CIVICRM_UF] :
CIVICRM_UF_BASEURL . "civicrm/stripe/webhook";
CRM_Core_Session::setStatus("Stripe Payment Processor Message:
<br />Don't forget to set up Webhooks in Stripe so that recurring contributions are ended!
<br />Webhook path to enter in Stripe: <strong>yoursite.com/civicrm/stripe/webhook</strong>
<br />Webhook path to enter in Stripe:<br/><em>$webookhook_path</em>
<br />");
return _stripe_civix_civicrm_enable();
......@@ -117,7 +128,12 @@ function stripe_civicrm_buildForm($formName, &$form) {
}
// For the 'Record Contribution' backend page.
if (($formName == 'CRM_Contribute_Form_Contribution' || $formName == 'CRM_Event_Form_Participant' || $formName == 'CRM_Member_Form_Membership' && !empty($form->_processors)) || stristr($formName, '_Main')) {
$backendForms = array(
'CRM_Contribute_Form_Contribution',
'CRM_Event_Form_Participant',
'CRM_Member_Form_Membership'
);
if (in_array($formName, $backendForms) && !empty($form->_processors)) {
if (!isset($form->_elementIndex['stripe_token'])) {
$form->_attributes['class'] .= " stripe-payment-form";
$form->addElement('hidden', 'stripe_token', NULL, 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