@brissoto/pay-react-native 1.6.1 → 1.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,8 +13,8 @@ export declare function pickCountry(view: CheckoutView, clues: CountryClues, cou
13
13
  /**
14
14
  * How the page opens: on the details of the app's preferred method when it
15
15
  * can be paid with, or of the only one that can; else on the methods, on its
16
- * preferred tab. Without one, a payer country with no Mobile Money opens the
17
- * Card tab, when there is a card to pay with.
16
+ * preferred tab. Without one, a payer country with no Mobile Money, or a
17
+ * payment with none at all, opens the Card tab, when there is a card to pay with.
18
18
  */
19
19
  export declare function initialUi(view: CheckoutView, clues: CountryClues): CheckoutUi;
20
20
  /** Which screen shows: the payment's status first, then what the payer is doing. */
@@ -22,8 +22,8 @@ export function pickCountry(view, clues, countries) {
22
22
  /**
23
23
  * How the page opens: on the details of the app's preferred method when it
24
24
  * can be paid with, or of the only one that can; else on the methods, on its
25
- * preferred tab. Without one, a payer country with no Mobile Money opens the
26
- * Card tab, when there is a card to pay with.
25
+ * preferred tab. Without one, a payer country with no Mobile Money, or a
26
+ * payment with none at all, opens the Card tab, when there is a card to pay with.
27
27
  */
28
28
  export function initialUi(view, clues) {
29
29
  const countries = countriesOf(view.methods);
@@ -31,9 +31,12 @@ export function initialUi(view, clues) {
31
31
  const opening = available.find((method) => method.id === view.preferredMethod) ??
32
32
  (available.length === 1 ? available[0] : undefined);
33
33
  const payer = payerCountryOf(view, clues);
34
- const away = !!payer.payerCountry &&
35
- !countries.some((country) => country === payer.payerCountry) &&
36
- view.methods.some((method) => method.kind === MethodKindEnum.CARD);
34
+ const hasCard = view.methods.some((method) => method.kind === MethodKindEnum.CARD);
35
+ // Away: the payer's country has no Mobile Money here, or none has.
36
+ const away = hasCard &&
37
+ (countries.length === 0 ||
38
+ (!!payer.payerCountry &&
39
+ !countries.some((country) => country === payer.payerCountry)));
37
40
  const base = {
38
41
  tab: view.preferredTab ??
39
42
  (away && !view.preferredMethod
@@ -168,8 +171,12 @@ export function deriveCheckout(view, ui, phone) {
168
171
  method.state === MethodStateEnum.AVAILABLE &&
169
172
  method.country === failed?.country &&
170
173
  method.id !== failed.id) ?? null;
174
+ const screen = screenOf(view, ui);
175
+ // On the methods, nothing picked: the payment's amount, never a past attempt's.
176
+ const choosing = screen === CheckoutScreenEnum.FORM ||
177
+ screen === CheckoutScreenEnum.SUBMITTING;
171
178
  return {
172
- screen: screenOf(view, ui),
179
+ screen,
173
180
  countries: countriesOf(view.methods),
174
181
  wallets,
175
182
  cards,
@@ -183,7 +190,10 @@ export function deriveCheckout(view, ui, phone) {
183
190
  canPay: !!selected && missing.length === 0 && !ui.submitting && !ui.cardPaying,
184
191
  detected,
185
192
  total: selected?.price ??
186
- view.attempt?.price ?? { amount: view.amount, currency: view.currency },
193
+ (choosing ? null : view.attempt?.price) ?? {
194
+ amount: view.amount,
195
+ currency: view.currency,
196
+ },
187
197
  // Only a Mobile Money method has a number to belong to another one.
188
198
  mismatch: selected && !onCard && detected && detected.id !== selected.id
189
199
  ? detected
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brissoto/pay-react-native",
3
- "version": "1.6.1",
3
+ "version": "1.6.2",
4
4
  "description": "Brissoto Pay for Expo and React Native apps: the payment sheet.",
5
5
  "license": "MIT",
6
6
  "sideEffects": false,