Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Stripe
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Extensions
Stripe
Commits
8928a489
Unverified
Commit
8928a489
authored
6 years ago
by
mattwire
Committed by
GitHub
6 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request
#3
from progressivetech/handle-corner-errors
handle error corner cases
parents
9df3cf70
3751fe5b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
js/civicrm_stripe.js
+31
-11
31 additions, 11 deletions
js/civicrm_stripe.js
with
31 additions
and
11 deletions
js/civicrm_stripe.js
+
31
−
11
View file @
8928a489
...
@@ -37,14 +37,25 @@
...
@@ -37,14 +37,25 @@
// Disable unload event handler
// Disable unload event handler
window
.
onbeforeunload
=
null
;
window
.
onbeforeunload
=
null
;
// Restore any onclickAction that was removed.
$submit
.
attr
(
'
onclick
'
,
onclickAction
);
// This triggers submit without generating a submit event (so we don't run submit handler again)
// This triggers submit without generating a submit event (so we don't run submit handler again)
$form
.
get
(
0
).
submit
();
$form
.
get
(
0
).
submit
();
}
}
}
}
// Prepare the form.
// Prepare the form.
var
onclickAction
=
null
;
$
(
document
).
ready
(
function
()
{
$
(
document
).
ready
(
function
()
{
loadStripeBillingBlock
();
loadStripeBillingBlock
();
$submit
=
getBillingSubmit
();
// Store and remove any onclick Action currently assigned to the form.
// We will re-add it if the transaction goes through.
onclickAction
=
$submit
.
attr
(
'
onclick
'
);
$submit
.
removeAttr
(
'
onclick
'
);
});
});
// Re-prep form when we've loaded a new payproc
// Re-prep form when we've loaded a new payproc
...
@@ -129,7 +140,19 @@
...
@@ -129,7 +140,19 @@
// Intercept form submission.
// Intercept form submission.
$form
.
on
(
'
submit
'
,
function
(
event
)
{
$form
.
on
(
'
submit
'
,
function
(
event
)
{
submit
(
event
);
var
ret
=
submit
(
event
);
if
(
ret
)
{
// True means it's not our form. We are bailing and not trying to
// process Stripe.
// Restore any onclickAction that was removed.
$form
=
getBillingForm
();
$submit
=
getBillingSubmit
();
$submit
.
attr
(
'
onclick
'
,
onclickAction
);
$form
.
get
(
0
).
submit
();
return
true
;
}
// Otherwise, this is a stripe submission - don't handle normally.
return
false
;
});
});
function
submit
(
event
)
{
function
submit
(
event
)
{
...
@@ -150,7 +173,6 @@
...
@@ -150,7 +173,6 @@
// Bail if we're not using Stripe or are using pay later (option value '0' in payment_processor radio group).
// Bail if we're not using Stripe or are using pay later (option value '0' in payment_processor radio group).
if
((
chosenProcessorId
!==
stripeProcessorId
)
||
(
chosenProcessorId
===
0
))
{
if
((
chosenProcessorId
!==
stripeProcessorId
)
||
(
chosenProcessorId
===
0
))
{
debugging
(
'
debug: Not a Stripe transaction, or pay-later
'
);
debugging
(
'
debug: Not a Stripe transaction, or pay-later
'
);
$form
.
get
(
0
).
submit
();
return
true
;
return
true
;
}
}
}
}
...
@@ -168,7 +190,6 @@
...
@@ -168,7 +190,6 @@
// Don't handle submits generated by the CiviDiscount button.
// Don't handle submits generated by the CiviDiscount button.
if
(
$form
.
data
(
'
submit-dont-process
'
))
{
if
(
$form
.
data
(
'
submit-dont-process
'
))
{
debugging
(
'
non-payment submit detected - not submitting payment
'
);
debugging
(
'
non-payment submit detected - not submitting payment
'
);
$form
.
get
(
0
).
submit
();
return
true
;
return
true
;
}
}
...
@@ -196,11 +217,17 @@
...
@@ -196,11 +217,17 @@
}
}
}
}
// If there's no credit card field, no use in continuing (probably wrong
// context anyway)
if
(
!
$form
.
find
(
'
#credit_card_number
'
).
length
)
{
debugging
(
'
debug: No credit card field
'
);
return
true
;
}
// Lock to prevent multiple submissions
// Lock to prevent multiple submissions
if
(
$form
.
data
(
'
submitted
'
)
===
true
)
{
if
(
$form
.
data
(
'
submitted
'
)
===
true
)
{
// Previously submitted - don't submit again
// Previously submitted - don't submit again
alert
(
'
Form already submitted. Please wait.
'
);
alert
(
'
Form already submitted. Please wait.
'
);
return
tru
e
;
return
fals
e
;
}
else
{
}
else
{
// Mark it so that the next submit can be ignored
// Mark it so that the next submit can be ignored
// ADDED requirement that form be valid
// ADDED requirement that form be valid
...
@@ -212,13 +239,6 @@
...
@@ -212,13 +239,6 @@
// Disable the submit button to prevent repeated clicks
// Disable the submit button to prevent repeated clicks
$submit
.
prop
(
'
disabled
'
,
true
);
$submit
.
prop
(
'
disabled
'
,
true
);
// If there's no credit card field, no use in continuing (probably wrong
// context anyway)
if
(
!
$form
.
find
(
'
#credit_card_number
'
).
length
)
{
debugging
(
'
debug: No credit card field
'
);
return
true
;
}
var
cc_month
=
$form
.
find
(
'
#credit_card_exp_date_M
'
).
val
();
var
cc_month
=
$form
.
find
(
'
#credit_card_exp_date_M
'
).
val
();
var
cc_year
=
$form
.
find
(
'
#credit_card_exp_date_Y
'
).
val
();
var
cc_year
=
$form
.
find
(
'
#credit_card_exp_date_Y
'
).
val
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment