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

Added Shipping Address information in paymentResponse #172

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
26 changes: 26 additions & 0 deletions packages/react-native-payments/lib/ios/ReactNativePayments.m
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,32 @@ - (void)handleUserAccept:(PKPayment *_Nonnull)payment
NSMutableDictionary *paymentResponse = [[NSMutableDictionary alloc]initWithCapacity:3];
[paymentResponse setObject:transactionId forKey:@"transactionIdentifier"];
[paymentResponse setObject:paymentData forKey:@"paymentData"];

PKContact *shippingContact = payment.shippingContact;
if(shippingContact) {

NSMutableDictionary *shippingAddress = [NSMutableDictionary new];
NSPersonNameComponents *presonNameComponent = shippingContact.name;

if (presonNameComponent) {
[shippingAddress setObject:presonNameComponent.namePrefix forKey:@"namePrefix"];
[shippingAddress setObject:presonNameComponent.nameSuffix forKey:@"nameSuffix"];
[shippingAddress setObject:presonNameComponent.givenName forKey:@"givenName"];
[shippingAddress setObject:presonNameComponent.middleName forKey:@"middleName"];
[shippingAddress setObject:presonNameComponent.nickname forKey:@"nickname"];
[shippingAddress setObject:presonNameComponent.familyName forKey:@"familyName"];
}

CNPostalAddress *postalAddess = shippingContact.postalAddress;
if (postalAddess) {
[shippingAddress setObject:postalAddess.street forKey:@"street"];
[shippingAddress setObject:postalAddess.city forKey:@"city"];
[shippingAddress setObject:postalAddess.state forKey:@"state"];
[shippingAddress setObject:postalAddess.postalCode forKey:@"postalCode"];
}

[paymentResponse setObject:shippingAddress forKey:@"shippingAddress"];
}

if (token) {
[paymentResponse setObject:token forKey:@"paymentToken"];
Expand Down