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
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
cfabcc72
Commit
cfabcc72
authored
4 years ago
by
mattwire
Committed by
mattwire
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add StripeInvoice.process API
parent
449d4c22
No related branches found
No related tags found
1 merge request
!152
6.6 to master
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
api/v3/StripeInvoice.php
+59
-0
59 additions, 0 deletions
api/v3/StripeInvoice.php
with
59 additions
and
0 deletions
api/v3/StripeInvoice.php
0 → 100644
+
59
−
0
View file @
cfabcc72
<?php
/*
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC. All rights reserved. |
| |
| This work is published under the GNU AGPLv3 license with some |
| permitted exceptions and without any warranty. For full license |
| and copyright information, see https://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
use
CRM_Stripe_ExtensionUtil
as
E
;
/**
* Stripe Invoice API
*
*/
/**
* StripeInvoice.Get API specification
*
* @param array $spec description of fields supported by this API call
*/
function
_civicrm_api3_stripe_invoice_process_spec
(
&
$spec
)
{
$spec
[
'invoice_id'
][
'title'
]
=
E
::
ts
(
'Stripe Invoice ID'
);
$spec
[
'invoice_id'
][
'type'
]
=
CRM_Utils_Type
::
T_STRING
;
$spec
[
'payment_processor_id'
][
'title'
]
=
E
::
ts
(
'Payment Processor ID'
);
$spec
[
'payment_processor_id'
][
'type'
]
=
CRM_Utils_Type
::
T_INT
;
$spec
[
'is_email_receipt'
][
'title'
]
=
E
::
ts
(
'Send Email Receipt'
);
$spec
[
'is_email_receipt'
][
'type'
]
=
CRM_Utils_Type
::
T_BOOLEAN
;
}
function
civicrm_api3_stripe_invoice_process
(
$params
)
{
$ipnClass
=
new
CRM_Core_Payment_StripeIPN
();
$ipnClass
->
setPaymentProcessor
(
$params
[
'payment_processor_id'
]);
$stripeInvoiceObject
=
$ipnClass
->
getPaymentProcessor
()
->
stripeClient
->
invoices
->
retrieve
(
$params
[
'invoice_id'
]);
if
(
$stripeInvoiceObject
->
paid
===
TRUE
)
{
$ipnClass
->
setEventID
(
'invoice'
);
$ipnClass
->
setEventType
(
'invoice.payment_succeeded'
);
$ipnClass
->
setVerifyData
(
FALSE
);
$ipnClass
->
setData
((
Object
)
[
'object'
=>
$stripeInvoiceObject
]);
$ipnClass
->
setExceptionMode
(
FALSE
);
if
(
isset
(
$emailReceipt
))
{
$ipnClass
->
setSendEmailReceipt
(
$params
[
'is_email_receipt'
]
??
NULL
);
}
if
(
$ipnClass
->
processWebhook
())
{
return
civicrm_api3_create_success
([
TRUE
],
$params
);
}
else
{
return
civicrm_api3_create_error
(
'Failed to process invoice'
);
}
}
else
{
return
civicrm_api3_create_error
(
'Invoice not paid'
);
}
}
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