Skip to content
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
10 changes: 8 additions & 2 deletions packages/react-native-payments/lib/js/PaymentRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ export default class PaymentRequest {
constructor(
methodData: Array<PaymentMethodData> = [],
details?: PaymentDetailsInit = [],
options?: PaymentOptions = {}
options?: PaymentOptions = {},
diableInitialUpdate?: bool,
) {
// 1. If the current settings object's responsible document is not allowed to use the feature indicated by attribute name allowpaymentrequest, then throw a " SecurityError" DOMException.
noop();
Expand Down Expand Up @@ -158,6 +159,7 @@ export default class PaymentRequest {

// 9. Let serializedModifierData be an empty list.
let serializedModifierData = [];
//

// 10. Process payment details modifiers:
// TODO
Expand Down Expand Up @@ -197,6 +199,8 @@ export default class PaymentRequest {
? options.shippingType
: null;

// 21. Add option to disable the initial update (to have the ability to trigger it yourself)
this._diableInitialUpdate = diableInitialUpdate
// React Native Payments specific 👇
// ---------------------------------

Expand Down Expand Up @@ -268,7 +272,9 @@ export default class PaymentRequest {
// On iOS, this event fires when the PKPaymentRequest is initialized.
// So on iOS, we track the amount of times `_handleShippingAddressChange` gets called
// and noop the first call.
if (IS_IOS && this._shippingAddressChangesCount === 1) {

// If the disableInitialUpdate is true, we gonna pass down the event on 1st update.
if (IS_IOS && this._shippingAddressChangesCount === 1 && !this._diableInitialUpdate) {
return event.updateWith(this._details);
}

Expand Down