Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,10 @@ public static WritableMap putExtraToTokenMap(final WritableMap tokenMap, UserAdd
WritableMap billingContactMap = convertAddressToWritableMap(billingAddress);
WritableMap shippingContactMap = convertAddressToWritableMap(shippingAddress);

billingContactMap.putString("emailAddress", emailAddress);
shippingContactMap.putString("emailAddress", emailAddress);
if (emailAddress != null && emailAddress.length() > 0) {
billingContactMap.putString("emailAddress", emailAddress);
shippingContactMap.putString("emailAddress", emailAddress);
}


extra.putMap("billingContact", billingContactMap);
Expand Down
2 changes: 1 addition & 1 deletion ios/Classes/TPSStripeManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -1646,7 +1646,7 @@ - (NSDictionary *)contactDetails:(PKContact*)inputContact {
[contactDetails setValue:inputContact.supplementarySubLocality forKey:@"supplementarySubLocality"];
}

for (NSString *elem in @[@"street", @"city", @"state", @"country", @"ISOCountryCode", @"postalCode"]) {
for (NSString *elem in @[@"street", @"city", @"state", @"country", @"ISOCountryCode", @"postalCode", @"subAdministrativeArea", @"subLocality", @"formattedAddress"]) {
if ([inputContact.postalAddress respondsToSelector:NSSelectorFromString(elem)]) {
[contactDetails setValue:[inputContact.postalAddress valueForKey:elem] forKey:elem];
}
Expand Down
11 changes: 10 additions & 1 deletion lib/src/stripe_payment.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ class StripePayment {

/// https://tipsi.github.io/tipsi-stripe/docs/usage.html
static void setOptions(StripeOptions settings) {
_channel.invokeMethod('setOptions', {"options": settings.toJson(), "errorCodes": Errors.mapping});
try {
_channel.invokeMethod('setOptions',
{"options": settings.toJson(), "errorCodes": Errors.mapping});
} catch(e) {
print(e);
}
}

/// https://tipsi.github.io/tipsi-stripe/docs/usage.html
Expand Down Expand Up @@ -174,6 +179,10 @@ class StripePayment {
final result = await _channel.invokeMethod('confirmSetupIntent', intent.toJson());
return SetupIntentResult.fromJson(result);
}

static openApplePaySetup() async {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add some information why and where this is needed?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need open ApplePaySetup in somecase and StripePaymentPlugin.m and TPSStripeManager.m implemented this. but I can't call this method and I add openApplePaySetup method in stripe_payment.dart file.

https://github.com/jonasbark/flutter_stripe_payment/blob/master/ios/Classes/StripePaymentPlugin.m#L65
https://github.com/jonasbark/flutter_stripe_payment/blob/master/ios/Classes/TPSStripeManager.m#L877

_channel.invokeMapMethod('openApplePaySetup');
}
}

class StripeOptions {
Expand Down
95 changes: 94 additions & 1 deletion lib/src/token.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ class Token {
double created;
bool livemode;
String tokenId;
Extra extra;

Token({this.bankAccount, this.card, this.created, this.livemode, this.tokenId});
Token({this.bankAccount, this.card, this.created, this.livemode, this.tokenId, this.extra});

factory Token.fromJson(Map<dynamic, dynamic> json) {
return Token(
Expand All @@ -14,6 +15,7 @@ class Token {
created: json['created'] is int ? (json['created'] as int).toDouble() : json['created'],
livemode: json['livemode'],
tokenId: json['tokenId'],
extra: json['extra'] != null ? Extra.fromJson(json['extra']) : null,
);
}

Expand All @@ -28,6 +30,9 @@ class Token {
if (this.card != null) {
data['card'] = this.card.toJson();
}
if (this.extra != null) {
data['extra'] = this.extra.toJson();
}
return data;
}
}
Expand Down Expand Up @@ -164,3 +169,91 @@ class CreditCard {
return data;
}
}

class Extra {
Contact shippingContact;
Contact billingContact;

Extra(
{this.shippingContact,
this.billingContact});

factory Extra.fromJson(Map<dynamic, dynamic> json) {
return Extra(
shippingContact: Contact.fromJson(json['shippingContact']),
billingContact: Contact.fromJson(json['billingContact']),
);
}

Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
if (this.shippingContact != null) data['shippingContact'] = this.shippingContact.toJson();
if (this.billingContact != null) data['billingContact'] = this.billingContact.toJson();
return data;
}
}

class Contact {
String name;
String emailAddress;
String phoneNumber;
String country;
String postalCode;
String state;
String city;
String street;
String isoCountryCode;
String subAdministrativeArea;
String subLocality;
String supplementarySubLocality;

Contact (
{this.name,
this.emailAddress,
this.phoneNumber,
this.country,
this.postalCode,
this.state,
this.city,
this.street,
this.isoCountryCode,
this.subAdministrativeArea,
this.subLocality,
this.supplementarySubLocality
});

factory Contact.fromJson(Map<dynamic, dynamic> json) {
print(json);
return Contact(
name: json['name'] ?? "",
emailAddress: json['emailAddress'] ?? "",
phoneNumber: json['phoneNumber'] ?? "",
country: json['country'] ?? "",
postalCode: json['postalCode'] ?? "",
state: json['state'] ?? json['administrativeArea'] ?? "",
city: json['city'] ?? json['locality'] ?? "",
street: json['street'] ?? json['address1'] != null ? json['address1'] + json['address2'] : "",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The following line breaks with exception:
street: json['street'] ?? json['address1'] != null ? json['address1'] + json['address2'] : "",
_TypeError (type 'String' is not a subtype of type 'bool')

Needs parens, so change to
json['street'] ?? (json['address1'] != null ? json['address1'] + json['address2'] : "")

isoCountryCode: json['ISOCountryCode'] ?? json['countryCode'] ?? "",
subAdministrativeArea: json['subAdministrativeArea'] ?? "",
subLocality: json['subLocality'] ?? json['locality'] ?? "",
supplementarySubLocality: json['supplementarySubLocality'] ?? "",
);
}

Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
if (this.name != null) data['name'] = this.name;
if (this.emailAddress != null) data['emailAddress'] = this.emailAddress;
if (this.phoneNumber != null) data['phoneNumber'] = this.phoneNumber;
if (this.country != null) data['country'] = this.country;
if (this.postalCode != null) data['postalCode'] = this.postalCode;
if (this.state != null) data['state'] = this.state;
if (this.city != null) data['city'] = this.city;
if (this.street != null) data['street'] = this.street;
if (this.isoCountryCode != null) data['ISOCountryCode'] = this.isoCountryCode;
if (this.subAdministrativeArea != null) data['subAdministrativeArea'] = this.subAdministrativeArea;
if (this.subLocality != null) data['subLocality'] = this.subLocality;
if (this.supplementarySubLocality != null) data['supplementarySubLocality'] = this.supplementarySubLocality;
return data;
}
}