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
9f840628
Commit
9f840628
authored
10 years ago
by
Eran
Browse files
Options
Downloads
Plain Diff
Fix merge conflicts
parents
76fd1788
a239e3d1
No related branches found
Branches containing commit
No related tags found
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
+18
-2
18 additions, 2 deletions
stripe.php
with
29 additions
and
15 deletions
js/civicrm_stripe.js
+
11
−
13
View file @
9f840628
...
...
@@ -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
.
$
));
This diff is collapsed.
Click to expand it.
stripe.php
+
18
−
2
View file @
9f840628
...
...
@@ -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'
));
...
...
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