From 85bae1502547df33048d202f8f8def0cf0f4f755 Mon Sep 17 00:00:00 2001 From: Sandeep Kharbanda <33030857+SandeepKharbanda@users.noreply.github.com> Date: Mon, 12 Aug 2019 14:45:26 +0530 Subject: [PATCH] Added Shipping Address information in paymentResponse in handleUserAccept method --- .../lib/ios/ReactNativePayments.m | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/packages/react-native-payments/lib/ios/ReactNativePayments.m b/packages/react-native-payments/lib/ios/ReactNativePayments.m index 26bc4c2d..89b947d6 100644 --- a/packages/react-native-payments/lib/ios/ReactNativePayments.m +++ b/packages/react-native-payments/lib/ios/ReactNativePayments.m @@ -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"];