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
5ff3615e
Commit
5ff3615e
authored
6 years ago
by
mattwire
Browse files
Options
Downloads
Patches
Plain Diff
Add StripeSubscription.Get API
parent
b6e3ec4c
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!10
5.x noemail noplan
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
api/v3/StripeCustomer.php
+1
-6
1 addition, 6 deletions
api/v3/StripeCustomer.php
api/v3/StripeSubscription.php
+85
-0
85 additions, 0 deletions
api/v3/StripeSubscription.php
with
86 additions
and
6 deletions
api/v3/StripeCustomer.php
+
1
−
6
View file @
5ff3615e
...
...
@@ -43,6 +43,7 @@ function civicrm_api3_stripe_customer_get($params) {
break
;
case
'contact_id'
:
case
'processor_id'
:
$where
[
$index
]
=
"
{
$key
}
=%
{
$index
}
"
;
$whereParam
[
$index
]
=
[
$value
,
'Integer'
];
$index
++
;
...
...
@@ -53,12 +54,6 @@ function civicrm_api3_stripe_customer_get($params) {
$whereParam
[
$index
]
=
[
$value
,
'Boolean'
];
$index
++
;
break
;
case
'processor_id'
:
$where
[
$index
]
=
"
{
$key
}
=%
{
$index
}
"
;
$whereParam
[
$index
]
=
[
$value
,
'Integer'
];
$index
++
;
break
;
}
}
...
...
This diff is collapsed.
Click to expand it.
api/v3/StripeSubscription.php
0 → 100644
+
85
−
0
View file @
5ff3615e
<?php
/**
* Stripe Customer 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_subscription_get_spec
(
&
$spec
)
{
$spec
[
'subscription_id'
][
'title'
]
=
ts
(
"Stripe Subscription ID"
);
$spec
[
'subscription_id'
][
'type'
]
=
CRM_Utils_Type
::
T_STRING
;
$spec
[
'customer_id'
][
'title'
]
=
ts
(
"Stripe Customer ID"
);
$spec
[
'customer_id'
][
'type'
]
=
CRM_Utils_Type
::
T_STRING
;
$spec
[
'contribution_recur_id'
][
'title'
]
=
ts
(
"Contribution Recur ID"
);
$spec
[
'contribution_recur_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
;
$spec
[
'end_time_id'
][
'title'
]
=
ts
(
"End Time"
);
$spec
[
'end_time_id'
][
'type'
]
=
CRM_Utils_Type
::
T_INT
;
}
/**
* StripeSubscription.Get API
* This api will get entries from the civicrm_stripe_subscriptions table
*
* @param array $params
* @see civicrm_api3_create_success
*
* @return array
*/
function
civicrm_api3_stripe_subscription_get
(
$params
)
{
foreach
(
$params
as
$key
=>
$value
)
{
$index
=
1
;
switch
(
$key
)
{
case
'subscription_id'
:
case
'customer_id'
:
$where
[
$index
]
=
"
{
$key
}
=%
{
$index
}
"
;
$whereParam
[
$index
]
=
[
$value
,
'String'
];
$index
++
;
break
;
case
'contribution_recur_id'
:
case
'processor_id'
:
case
'end_time'
:
$where
[
$index
]
=
"
{
$key
}
=%
{
$index
}
"
;
$whereParam
[
$index
]
=
[
$value
,
'Integer'
];
$index
++
;
break
;
case
'is_live'
:
$where
[
$index
]
=
"
{
$key
}
=%
{
$index
}
"
;
$whereParam
[
$index
]
=
[
$value
,
'Boolean'
];
$index
++
;
break
;
}
}
$query
=
"SELECT * FROM civicrm_stripe_subscriptions "
;
if
(
count
(
$where
))
{
$whereClause
=
implode
(
' AND '
,
$where
);
$query
.
=
"WHERE
{
$whereClause
}
"
;
}
$dao
=
CRM_Core_DAO
::
executeQuery
(
$query
,
$whereParam
);
while
(
$dao
->
fetch
())
{
$result
=
[
'subscription_id'
=>
$dao
->
subscription_id
,
'customer_id'
=>
$dao
->
customer_id
,
'contribution_recur_id'
=>
$dao
->
contribution_recur_id
,
'is_live'
=>
$dao
->
is_live
,
'processor_id'
=>
$dao
->
processor_id
,
'end_time'
=>
$dao
->
end_time
,
];
$results
[]
=
$result
;
}
return
civicrm_api3_create_success
(
$results
);
}
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