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
454c055c
Commit
454c055c
authored
8 years ago
by
Andie Hunt
Browse files
Options
Downloads
Patches
Plain Diff
Stripe customers per-account
parent
9d78a704
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CRM/Core/Payment/Stripe.php
+10
-6
10 additions, 6 deletions
CRM/Core/Payment/Stripe.php
CRM/Stripe/Upgrader.php
+19
-0
19 additions, 0 deletions
CRM/Stripe/Upgrader.php
stripe.php
+1
-0
1 addition, 0 deletions
stripe.php
with
30 additions
and
6 deletions
CRM/Core/Payment/Stripe.php
+
10
−
6
View file @
454c055c
...
...
@@ -310,11 +310,12 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
// Prepare escaped query params.
$query_params
=
array
(
1
=>
array
(
$email
,
'String'
),
2
=>
array
(
$this
->
_paymentProcessor
[
'id'
],
'Integer'
),
);
$customer_query
=
CRM_Core_DAO
::
singleValueQuery
(
"SELECT id
FROM civicrm_stripe_customers
WHERE email = %1 AND is_live = '
{
$this
->
_islive
}
'"
,
$query_params
);
WHERE email = %1 AND is_live = '
{
$this
->
_islive
}
'
AND processor_id = %2
"
,
$query_params
);
/****
* If for some reason you cannot use Stripe.js and you are aware of PCI Compliance issues,
...
...
@@ -368,10 +369,11 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
$query_params
=
array
(
1
=>
array
(
$email
,
'String'
),
2
=>
array
(
$stripe_customer
->
id
,
'String'
),
3
=>
array
(
$this
->
_paymentProcessor
[
'id'
],
'Integer'
),
);
CRM_Core_DAO
::
executeQuery
(
"INSERT INTO civicrm_stripe_customers
(email, id, is_live) VALUES (%1, %2, '
{
$this
->
_islive
}
')"
,
$query_params
);
(email, id, is_live
, processor_id
) VALUES (%1, %2, '
{
$this
->
_islive
}
'
, %3
)"
,
$query_params
);
}
else
{
CRM_Core_Error
::
fatal
(
ts
(
'There was an error saving new customer within Stripe. Is Stripe down?'
));
...
...
@@ -421,17 +423,19 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
// Delete whatever we have for this customer.
$query_params
=
array
(
1
=>
array
(
$email
,
'String'
),
2
=>
array
(
$this
->
_paymentProcessor
[
'id'
],
'Integer'
),
);
CRM_Core_DAO
::
executeQuery
(
"DELETE FROM civicrm_stripe_customers
WHERE email = %1 AND is_live = '
{
$this
->
_islive
}
'"
,
$query_params
);
WHERE email = %1 AND is_live = '
{
$this
->
_islive
}
'
AND processor_id = %2
"
,
$query_params
);
// Create new record for this customer.
$query_params
=
array
(
1
=>
array
(
$email
,
'String'
),
2
=>
array
(
$stripe_customer
->
id
,
'String'
),
3
=>
array
(
$this
->
_paymentProcessor
[
'id'
],
'Integer'
),
);
CRM_Core_DAO
::
executeQuery
(
"INSERT INTO civicrm_stripe_customers (email, id, is_live)
VALUES (%1, %2, '
{
$this
->
_islive
}
')"
,
$query_params
);
CRM_Core_DAO
::
executeQuery
(
"INSERT INTO civicrm_stripe_customers (email, id, is_live
, processor_id
)
VALUES (%1, %2, '
{
$this
->
_islive
}
, %3
')"
,
$query_params
);
}
else
{
// Customer was found in civicrm_stripe database, but unable to be
...
...
@@ -576,7 +580,7 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
// subscription first.
$subscriptions
=
$stripe_customer
->
offsetGet
(
'subscriptions'
);
$data
=
$subscriptions
->
offsetGet
(
'data'
);
if
(
!
empty
(
$data
))
{
$status
=
$data
[
0
]
->
offsetGet
(
'status'
);
...
...
This diff is collapsed.
Click to expand it.
CRM/Stripe/Upgrader.php
+
19
−
0
View file @
454c055c
...
...
@@ -51,4 +51,23 @@ class CRM_Stripe_Upgrader extends CRM_Stripe_Upgrader_Base {
}
return
TRUE
;
}
/**
* Add processor_id column to civicrm_stripe_customers table.
*
* @return TRUE on success
* @throws Exception
*/
public
function
upgrade_4_6_01
()
{
$procIdCheck
=
mysql_query
(
"SHOW COLUMNS FROM `civicrm_stripe_customers` LIKE 'processor_id'"
);
if
(
mysql_num_rows
(
$procIdCheck
))
{
$this
->
ctx
->
log
->
info
(
'Skipped civicrm_stripe update 4601. Column processor_id already present on civicrm_stripe_customers table.'
);
}
else
{
$this
->
ctx
->
log
->
info
(
'Applying civicrm_stripe update 4601. Adding processor_id to civicrm_stripe_customers table.'
);
CRM_Core_DAO
::
executeQuery
(
'ALTER TABLE civicrm_stripe_customers ADD COLUMN `processor_id` int(10) DEFAULT NULL COMMENT "ID from civicrm_payment_processor"'
);
}
return
TRUE
;
}
}
This diff is collapsed.
Click to expand it.
stripe.php
+
1
−
0
View file @
454c055c
...
...
@@ -32,6 +32,7 @@ function stripe_civicrm_install() {
`email` varchar(64) COLLATE utf8_unicode_ci DEFAULT NULL,
`id` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`is_live` tinyint(4) NOT NULL COMMENT 'Whether this is a live or test transaction',
`processor_id` int(10) DEFAULT NULL COMMENT 'ID from civicrm_payment_processor',
UNIQUE KEY `id` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
"
);
...
...
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