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
a239e3d1
Commit
a239e3d1
authored
10 years ago
by
Joshua Walker
Browse files
Options
Downloads
Plain Diff
Merge pull request
#64
from kurund/js-fixes
more js fixes and code cleanup
parents
032970f0
60a5dc10
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
js/civicrm_stripe.js
+11
-13
11 additions, 13 deletions
js/civicrm_stripe.js
stripe.php
+6
-1
6 additions, 1 deletion
stripe.php
with
17 additions
and
14 deletions
js/civicrm_stripe.js
+
11
−
13
View file @
a239e3d1
...
...
@@ -5,6 +5,7 @@
(
function
(
$
)
{
// 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.
...
...
@@ -19,21 +20,15 @@
+
'
</ul>
'
+
'
</div>
'
);
$
(
'
form.stripe-payment-form input.form-submit
'
).
removeAttr
(
"
disabled
"
);
submitButton
.
prop
(
'
disabled
'
,
false
);
}
else
{
var
token
=
response
[
'
id
'
];
// Update form with the token & submit.
$
(
"
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
'
);
$
(
'
form.stripe-payment-form input.form-submit
'
).
removeAttr
(
"
disabled
"
);
$
(
"
input[type='submit']:last
"
).
click
();
submitButton
.
prop
(
'
disabled
'
,
false
);
$
(
"
form.stripe-payment-form
"
).
get
(
0
).
submit
();
}
}
...
...
@@ -55,11 +50,16 @@
$
(
'
#crm-ajax-dialog-1 form
'
).
addClass
(
'
stripe-payment-form
'
);
}
$
(
"
form.stripe-payment-form
"
).
unbind
(
'
submit
'
);
// Intercept form submission.
$
(
"
form.stripe-payment-form
"
).
submit
(
function
(
event
)
{
event
.
preventDefault
();
event
.
stopPropagation
();
var
$form
=
$
(
this
);
// Disable the submit button to prevent repeated clicks.
$
(
"
input[type='submit']:last
"
).
attr
(
'
disabled
'
,
true
);
$
form
.
find
(
"
input[type='submit']:last
"
).
prop
(
'
disabled
'
,
true
);
if
(
$form
.
find
(
"
#priceset input[type='radio']:checked
"
).
data
(
'
amount
'
)
==
0
)
{
return
true
;
...
...
@@ -95,9 +95,7 @@
exp_year
:
cc_year
},
stripeResponseHandler
);
// Prevent the form from submitting with the default action.
return
false
;
});
});
}(
jQuery
));
}(
CRM
.
$
));
This diff is collapsed.
Click to expand it.
stripe.php
+
6
−
1
View file @
a239e3d1
...
...
@@ -129,7 +129,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
->
addElement
(
'hidden'
,
'stripe_token'
,
NULL
,
array
(
'id'
=>
'stripe-token'
));
stripe_add_stripe_js
(
$form
);
...
...
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