Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
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
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
Rich
Stripe
Commits
a5f385de
Commit
a5f385de
authored
6 years ago
by
mattwire
Browse files
Options
Downloads
Patches
Plain Diff
Add StripeCustomer.get API, move customercontactids to StripeCustomer.updatecontactids
parent
052c1f6e
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
CRM/Stripe/Upgrader.php
+1
-1
1 addition, 1 deletion
CRM/Stripe/Upgrader.php
api/v3/StripeCustomer.php
+81
-2
81 additions, 2 deletions
api/v3/StripeCustomer.php
with
82 additions
and
3 deletions
CRM/Stripe/Upgrader.php
+
1
−
1
View file @
a5f385de
...
@@ -378,7 +378,7 @@ class CRM_Stripe_Upgrader extends CRM_Stripe_Upgrader_Base {
...
@@ -378,7 +378,7 @@ class CRM_Stripe_Upgrader extends CRM_Stripe_Upgrader_Base {
}
}
$this
->
ctx
->
log
->
info
(
'Applying Stripe update 5010. Getting Contact IDs for civicrm_stripe_customers.'
);
$this
->
ctx
->
log
->
info
(
'Applying Stripe update 5010. Getting Contact IDs for civicrm_stripe_customers.'
);
civicrm_api3
(
'Stripe
'
,
'c
ustomercontactids'
,
[]);
civicrm_api3
(
'Stripe
C
ustomer
'
,
'update
contactids'
,
[]);
return
TRUE
;
return
TRUE
;
}
}
...
...
This diff is collapsed.
Click to expand it.
api/v3/Stripe
/
Customer
contactids
.php
→
api/v3/StripeCustomer.php
+
81
−
2
View file @
a5f385de
...
@@ -6,7 +6,86 @@
...
@@ -6,7 +6,86 @@
*/
*/
/**
/**
* Stripe.Customer_Contactids API
* 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_get_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
[
'processor_id'
][
'title'
]
=
ts
(
"Payment Processor ID"
);
$spec
[
'processor_id'
][
'type'
]
=
CRM_Utils_Type
::
T_INT
;
}
/**
* StripeCustomer.Get API
* This api will update the civicrm_stripe_customers table and add contact IDs for all known email addresses
*
* @param array $params
* @see civicrm_api3_create_success
*
* @return array
*/
function
civicrm_api3_stripe_customer_get
(
$params
)
{
foreach
(
$params
as
$key
=>
$value
)
{
$index
=
1
;
switch
(
$key
)
{
case
'id'
:
$where
[
$index
]
=
"
{
$key
}
=%
{
$index
}
"
;
$whereParam
[
$index
]
=
[
$value
,
'String'
];
$index
++
;
break
;
case
'contact_id'
:
$where
[
$index
]
=
"
{
$key
}
=%
{
$index
}
"
;
$whereParam
[
$index
]
=
[
$value
,
'Integer'
];
$index
++
;
break
;
case
'is_live'
:
$where
[
$index
]
=
"
{
$key
}
=%
{
$index
}
"
;
$whereParam
[
$index
]
=
[
$value
,
'Boolean'
];
$index
++
;
break
;
case
'processor_id'
:
$where
[
$index
]
=
"
{
$key
}
=%
{
$index
}
"
;
$whereParam
[
$index
]
=
[
$value
,
'Integer'
];
$index
++
;
break
;
}
}
$query
=
"SELECT * FROM civicrm_stripe_customers "
;
if
(
count
(
$where
))
{
$whereClause
=
implode
(
' AND '
,
$where
);
$query
.
=
"WHERE
{
$whereClause
}
"
;
}
$dao
=
CRM_Core_DAO
::
executeQuery
(
$query
,
$whereParam
);
while
(
$dao
->
fetch
())
{
$result
=
[
'id'
=>
$dao
->
id
,
'contact_id'
=>
$dao
->
contact_id
,
'is_live'
=>
$dao
->
is_live
,
'processor_id'
=>
$dao
->
processor_id
,
];
if
(
$dao
->
email
)
{
$result
[
'email'
]
=
$dao
->
email
;
}
$results
[]
=
$result
;
}
return
civicrm_api3_create_success
(
$results
);
}
/**
* 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
*
*
* @param array $params
* @param array $params
...
@@ -14,7 +93,7 @@
...
@@ -14,7 +93,7 @@
*
*
* @return array
* @return array
*/
*/
function
civicrm_api3_stripe_customercontactids
(
$params
)
{
function
civicrm_api3_stripe_customer
_update
contactids
(
$params
)
{
$dao
=
CRM_Core_DAO
::
executeQuery
(
'SELECT email, id FROM civicrm_stripe_customers WHERE contact_id IS NULL'
);
$dao
=
CRM_Core_DAO
::
executeQuery
(
'SELECT email, id FROM civicrm_stripe_customers WHERE contact_id IS NULL'
);
$counts
=
[
$counts
=
[
'updated'
=>
0
,
'updated'
=>
0
,
...
...
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