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

Fix paymentToken issue #21

Closed
wants to merge 2 commits into from
Closed
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
5 changes: 1 addition & 4 deletions packages/react-native-payments/lib/ios/ReactNativePayments.m
Original file line number Diff line number Diff line change
Expand Up @@ -318,10 +318,7 @@ - (void)handleUserAccept:(PKPayment *_Nonnull)payment
NSMutableDictionary *paymentResponse = [[NSMutableDictionary alloc]initWithCapacity:3];
[paymentResponse setObject:transactionId forKey:@"transactionIdentifier"];
[paymentResponse setObject:paymentData forKey:@"paymentData"];

if (token) {
[paymentResponse setObject:token forKey:@"paymentToken"];
}
[paymentResponse setObject:(token) ? (token) : (nil) forKey:@"paymentToken"];

[self.bridge.eventDispatcher sendDeviceEventWithName:@"NativePayments:onuseraccept"
body:paymentResponse
Expand Down
16 changes: 11 additions & 5 deletions packages/react-native-payments/lib/js/PaymentRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,25 +295,29 @@ export default class PaymentRequest {

_getPlatformDetailsIOS(details: {
transactionIdentifier: string,
paymentData: string
paymentData: string,
paymentToken: string,
}) {
const {
transactionIdentifier,
paymentData: serializedPaymentData
paymentData: serializedPaymentData,
paymentToken
} = details;
const isSimulator = transactionIdentifier === 'Simulated Identifier';

if (isSimulator) {
return Object.assign({}, details, {
paymentData: null,
serializedPaymentData
paymentToken: null,
serializedPaymentData,
});
}

return {
transactionIdentifier,
paymentData: JSON.parse(serializedPaymentData),
serializedPaymentData
paymentToken: paymentToken,
serializedPaymentData,
};
}

Expand Down Expand Up @@ -345,7 +349,8 @@ export default class PaymentRequest {
transactionIdentifier: string,
paymentData: string,
shippingAddress: object,
payerEmail: string
payerEmail: string,
paymentToken: string
}) {
// On Android, we don't have `onShippingAddressChange` events, so we
// set the shipping address when the user accepts.
Expand All @@ -365,6 +370,7 @@ export default class PaymentRequest {
shippingOption: IS_IOS ? this._shippingOption : null,
payerName: this._options.requestPayerName ? this._shippingAddress.recipient : null,
payerPhone: this._options.requestPayerPhone ? this._shippingAddress.phone : null,
paymentToken: details.paymentToken,
payerEmail: IS_ANDROID && this._options.requestPayerEmail
? details.payerEmail
: null
Expand Down