Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retreave shipping address at Apple Pay Native Payment #140

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 6 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
11 changes: 6 additions & 5 deletions lib/src/token.dart
Original file line number Diff line number Diff line change
Expand Up @@ -223,18 +223,19 @@ class Contact {
});

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'] ?? "",
city: json['city'] ?? "",
street: json['street'] ?? "",
isoCountryCode: json['ISOCountryCode'] ?? "",
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'] ?? "",
subLocality: json['subLocality'] ?? json['locality'] ?? "",
supplementarySubLocality: json['supplementarySubLocality'] ?? "",
);
}
Expand Down