-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathStripe.php
More file actions
113 lines (94 loc) · 4.18 KB
/
Stripe.php
File metadata and controls
113 lines (94 loc) · 4.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<?php
namespace MatchBot\Client;
use MatchBot\Domain\Donation;
use MatchBot\Domain\Money;
use MatchBot\Domain\StripeConfirmationTokenId;
use MatchBot\Domain\StripeCustomerId;
use MatchBot\Domain\StripePaymentMethodId;
use Stripe\BalanceTransaction;
use Stripe\Charge;
use Stripe\Collection;
use Stripe\ConfirmationToken;
use Stripe\Customer;
use Stripe\CustomerSession;
use Stripe\Exception\ApiErrorException;
use Stripe\Exception\InvalidRequestException;
use Stripe\PaymentIntent;
use Stripe\PaymentMethod;
use Stripe\SearchResult;
use Stripe\SetupIntent;
/**
* Abstraction for talking to stripe, either with a real HTTP connection or an imaginary version of stripe for use in
* load tests or any other tests. This interface should generally be used in all other code in preference to
* directly relying on \Stripe\StripeClient.
*
* As well as allowing load tests this should also make writing unit tests a lot easier, as the functions in this
* interface should suit what we can easily mock using e.g. Prophecy much better than the API of Stripe's library.
*/
interface Stripe
{
/**
* @throws ApiErrorException
*/
public function cancelPaymentIntent(string $paymentIntentId): void;
/**
* @throws ApiErrorException
* @param array{amount?: int, currency?: string, metadata?: array<string, mixed>, application_fee_amount?: int, payment_method?: null} $updateData
*/
public function updatePaymentIntent(string $paymentIntentId, array $updateData): void;
/**
* @param array{confirmation_token?: string, off_session?: bool, payment_method?: string, return_url?: string} $params
* @throws ApiErrorException
*/
public function confirmPaymentIntent(string $paymentIntentId, array $params): PaymentIntent;
/**
* @throws ApiErrorException
*/
public function retrievePaymentIntent(string $paymentIntentId): PaymentIntent;
/**
* @param array{
* amount: int,
* currency: string
* } $createPayload
* @throws ApiErrorException
* @throws InvalidRequestException - e.g. if the CVC wasn't collected, presumably due to bots accessing the system.
*/
public function createPaymentIntent(array $createPayload): PaymentIntent;
public function createCustomerSession(StripeCustomerId $stripeCustomerId): CustomerSession;
/**
* Creates a customer session that will save the given payment method for off-session use.
*/
public function createRegularGivingCustomerSession(StripeCustomerId $stripeCustomerId): CustomerSession;
public function retrieveConfirmationToken(StripeConfirmationTokenId $confirmationTokenId): ConfirmationToken;
public function retrieveCharge(string $chargeId): Charge;
public function retrieveBalanceTransaction(string $id): BalanceTransaction;
public function createSetupIntent(StripeCustomerId $stripeCustomerId): SetupIntent;
/**
* Gets a specific Customer's Payment Method which must be attached. Generally for saved methods.
* @link https://docs.stripe.com/api/payment_methods/customer
* @throws InvalidRequestException
*/
public function retrievePaymentMethod(StripeCustomerId $customerId, StripePaymentMethodId $methodId): PaymentMethod;
/**
* Gets a Payment Method that is not necessarily attached to a Customer yet.
* @link https://docs.stripe.com/api/payment_methods/retrieve
* @throws ApiErrorException
*/
public function retrievePendingPaymentMethod(StripePaymentMethodId $methodId): PaymentMethod;
/**
* @throws ApiErrorException
*/
public function detatchPaymentMethod(StripePaymentMethodId $paymentMethodId): void;
/**
* Deletes a given customer from Stripe. (removing their credit card details and prevent operations, although
* not erasing all data)
*
* See https://docs.stripe.com/api/customers/delete
*/
public function deleteCustomer(StripeCustomerId $getStripeCustomerId): void;
/**
* @param array{expand?: array<array-key, string>} $params
*/
public function retrieveCustomer(StripeCustomerId $stripeCustomerId, array $params): Customer;
public function refundCustomerBalance(StripeCustomerId $stripeCustomerId, Money $money): void;
}