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

APM Mobile - Add new API for handling payment method change #1

Merged
merged 3 commits into from
Nov 10, 2021
Merged
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
16 changes: 16 additions & 0 deletions ios/ReactNativePayments.m
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ -(void) paymentAuthorizationViewControllerDidFinish:(PKPaymentAuthorizationViewC

NSArray<PKPaymentSummaryItem *> * paymentSummaryItems = [self getPaymentSummaryItemsFromDetails:details];

if (self.paymentMethodCompletion) {
self.paymentMethodCompletion (paymentSummaryItems);
self.paymentMethodCompletion = nil;
}

if (self.shippingMethodCompletion) {
self.shippingMethodCompletion(
Expand Down Expand Up @@ -214,6 +218,18 @@ - (void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController
}];
}

// Payment method changes
- (void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller
didSelectPaymentMethod:(PKPaymentMethod *)paymentMethod
completion:(nonnull void (^)(NSArray<PKPaymentSummaryItem *> * _Nonnull))completion
{
self.paymentMethodCompletion = completion;
NSString *type = [self paymentMethodTypeToString:paymentMethod.type];

Choose a reason for hiding this comment

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

Do we need to explicitly define paymentMethodTypeToString somewhere?

Copy link
Author

Choose a reason for hiding this comment

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

yes, paymentMethodTypeToString is defined at line 447 in ReactNativePayments.m

[self.bridge.eventDispatcher sendDeviceEventWithName:@"NativePayments:onpaymentmethodchange" body:@{
@"paymentMethodType": type
}];
}

// PRIVATE METHODS
// https://developer.apple.com/reference/passkit/pkpaymentnetwork
// ---------------
Expand Down