forked from enyo/stripe-dart
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstripe.dart
81 lines (65 loc) · 2.57 KB
/
stripe.dart
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
library stripe;
import 'package:meta/meta.dart';
import 'src/client.dart';
import 'src/resources/balance_transaction.dart';
import 'src/resources/charge.dart';
import 'src/resources/checkout_session.dart';
import 'src/resources/customer.dart';
import 'src/resources/payment_intent.dart';
import 'src/resources/portal_session.dart';
import 'src/resources/price.dart';
import 'src/resources/product.dart';
import 'src/resources/refund.dart';
import 'src/resources/subscription.dart';
export 'messages.dart';
export 'src/webhook.dart';
/// [Stripe] is the Class that provides the Interface for external calls via the
/// Stripe API.
///
/// Create an instance of this class, and use it like this:
///
/// final stripe = Stripe('privateApiKey');
/// final charge = await stripe.charge.retrieve(chargeId);
class Stripe {
/// Our actual client implementation that communicates with Stripe.
///
/// You should not need to access this, it is mostly exposed for testing, but
/// you can use it to make requests that have not yet been implemented.
final Client client;
/// https://stripe.com/docs/api/checkout/sessions
final CheckoutSessionResource checkoutSession;
/// https://stripe.com/docs/api/billing_portal/sessions
final PortalSessionResource portalSession;
/// https://stripe.com/docs/api/customers
final CustomerResource customer;
/// https://stripe.com/docs/api/refunds
final RefundResource refund;
/// https://stripe.com/docs/api/payment_intents
final PaymentIntentResource paymentIntent;
/// https://stripe.com/docs/api/prices
final PriceResource price;
/// https://stripe.com/docs/api/products
final ProductResource product;
/// https://stripe.com/docs/api/charges
final ChargeResource charge;
/// https://stripe.com/docs/api/subscriptions
final SubscriptionResource subscription;
/// https://stripe.com/docs/api/balance_transactions
final BalanceTransactionResource balanceTransaction;
factory Stripe(String apiKey) {
final client = Client(apiKey: apiKey);
return Stripe.withClient(client);
}
@visibleForTesting
Stripe.withClient(this.client)
: checkoutSession = CheckoutSessionResource(client),
portalSession = PortalSessionResource(client),
customer = CustomerResource(client),
refund = RefundResource(client),
paymentIntent = PaymentIntentResource(client),
price = PriceResource(client),
product = ProductResource(client),
subscription = SubscriptionResource(client),
charge = ChargeResource(client),
balanceTransaction = BalanceTransactionResource(client);
}