@stripe/stripe-react-native 0.71.0 → 0.72.0
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/android/gradle.properties +1 -1
- package/android/src/main/java/com/reactnativestripesdk/CurrencySelectorElementView.kt +7 -103
- package/android/src/main/java/com/reactnativestripesdk/CurrencySelectorElementViewManager.kt +1 -5
- package/android/src/main/java/com/reactnativestripesdk/EmbeddedPaymentElementView.kt +0 -26
- package/android/src/main/java/com/reactnativestripesdk/EmbeddedPaymentElementViewManager.kt +6 -21
- package/android/src/main/java/com/reactnativestripesdk/LinkControllerManager.kt +59 -18
- package/android/src/main/java/com/reactnativestripesdk/PaymentMethodCreateParamsFactory.kt +14 -0
- package/android/src/main/java/com/reactnativestripesdk/PaymentSheetManager.kt +6 -50
- package/android/src/main/java/com/reactnativestripesdk/StripeSdkModule.kt +38 -187
- package/android/src/main/java/com/reactnativestripesdk/utils/Mappers.kt +2 -0
- package/android/src/oldarch/java/com/reactnativestripesdk/NativeStripeSdkModuleSpec.java +4 -0
- package/android/src/onramp/java/com/reactnativestripesdk/OnrampMappers.kt +1 -0
- package/android/src/test/java/com/reactnativestripesdk/mappers/MappersTest.kt +0 -60
- package/ios/CurrencySelectorElementView.swift +18 -129
- package/ios/Mappers.swift +2 -0
- package/ios/PaymentMethodFactory.swift +14 -1
- package/ios/StripeSdk.mm +7 -0
- package/ios/StripeSdkImpl+Checkout.swift +35 -259
- package/ios/StripeSdkImpl+Embedded.swift +5 -28
- package/ios/StripeSdkImpl+LinkController.swift +40 -2
- package/ios/StripeSdkImpl+PaymentSheet.swift +2 -15
- package/ios/StripeSdkImpl.swift +2 -4
- package/lib/commonjs/connect/EmbeddedComponent.js +2 -2
- package/lib/commonjs/connect/EmbeddedComponent.js.map +1 -1
- package/lib/commonjs/functions.js +1 -1
- package/lib/commonjs/functions.js.map +1 -1
- package/lib/commonjs/hooks/useLinkController.js +1 -1
- package/lib/commonjs/hooks/useLinkController.js.map +1 -1
- package/lib/commonjs/specs/NativeStripeSdkModule.js.map +1 -1
- package/lib/commonjs/types/PaymentIntent.js.map +1 -1
- package/lib/module/connect/EmbeddedComponent.js +2 -2
- package/lib/module/connect/EmbeddedComponent.js.map +1 -1
- package/lib/module/functions.js +1 -1
- package/lib/module/functions.js.map +1 -1
- package/lib/module/hooks/useLinkController.js +1 -1
- package/lib/module/hooks/useLinkController.js.map +1 -1
- package/lib/module/specs/NativeStripeSdkModule.js.map +1 -1
- package/lib/module/types/PaymentIntent.js.map +1 -1
- package/lib/typescript/src/connect/EmbeddedComponent.d.ts +1 -0
- package/lib/typescript/src/connect/EmbeddedComponent.d.ts.map +1 -1
- package/lib/typescript/src/functions.d.ts +11 -0
- package/lib/typescript/src/functions.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useLinkController.d.ts +7 -0
- package/lib/typescript/src/hooks/useLinkController.d.ts.map +1 -1
- package/lib/typescript/src/specs/NativeStripeSdkModule.d.ts +4 -0
- package/lib/typescript/src/specs/NativeStripeSdkModule.d.ts.map +1 -1
- package/lib/typescript/src/types/LinkController.d.ts +10 -5
- package/lib/typescript/src/types/LinkController.d.ts.map +1 -1
- package/lib/typescript/src/types/PaymentIntent.d.ts +9 -1
- package/lib/typescript/src/types/PaymentIntent.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/connect/EmbeddedComponent.tsx +14 -2
- package/src/functions.ts +26 -0
- package/src/hooks/useLinkController.tsx +24 -1
- package/src/specs/NativeStripeSdkModule.ts +5 -0
- package/src/types/LinkController.ts +9 -5
- package/src/types/PaymentIntent.ts +11 -1
- package/stripe-react-native.podspec +1 -1
- package/android/src/main/java/com/reactnativestripesdk/CurrencySelectorAppearance.kt +0 -229
- package/android/src/main/java/com/reactnativestripesdk/utils/CheckoutAddressUpdate.kt +0 -45
- package/android/src/main/java/com/reactnativestripesdk/utils/CheckoutMappers.kt +0 -127
- package/android/src/test/java/com/reactnativestripesdk/CurrencySelectorAppearanceTest.kt +0 -137
- package/android/src/test/java/com/reactnativestripesdk/utils/CheckoutMappersTest.kt +0 -98
- package/android/src/test/java/com/reactnativestripesdk/utils/CheckoutTestFixtures.java +0 -57
- package/ios/CurrencySelectorAppearance.swift +0 -120
- package/ios/Mappers+Checkout.swift +0 -337
|
@@ -1,337 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Mappers+Checkout.swift
|
|
3
|
-
// stripe-react-native
|
|
4
|
-
//
|
|
5
|
-
// Created by Nick Porter on 4/29/26.
|
|
6
|
-
//
|
|
7
|
-
|
|
8
|
-
import Foundation
|
|
9
|
-
@_spi(ReactNativeSDK) import StripePaymentSheet
|
|
10
|
-
|
|
11
|
-
extension Mappers {
|
|
12
|
-
|
|
13
|
-
// MARK: - State & Session
|
|
14
|
-
|
|
15
|
-
class func mapFromCheckoutState(isLoading: Bool, session: Checkout.Session) -> NSDictionary {
|
|
16
|
-
[
|
|
17
|
-
"status": isLoading ? "loading" : "loaded",
|
|
18
|
-
"session": mapFromCheckoutSession(session),
|
|
19
|
-
]
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
class func mapFromCheckoutSession(_ session: Checkout.Session) -> NSDictionary {
|
|
23
|
-
let result = NSMutableDictionary()
|
|
24
|
-
result["id"] = session.id
|
|
25
|
-
result["livemode"] = session.livemode
|
|
26
|
-
result["lineItems"] = session.lineItems.map(mapFromLineItem)
|
|
27
|
-
result["shippingOptions"] = session.shippingOptions.map(mapFromShippingOption)
|
|
28
|
-
result["discountAmounts"] = session.discountAmounts.map(mapFromDiscountAmount)
|
|
29
|
-
result["currencyOptions"] = session.currencyOptions.map(mapFromCurrencyOption)
|
|
30
|
-
result["tax"] = mapFromTax(session.tax)
|
|
31
|
-
|
|
32
|
-
if let businessName = session.businessName {
|
|
33
|
-
result["businessName"] = businessName
|
|
34
|
-
}
|
|
35
|
-
if let currency = session.currency {
|
|
36
|
-
result["currency"] = currency
|
|
37
|
-
}
|
|
38
|
-
if let email = session.email {
|
|
39
|
-
result["email"] = email
|
|
40
|
-
}
|
|
41
|
-
if let minorUnitsAmountDivisor = session.minorUnitsAmountDivisor {
|
|
42
|
-
result["minorUnitsAmountDivisor"] = minorUnitsAmountDivisor
|
|
43
|
-
}
|
|
44
|
-
if let status = session.status {
|
|
45
|
-
result["status"] = mapFromStatus(status)
|
|
46
|
-
}
|
|
47
|
-
if let total = session.total {
|
|
48
|
-
result["total"] = mapFromTotal(total)
|
|
49
|
-
}
|
|
50
|
-
if let shipping = session.shipping {
|
|
51
|
-
result["shipping"] = mapFromSelectedShipping(shipping)
|
|
52
|
-
}
|
|
53
|
-
if let billingAddress = session.billingAddress {
|
|
54
|
-
result["billingAddress"] = mapFromContactAddress(billingAddress)
|
|
55
|
-
}
|
|
56
|
-
if let shippingAddress = session.shippingAddress {
|
|
57
|
-
result["shippingAddress"] = mapFromContactAddress(shippingAddress)
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return result
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// MARK: - Amount
|
|
64
|
-
|
|
65
|
-
class func mapFromAmount(_ amount: Checkout.Amount) -> NSDictionary {
|
|
66
|
-
[
|
|
67
|
-
"amount": amount.amount,
|
|
68
|
-
"minorUnitsAmount": amount.minorUnitsAmount,
|
|
69
|
-
]
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
class func mapFromDecimalAmount(_ decimalAmount: Checkout.DecimalAmount) -> NSDictionary {
|
|
73
|
-
[
|
|
74
|
-
"amount": decimalAmount.amount,
|
|
75
|
-
"minorUnitsAmount": NSDecimalNumber(decimal: decimalAmount.minorUnitsAmount).doubleValue,
|
|
76
|
-
]
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// MARK: - Status
|
|
80
|
-
|
|
81
|
-
class func mapFromStatus(_ status: Checkout.Status) -> NSDictionary {
|
|
82
|
-
let result = NSMutableDictionary()
|
|
83
|
-
result["type"] = mapFromStatusType(status.type)
|
|
84
|
-
|
|
85
|
-
if let paymentStatus = status.paymentStatus {
|
|
86
|
-
result["paymentStatus"] = mapFromPaymentStatus(paymentStatus)
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
return result
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
private class func mapFromStatusType(_ type: Checkout.StatusType) -> String {
|
|
93
|
-
switch type {
|
|
94
|
-
case .open: return "open"
|
|
95
|
-
case .complete: return "complete"
|
|
96
|
-
case .expired: return "expired"
|
|
97
|
-
case .unknown: return "unknown"
|
|
98
|
-
@unknown default: return "unknown"
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
private class func mapFromPaymentStatus(_ paymentStatus: Checkout.PaymentStatus) -> String {
|
|
103
|
-
switch paymentStatus {
|
|
104
|
-
case .paid: return "paid"
|
|
105
|
-
case .unpaid: return "unpaid"
|
|
106
|
-
case .noPaymentRequired: return "noPaymentRequired"
|
|
107
|
-
case .unknown: return "unknown"
|
|
108
|
-
@unknown default: return "unknown"
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
// MARK: - Total
|
|
113
|
-
|
|
114
|
-
class func mapFromTotal(_ total: Checkout.Total) -> NSDictionary {
|
|
115
|
-
[
|
|
116
|
-
"subtotal": mapFromAmount(total.subtotal),
|
|
117
|
-
"taxExclusive": mapFromAmount(total.taxExclusive),
|
|
118
|
-
"taxInclusive": mapFromAmount(total.taxInclusive),
|
|
119
|
-
"shippingRate": mapFromAmount(total.shippingRate),
|
|
120
|
-
"discount": mapFromAmount(total.discount),
|
|
121
|
-
"total": mapFromAmount(total.total),
|
|
122
|
-
"appliedBalance": mapFromAmount(total.appliedBalance),
|
|
123
|
-
"balanceAppliedToNextInvoice": total.balanceAppliedToNextInvoice,
|
|
124
|
-
]
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
// MARK: - Tax
|
|
128
|
-
|
|
129
|
-
class func mapFromTax(_ tax: Checkout.Tax) -> NSDictionary {
|
|
130
|
-
let result = NSMutableDictionary()
|
|
131
|
-
result["status"] = mapFromTaxStatus(tax.status)
|
|
132
|
-
|
|
133
|
-
if let taxAmounts = tax.taxAmounts {
|
|
134
|
-
result["taxAmounts"] = taxAmounts.map(mapFromTaxAmount)
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
return result
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
private class func mapFromTaxStatus(_ status: Checkout.TaxStatus) -> String {
|
|
141
|
-
switch status {
|
|
142
|
-
case .ready: return "ready"
|
|
143
|
-
case .requiresShippingAddress: return "requiresShippingAddress"
|
|
144
|
-
case .requiresBillingAddress: return "requiresBillingAddress"
|
|
145
|
-
case .unknown: return "unknown"
|
|
146
|
-
@unknown default: return "unknown"
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
private class func mapFromTaxAmount(_ taxAmount: Checkout.TaxAmount) -> NSDictionary {
|
|
151
|
-
[
|
|
152
|
-
"amount": mapFromAmount(taxAmount.amount),
|
|
153
|
-
"inclusive": taxAmount.inclusive,
|
|
154
|
-
"displayName": taxAmount.displayName,
|
|
155
|
-
]
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
// MARK: - Line Items
|
|
159
|
-
|
|
160
|
-
class func mapFromLineItem(_ lineItem: Checkout.LineItem) -> NSDictionary {
|
|
161
|
-
let result = NSMutableDictionary()
|
|
162
|
-
result["id"] = lineItem.id
|
|
163
|
-
result["name"] = lineItem.name
|
|
164
|
-
result["images"] = lineItem.images
|
|
165
|
-
result["quantity"] = lineItem.quantity
|
|
166
|
-
result["discountAmounts"] = lineItem.discountAmounts.map(mapFromDiscountAmount)
|
|
167
|
-
result["taxAmounts"] = lineItem.taxAmounts.map(mapFromTaxAmount)
|
|
168
|
-
|
|
169
|
-
if let description = lineItem.description {
|
|
170
|
-
result["description"] = description
|
|
171
|
-
}
|
|
172
|
-
if let unitAmount = lineItem.unitAmount {
|
|
173
|
-
result["unitAmount"] = mapFromAmount(unitAmount)
|
|
174
|
-
}
|
|
175
|
-
if let unitAmountDecimal = lineItem.unitAmountDecimal {
|
|
176
|
-
result["unitAmountDecimal"] = mapFromDecimalAmount(unitAmountDecimal)
|
|
177
|
-
}
|
|
178
|
-
if let subtotal = lineItem.subtotal {
|
|
179
|
-
result["subtotal"] = mapFromAmount(subtotal)
|
|
180
|
-
}
|
|
181
|
-
if let discount = lineItem.discount {
|
|
182
|
-
result["discount"] = mapFromAmount(discount)
|
|
183
|
-
}
|
|
184
|
-
if let taxExclusive = lineItem.taxExclusive {
|
|
185
|
-
result["taxExclusive"] = mapFromAmount(taxExclusive)
|
|
186
|
-
}
|
|
187
|
-
if let taxInclusive = lineItem.taxInclusive {
|
|
188
|
-
result["taxInclusive"] = mapFromAmount(taxInclusive)
|
|
189
|
-
}
|
|
190
|
-
if let total = lineItem.total {
|
|
191
|
-
result["total"] = mapFromAmount(total)
|
|
192
|
-
}
|
|
193
|
-
if let adjustableQuantity = lineItem.adjustableQuantity {
|
|
194
|
-
result["adjustableQuantity"] = mapFromAdjustableQuantity(adjustableQuantity)
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
return result
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
private class func mapFromAdjustableQuantity(_ adjustableQuantity: Checkout.AdjustableQuantity) -> NSDictionary {
|
|
201
|
-
[
|
|
202
|
-
"minimum": adjustableQuantity.minimum,
|
|
203
|
-
"maximum": adjustableQuantity.maximum,
|
|
204
|
-
]
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
// MARK: - Shipping
|
|
208
|
-
|
|
209
|
-
class func mapFromShippingOption(_ shippingOption: Checkout.ShippingOption) -> NSDictionary {
|
|
210
|
-
let result = NSMutableDictionary()
|
|
211
|
-
result["id"] = shippingOption.id
|
|
212
|
-
result["amount"] = mapFromAmount(shippingOption.amount)
|
|
213
|
-
result["currency"] = shippingOption.currency
|
|
214
|
-
|
|
215
|
-
if let displayName = shippingOption.displayName {
|
|
216
|
-
result["displayName"] = displayName
|
|
217
|
-
}
|
|
218
|
-
if let deliveryEstimate = shippingOption.deliveryEstimate {
|
|
219
|
-
result["deliveryEstimate"] = mapFromDeliveryEstimate(deliveryEstimate)
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
return result
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
private class func mapFromDeliveryEstimate(_ estimate: Checkout.DeliveryEstimate) -> NSDictionary {
|
|
226
|
-
let result = NSMutableDictionary()
|
|
227
|
-
|
|
228
|
-
if let minimum = estimate.minimum {
|
|
229
|
-
result["minimum"] = mapFromDeliveryEstimateBound(minimum)
|
|
230
|
-
}
|
|
231
|
-
if let maximum = estimate.maximum {
|
|
232
|
-
result["maximum"] = mapFromDeliveryEstimateBound(maximum)
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
return result
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
private class func mapFromDeliveryEstimateBound(_ bound: Checkout.DeliveryEstimate.Bound) -> NSDictionary {
|
|
239
|
-
[
|
|
240
|
-
"unit": mapFromDeliveryEstimateUnit(bound.unit),
|
|
241
|
-
"value": bound.value,
|
|
242
|
-
]
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
private class func mapFromDeliveryEstimateUnit(_ unit: Checkout.DeliveryEstimate.Bound.Unit) -> String {
|
|
246
|
-
switch unit {
|
|
247
|
-
case .hour: return "hour"
|
|
248
|
-
case .day: return "day"
|
|
249
|
-
case .businessDay: return "businessDay"
|
|
250
|
-
case .week: return "week"
|
|
251
|
-
case .month: return "month"
|
|
252
|
-
case .unknown: return "unknown"
|
|
253
|
-
@unknown default: return "unknown"
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
class func mapFromSelectedShipping(_ selectedShipping: Checkout.SelectedShipping) -> NSDictionary {
|
|
258
|
-
[
|
|
259
|
-
"shippingOption": mapFromShippingOption(selectedShipping.shippingOption),
|
|
260
|
-
"taxAmounts": selectedShipping.taxAmounts.map(mapFromTaxAmount),
|
|
261
|
-
]
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
// MARK: - Discounts
|
|
265
|
-
|
|
266
|
-
class func mapFromDiscountAmount(_ discountAmount: Checkout.DiscountAmount) -> NSDictionary {
|
|
267
|
-
let result = NSMutableDictionary()
|
|
268
|
-
result["amount"] = mapFromAmount(discountAmount.amount)
|
|
269
|
-
result["displayName"] = discountAmount.displayName
|
|
270
|
-
|
|
271
|
-
if let promotionCode = discountAmount.promotionCode {
|
|
272
|
-
result["promotionCode"] = promotionCode
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
return result
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
// MARK: - Currency Options
|
|
279
|
-
|
|
280
|
-
class func mapFromCurrencyOption(_ currencyOption: Checkout.CurrencyOption) -> NSDictionary {
|
|
281
|
-
let result = NSMutableDictionary()
|
|
282
|
-
result["amount"] = mapFromAmount(currencyOption.amount)
|
|
283
|
-
result["currency"] = currencyOption.currency
|
|
284
|
-
|
|
285
|
-
if let currencyConversion = currencyOption.currencyConversion {
|
|
286
|
-
result["currencyConversion"] = mapFromCurrencyConversion(currencyConversion)
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
return result
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
private class func mapFromCurrencyConversion(_ conversion: Checkout.CurrencyConversion) -> NSDictionary {
|
|
293
|
-
[
|
|
294
|
-
"fxRate": conversion.fxRate,
|
|
295
|
-
"sourceCurrency": conversion.sourceCurrency,
|
|
296
|
-
]
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
// MARK: - Address
|
|
300
|
-
|
|
301
|
-
class func mapFromContactAddress(_ contactAddress: Checkout.ContactAddress) -> NSDictionary {
|
|
302
|
-
let result = NSMutableDictionary()
|
|
303
|
-
result["address"] = mapFromCheckoutAddress(contactAddress.address)
|
|
304
|
-
|
|
305
|
-
if let name = contactAddress.name {
|
|
306
|
-
result["name"] = name
|
|
307
|
-
}
|
|
308
|
-
if let phone = contactAddress.phone {
|
|
309
|
-
result["phone"] = phone
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
return result
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
private class func mapFromCheckoutAddress(_ address: Checkout.Address) -> NSDictionary {
|
|
316
|
-
let result = NSMutableDictionary()
|
|
317
|
-
result["country"] = address.country
|
|
318
|
-
|
|
319
|
-
if let line1 = address.line1 {
|
|
320
|
-
result["line1"] = line1
|
|
321
|
-
}
|
|
322
|
-
if let line2 = address.line2 {
|
|
323
|
-
result["line2"] = line2
|
|
324
|
-
}
|
|
325
|
-
if let city = address.city {
|
|
326
|
-
result["city"] = city
|
|
327
|
-
}
|
|
328
|
-
if let state = address.state {
|
|
329
|
-
result["state"] = state
|
|
330
|
-
}
|
|
331
|
-
if let postalCode = address.postalCode {
|
|
332
|
-
result["postalCode"] = postalCode
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
return result
|
|
336
|
-
}
|
|
337
|
-
}
|