tf-checkout-react-native 2.0.0-beta.15 → 2.0.0-beta.17
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.
- package/dist/index.js +11 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +11 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/paymentSheet.ts +18 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tf-checkout-react-native",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.17",
|
|
4
4
|
"description": "TheTicketFairy ReactNative Checkout library",
|
|
5
5
|
"homepage": "https://github.com/theticketfairy/tf-shared-libraries#readme",
|
|
6
6
|
"author": "The Ticket Fairy",
|
package/src/paymentSheet.ts
CHANGED
|
@@ -59,12 +59,21 @@ export const nativeSheetIntentIdentity = (
|
|
|
59
59
|
)
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
/**
|
|
63
|
-
*
|
|
64
|
-
const
|
|
62
|
+
/** Keep the complete original list: the server can enable immediate USD Cash
|
|
63
|
+
* App Pay beside card. Other rails still need their own canonical contract. */
|
|
64
|
+
const nativeSheetMethods = (intent: unknown): boolean => {
|
|
65
65
|
if (!intent || typeof intent !== 'object') return false
|
|
66
66
|
const methods = Object.getOwnPropertyDescriptor(intent, 'paymentMethodTypes')?.value
|
|
67
|
-
|
|
67
|
+
if (!Array.isArray(methods)) return false
|
|
68
|
+
if (methods.length === 1) return methods[0] === 'card'
|
|
69
|
+
const currency = Object.getOwnPropertyDescriptor(intent, 'currency')?.value
|
|
70
|
+
return (
|
|
71
|
+
methods.length === 2 &&
|
|
72
|
+
methods.includes('card') &&
|
|
73
|
+
methods.includes('cashapp') &&
|
|
74
|
+
typeof currency === 'string' &&
|
|
75
|
+
currency.toUpperCase() === 'USD'
|
|
76
|
+
)
|
|
68
77
|
}
|
|
69
78
|
|
|
70
79
|
/** Internal building block. The caller must hold
|
|
@@ -111,7 +120,7 @@ export const createPaymentSheetConfirmation = (
|
|
|
111
120
|
!nativeSheetIntentIdentity(result.paymentIntent, intentId, options.reviewed)
|
|
112
121
|
)
|
|
113
122
|
throw paymentProviderError(NATIVE_SHEET_REVIEW_REQUIRED, 'notStarted')
|
|
114
|
-
if (!
|
|
123
|
+
if (!nativeSheetMethods(result.paymentIntent))
|
|
115
124
|
throw paymentProviderError(NATIVE_SHEET_CARD_FIELD_MESSAGE, 'notStarted', {
|
|
116
125
|
code: NATIVE_SHEET_CARD_FIELD_REQUIRED,
|
|
117
126
|
})
|
|
@@ -126,9 +135,9 @@ export const createPaymentSheetConfirmation = (
|
|
|
126
135
|
defaultBillingDetails: billing,
|
|
127
136
|
customFlow: false,
|
|
128
137
|
allowsDelayedPaymentMethods: false,
|
|
129
|
-
//
|
|
130
|
-
//
|
|
131
|
-
link: { display: sdk.LinkDisplay.
|
|
138
|
+
// Stripe decides whether the original account/session supports card-mode
|
|
139
|
+
// Link. This preference does not add an explicit Link/non-card PI type.
|
|
140
|
+
link: { display: sdk.LinkDisplay.AUTOMATIC },
|
|
132
141
|
})
|
|
133
142
|
if (initialized.error)
|
|
134
143
|
throw paymentProviderError(NATIVE_SHEET_CARD_FIELD_MESSAGE, 'notStarted', {
|
|
@@ -155,7 +164,7 @@ export const createPaymentSheetConfirmation = (
|
|
|
155
164
|
if (
|
|
156
165
|
result.error ||
|
|
157
166
|
!nativeSheetIntentIdentity(result.paymentIntent, intentId, options.reviewed) ||
|
|
158
|
-
!
|
|
167
|
+
!nativeSheetMethods(result.paymentIntent)
|
|
159
168
|
)
|
|
160
169
|
throw paymentProviderError(
|
|
161
170
|
'The original payment could not be verified.',
|