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
88b90577
Commit
88b90577
authored
5 years ago
by
mattwire
Browse files
Options
Downloads
Patches
Plain Diff
Partial support for backend payments (disabled)
parent
93321013
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CRM/Core/Payment/Stripe.php
+11
-2
11 additions, 2 deletions
CRM/Core/Payment/Stripe.php
stripe.php
+40
-46
40 additions, 46 deletions
stripe.php
templates/CRM/Core/Payment/Stripe/Card.tpl
+0
-1
0 additions, 1 deletion
templates/CRM/Core/Payment/Stripe/Card.tpl
with
51 additions
and
49 deletions
CRM/Core/Payment/Stripe.php
+
11
−
2
View file @
88b90577
...
...
@@ -123,7 +123,9 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
* @return bool
*/
public
function
supportsBackOffice
()
{
return
TRUE
;
// @fixme Make this work again with stripe elements / 6.0
return
FALSE
;
// return TRUE;
}
/**
...
...
@@ -134,6 +136,11 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
return
FALSE
;
}
public
function
supportsRecurring
()
{
// @fixme: Test and make this work for stripe elements / 6.0
return
FALSE
;
}
/**
* We can configure a start date for a smartdebit mandate
* @return bool
...
...
@@ -316,7 +323,9 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
// Add help and javascript
CRM_Core_Region
::
instance
(
'billing-block'
)
->
add
(
[
'template'
=>
'CRM/Core/Payment/Stripe/Card.tpl'
,
'weight'
=>
-
1
]);
CRM_Core_Resources
::
singleton
()
->
addStyleFile
(
E
::
LONG_NAME
,
'css/elements.css'
,
0
,
'html-header'
);
CRM_Core_Resources
::
singleton
()
->
addStyleFile
(
E
::
LONG_NAME
,
'css/elements.css'
,
0
,
'page-header'
)
->
addScriptFile
(
'com.drastikbydesign.stripe'
,
'js/civicrm_stripe.js'
);
}
/**
...
...
This diff is collapsed.
Click to expand it.
stripe.php
+
40
−
46
View file @
88b90577
...
...
@@ -81,43 +81,40 @@ function stripe_civicrm_alterSettingsFolders(&$metaDataFolders = NULL) {
}
/**
* Implementation of hook_civicrm_validateForm().
*
* Prevent server validation of cc fields
*
* @param $formName - the name of the form
* @param $fields - Array of name value pairs for all 'POST'ed form values
* @param $files - Array of file properties as sent by PHP POST protocol
* @param $form - reference to the form object
* @param $errors - Reference to the errors array.
*
*/
* Implementation of hook_civicrm_validateForm().
*
* Prevent server validation of cc fields
*
* @param $formName - the name of the form
* @param $fields - Array of name value pairs for all 'POST'ed form values
* @param $files - Array of file properties as sent by PHP POST protocol
* @param $form - reference to the form object
* @param $errors - Reference to the errors array.
*
*/
function
stripe_civicrm_validateForm
(
$formName
,
&
$fields
,
&
$files
,
&
$form
,
&
$errors
)
{
if
(
empty
(
$form
->
_paymentProcessor
[
'payment_processor_type'
]))
{
return
;
}
// If Stripe is active here.
if
(
$form
->
_paymentProcessor
[
'class_name'
]
==
'Payment_Stripe'
)
{
if
(
isset
(
$form
->
_elementIndex
[
'stripe_token'
]))
{
if
(
$form
->
elementExists
(
'credit_card_number'
))
{
$cc_field
=
$form
->
getElement
(
'credit_card_number'
);
$form
->
removeElement
(
'credit_card_number'
,
true
);
$form
->
addElement
(
$cc_field
);
}
if
(
$form
->
elementExists
(
'cvv2'
))
{
$cvv2_field
=
$form
->
getElement
(
'cvv2'
);
$form
->
removeElement
(
'cvv2'
,
true
);
$form
->
addElement
(
$cvv2_field
);
}
function
stripe_civicrm_validateForm
(
$formName
,
&
$fields
,
&
$files
,
&
$form
,
&
$errors
)
{
if
(
empty
(
$form
->
_paymentProcessor
[
'payment_processor_type'
]))
{
return
;
}
// If Stripe is active here.
if
(
$form
->
_paymentProcessor
[
'class_name'
]
==
'Payment_Stripe'
)
{
if
(
isset
(
$form
->
_elementIndex
[
'stripe_token'
]))
{
if
(
$form
->
elementExists
(
'credit_card_number'
))
{
$cc_field
=
$form
->
getElement
(
'credit_card_number'
);
$form
->
removeElement
(
'credit_card_number'
,
true
);
$form
->
addElement
(
$cc_field
);
}
if
(
$form
->
elementExists
(
'cvv2'
))
{
$cvv2_field
=
$form
->
getElement
(
'cvv2'
);
$form
->
removeElement
(
'cvv2'
,
true
);
$form
->
addElement
(
$cvv2_field
);
}
}
else
{
return
;
}
}
else
{
return
;
}
// Flag so we don't add the stripe scripts more than once.
static
$_stripe_scripts_added
;
}
/**
* Implementation of hook_civicrm_alterContent
...
...
@@ -128,7 +125,6 @@ static $_stripe_scripts_added;
* @return void
*/
function
stripe_civicrm_alterContent
(
&
$content
,
$context
,
$tplName
,
&
$object
)
{
global
$_stripe_scripts_added
;
/* Adding stripe js:
* - Webforms don't get scripts added by hook_civicrm_buildForm so we have to user alterContent
* - (Webforms still call buildForm and it looks like they are added but they are not,
...
...
@@ -139,12 +135,12 @@ function stripe_civicrm_alterContent( &$content, $context, $tplName, &$object )
*
*/
if
((
$context
==
'form'
&&
!
empty
(
$object
->
_paymentProcessor
[
'class_name'
]))
||
((
$context
==
'page'
)
&&
!
empty
(
$object
->
_isPaymentProcessor
)))
{
if
(
!
$_stripe_scripts_added
||
$object
instanceof
CRM_Financial_Form_Payment
)
{
||
((
$context
==
'page'
)
&&
!
empty
(
$object
->
_isPaymentProcessor
)))
{
if
(
!
isset
(
\Civi
::
$statics
[
E
::
LONG_NAME
][
'stripeJSLoaded'
])
||
$object
instanceof
CRM_Financial_Form_Payment
)
{
$stripeJSURL
=
CRM_Core_Resources
::
singleton
()
->
getUrl
(
'com.drastikbydesign.stripe'
,
'js/civicrm_stripe.js'
);
$content
.
=
"<script src='
{
$stripeJSURL
}
'></script>"
;
$_stripe_scripts_ad
ded
=
TRUE
;
\Civi
::
$statics
[
E
::
LONG_NAME
][
'stripeJSLoa
ded
'
]
=
TRUE
;
}
}
}
...
...
@@ -157,17 +153,15 @@ function stripe_civicrm_alterContent( &$content, $context, $tplName, &$object )
* @param CRM_Core_Form $form
*/
function
stripe_civicrm_buildForm
(
$formName
,
&
$form
)
{
global
$_stripe_scripts_added
;
if
(
!
isset
(
$form
->
_paymentProcessor
)
)
{
// Don't load stripe js on ajax forms
if
(
CRM_Utils_Request
::
retrieveValue
(
'snippet'
,
'String'
)
===
'json'
)
{
return
;
}
$paymentProcessor
=
$form
->
_paymentProcessor
;
if
(
!
empty
(
$paymentProcessor
[
'class_name'
]))
{
if
(
!
$_stripe_scripts_added
)
{
CRM_Core_Resources
::
singleton
()
->
addScriptFile
(
'com.drastikbydesign.stripe'
,
'js/civicrm_stripe.js'
);
}
$_stripe_scripts_added
=
TRUE
;
// Load stripe.js on all civi forms per stripe requirements
if
(
!
isset
(
\Civi
::
$statics
[
E
::
LONG_NAME
][
'stripeJSLoaded'
]))
{
CRM_Core_Resources
::
singleton
()
->
addScriptUrl
(
'https://js.stripe.com/v3'
);
\Civi
::
$statics
[
E
::
LONG_NAME
][
'stripeJSLoaded'
]
=
TRUE
;
}
}
...
...
This diff is collapsed.
Click to expand it.
templates/CRM/Core/Payment/Stripe/Card.tpl
+
0
−
1
View file @
88b90577
{* https://civicrm.org/licensing *}
<script
src=
"https://js.stripe.com/v3/"
></script>
<label
for=
"card-element"
>
<legend>
Credit or debit card
</legend>
</label>
...
...
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