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
8a06d51e
Commit
8a06d51e
authored
6 years ago
by
mattwire
Browse files
Options
Downloads
Patches
Plain Diff
Add StripeCustomer.delete to delete a customer from CiviCRM
parent
3d22e522
No related branches found
No related tags found
1 merge request
!23
Bugfixes - detect webform correctly, fix stripe customer creation in test mode
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CRM/Stripe/Customer.php
+21
-7
21 additions, 7 deletions
CRM/Stripe/Customer.php
api/v3/StripeCustomer.php
+35
-0
35 additions, 0 deletions
api/v3/StripeCustomer.php
with
56 additions
and
7 deletions
CRM/Stripe/Customer.php
+
21
−
7
View file @
8a06d51e
...
@@ -161,20 +161,34 @@ class CRM_Stripe_Customer {
...
@@ -161,20 +161,34 @@ class CRM_Stripe_Customer {
* @throws \Civi\Payment\Exception\PaymentProcessorException
* @throws \Civi\Payment\Exception\PaymentProcessorException
*/
*/
public
static
function
delete
(
$params
)
{
public
static
function
delete
(
$params
)
{
$requiredParams
=
[
'contact_id'
,
'is_live'
,
'processor_id'
];
$requiredParams
=
[
'is_live'
,
'processor_id'
];
foreach
(
$requiredParams
as
$required
)
{
foreach
(
$requiredParams
as
$required
)
{
if
(
empty
(
$required
))
{
if
(
empty
(
$required
))
{
throw
new
\Civi\Payment\Exception\PaymentProcessorException
(
'Stripe Customer (delete): Missing required parameter: '
.
$required
);
throw
new
\Civi\Payment\Exception\PaymentProcessorException
(
'Stripe Customer (delete): Missing required parameter: '
.
$required
);
}
}
}
}
if
(
empty
(
$params
[
'contact_id'
])
&&
empty
(
$params
[
'id'
]))
{
throw
new
\Civi\Payment\Exception\PaymentProcessorException
(
'Stripe Customer (delete): Missing required parameter: contact_id or id'
);
}
$queryParams
=
[
if
(
!
empty
(
$params
[
'id'
]))
{
1
=>
[
$params
[
'contact_id'
],
'String'
],
$queryParams
=
[
2
=>
[
$params
[
'is_live'
]
?
1
:
0
,
'Boolean'
],
1
=>
[
$params
[
'id'
],
'String'
],
3
=>
[
$params
[
'processor_id'
],
'Integer'
],
2
=>
[
$params
[
'is_live'
]
?
1
:
0
,
'Boolean'
],
];
3
=>
[
$params
[
'processor_id'
],
'Integer'
],
$sql
=
"DELETE FROM civicrm_stripe_customers
];
$sql
=
"DELETE FROM civicrm_stripe_customers
WHERE id = %1 AND is_live = %2 AND processor_id = %3"
;
}
else
{
$queryParams
=
[
1
=>
[
$params
[
'contact_id'
],
'String'
],
2
=>
[
$params
[
'is_live'
]
?
1
:
0
,
'Boolean'
],
3
=>
[
$params
[
'processor_id'
],
'Integer'
],
];
$sql
=
"DELETE FROM civicrm_stripe_customers
WHERE contact_id = %1 AND is_live = %2 AND processor_id = %3"
;
WHERE contact_id = %1 AND is_live = %2 AND processor_id = %3"
;
}
CRM_Core_DAO
::
executeQuery
(
$sql
,
$queryParams
);
CRM_Core_DAO
::
executeQuery
(
$sql
,
$queryParams
);
}
}
...
...
This diff is collapsed.
Click to expand it.
api/v3/StripeCustomer.php
+
35
−
0
View file @
8a06d51e
...
@@ -81,6 +81,41 @@ function civicrm_api3_stripe_customer_get($params) {
...
@@ -81,6 +81,41 @@ function civicrm_api3_stripe_customer_get($params) {
return
civicrm_api3_create_success
(
$results
);
return
civicrm_api3_create_success
(
$results
);
}
}
/**
* StripeCustomer.Get API specification
*
* @param array $spec description of fields supported by this API call
* @return void
* @see http://wiki.civicrm.org/confluence/display/CRMDOC/API+Architecture+Standards
*/
function
_civicrm_api3_stripe_customer_delete_spec
(
&
$spec
)
{
$spec
[
'id'
][
'title'
]
=
ts
(
"Stripe Customer ID"
);
$spec
[
'id'
][
'type'
]
=
CRM_Utils_Type
::
T_STRING
;
$spec
[
'contact_id'
][
'title'
]
=
ts
(
"CiviCRM Contact ID"
);
$spec
[
'contact_id'
][
'type'
]
=
CRM_Utils_Type
::
T_INT
;
$spec
[
'is_live'
][
'title'
]
=
ts
(
"Is live processor"
);
$spec
[
'is_live'
][
'type'
]
=
CRM_Utils_Type
::
T_BOOLEAN
;
$spec
[
'is_live'
][
'api.required'
]
=
TRUE
;
$spec
[
'processor_id'
][
'title'
]
=
ts
(
"Payment Processor ID"
);
$spec
[
'processor_id'
][
'type'
]
=
CRM_Utils_Type
::
T_INT
;
$spec
[
'processor_id'
][
'api.required'
]
=
TRUE
;
}
/**
* StripeCustomer.delete API
* This api will delete a stripe customer from CiviCRM
*
* @param array $params
* @see civicrm_api3_create_success
*
* @throws \Civi\Payment\Exception\PaymentProcessorException
* @return array
*/
function
civicrm_api3_stripe_customer_delete
(
$params
)
{
CRM_Stripe_Customer
::
delete
(
$params
);
return
civicrm_api3_create_success
([]);
}
/**
/**
* Stripe.Customer.Updatecontactids API
* Stripe.Customer.Updatecontactids API
* This api will update the civicrm_stripe_customers table and add contact IDs for all known email addresses
* This api will update the civicrm_stripe_customers table and add contact IDs for all known email addresses
...
...
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