File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -53,6 +53,7 @@ part 'src/messages/requests/update_subscription.dart';
5353part 'src/messages/requests/update_subscription_item.dart' ;
5454part 'src/messages/requests/update_subscription_schedule.dart' ;
5555part 'src/messages/shipping_specification.dart' ;
56+ part 'src/messages/source.dart' ;
5657part 'src/messages/stripe_api_error.dart' ;
5758part 'src/messages/subscription.dart' ;
5859part 'src/messages/subscription_item.dart' ;
Original file line number Diff line number Diff line change @@ -4,3 +4,5 @@ export 'enums/payment_behavior.dart';
44export 'enums/proration_behavior.dart' ;
55export 'enums/stripe_api_error_type.dart' ;
66export 'enums/pause_collection_behavior.dart' ;
7+ export 'enums/source_type.dart' ;
8+ export 'enums/source_status.dart' ;
Original file line number Diff line number Diff line change 1+ import 'package:json_annotation/json_annotation.dart' ;
2+
3+ @Deprecated ('''Stripe doesn't recommend using the deprecated Sources API.
4+ We recommend that you adopt the PaymentMethods API.
5+ This newer API provides access to our latest features and payment method types.
6+ ''' )
7+ enum SourceStatus {
8+ @JsonValue ('canceled' )
9+ canceled,
10+ @JsonValue ('chargeable' )
11+ chargeable,
12+ @JsonValue ('consumed' )
13+ consumed,
14+ @JsonValue ('failed' )
15+ failed,
16+ @JsonValue ('pending' )
17+ pending,
18+ }
Original file line number Diff line number Diff line change 1+ import 'package:json_annotation/json_annotation.dart' ;
2+
3+ @Deprecated ('''Stripe doesn't recommend using the deprecated Sources API.
4+ We recommend that you adopt the PaymentMethods API.
5+ This newer API provides access to our latest features and payment method types.
6+ ''' )
7+ enum SourceType {
8+ @JsonValue ('ach_credit_transfer' )
9+ achCreditTransfer,
10+ @JsonValue ('ach_debit' )
11+ achDebit,
12+ @JsonValue ('alipay' )
13+ alipay,
14+ @JsonValue ('bancontact' )
15+ bancontact,
16+ @JsonValue ('card' )
17+ card,
18+ @JsonValue ('card_present' )
19+ cardPresent,
20+ @JsonValue ('eps' )
21+ eps,
22+ @JsonValue ('giropay' )
23+ giropay,
24+ @JsonValue ('ideal' )
25+ ideal,
26+ @JsonValue ('multibanco' )
27+ multibanco,
28+ @JsonValue ('klarna' )
29+ klarna,
30+ @JsonValue ('p24' )
31+ p24,
32+ @JsonValue ('sepa_debit' )
33+ sepaDebit,
34+ @JsonValue ('sofort' )
35+ sofort,
36+ @JsonValue ('three_d_secure' )
37+ threeDSecure,
38+ @JsonValue ('wechat' )
39+ wechat,
40+ }
Original file line number Diff line number Diff line change 1+ part of '../../messages.dart' ;
2+
3+ /// Source objects allow you to accept a variety of payment methods.
4+ /// They represent a customer’s payment instrument,
5+ /// and can be used with the Stripe API just like a Card object:
6+ /// once chargeable, they can be charged, or can be attached to customers.
7+ @Deprecated ('''Stripe doesn't recommend using the deprecated Sources API.
8+ We recommend that you adopt the PaymentMethods API.
9+ This newer API provides access to our latest features and payment method types.
10+ ''' )
11+ @JsonSerializable ()
12+ class Source extends Message {
13+ final String id;
14+ final String object;
15+ final int ? amount;
16+
17+ @TimestampConverter ()
18+ final DateTime created;
19+ final String ? currency;
20+ final String ? customer;
21+ final String ? flow;
22+ final bool livemode;
23+ final String ? statementDescriptor;
24+ final String status;
25+ final SourceType type;
26+ final String usage;
27+
28+ const Source ({
29+ required this .id,
30+ required this .object,
31+ required this .amount,
32+ required this .created,
33+ required this .currency,
34+ required this .customer,
35+ required this .flow,
36+ required this .livemode,
37+ required this .statementDescriptor,
38+ required this .status,
39+ required this .type,
40+ required this .usage,
41+ });
42+
43+ factory Source .fromJson (Map <String , dynamic > json) => _$SourceFromJson (json);
44+
45+ @override
46+ Map <String , dynamic > toJson () => _$SourceToJson (this );
47+ }
Original file line number Diff line number Diff line change 11import 'dart:async' ;
22
33import 'package:stripe/messages.dart' ;
4+ import 'package:stripe/src/resources/source.dart' ;
45
56import '../client.dart' ;
67import '_resource.dart' ;
78
89class CustomerResource extends Resource <Customer > {
9- CustomerResource (Client client) : super (client);
10+ final Client _client;
11+
12+ CustomerResource (Client client)
13+ : _client = client,
14+ super (client);
1015
1116 Future <Customer > create (CreateCustomerRequest request) async {
1217 final response = await post ('customers' , data: request.toJson ());
@@ -40,4 +45,12 @@ class CustomerResource extends Resource<Customer> {
4045
4146 return customer;
4247 }
48+
49+ @Deprecated ('''Stripe doesn't recommend using the deprecated Sources API.
50+ We recommend that you adopt the PaymentMethods API.
51+ This newer API provides access to our latest features and payment method types.
52+ ''' )
53+ SourceResource sources (String customerId) {
54+ return SourceResource (_client, customerId);
55+ }
4356}
Original file line number Diff line number Diff line change 1+ import 'dart:async' ;
2+
3+ import 'package:stripe/messages.dart' ;
4+
5+ import '../client.dart' ;
6+ import '_resource.dart' ;
7+
8+ /// Source objects allow you to accept a variety of payment methods.
9+ /// They represent a customer’s payment instrument,
10+ /// and can be used with the Stripe API just like a Card object:
11+ /// once chargeable, they can be charged, or can be attached to customers.
12+ @Deprecated ('''Stripe doesn't recommend using the deprecated Sources API.
13+ We recommend that you adopt the PaymentMethods API.
14+ This newer API provides access to our latest features and payment method types.
15+ ''' )
16+ class SourceResource extends Resource <Subscription > {
17+ final String customerId;
18+
19+ String get _resourcePath => 'customers/$customerId /sources' ;
20+
21+ SourceResource (Client client, this .customerId) : super (client);
22+
23+ Future <DataList <Source >> list () async {
24+ final map = await get (_resourcePath);
25+ return DataList <Source >.fromJson (
26+ map, (value) => Source .fromJson (value as Map <String , dynamic >));
27+ }
28+ }
You can’t perform that action at this time.
0 commit comments