@stripe/stripe-react-native 0.65.1 → 0.66.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/detekt/detekt-baseline.xml +0 -10
- package/android/gradle.properties +1 -1
- package/android/src/main/java/com/reactnativestripesdk/CardFieldView.kt +51 -57
- package/android/src/main/java/com/reactnativestripesdk/CurrencySelectorElementEvent.kt +26 -0
- package/android/src/main/java/com/reactnativestripesdk/CurrencySelectorElementView.kt +129 -16
- package/android/src/main/java/com/reactnativestripesdk/CurrencySelectorElementViewManager.kt +17 -0
- package/android/src/main/java/com/reactnativestripesdk/EventEmitterCompat.kt +4 -0
- package/android/src/main/java/com/reactnativestripesdk/PaymentSheetManager.kt +8 -19
- package/android/src/main/java/com/reactnativestripesdk/StripeAbstractComposeView.kt +1 -0
- package/android/src/main/java/com/reactnativestripesdk/StripeSdkModule.kt +95 -26
- package/android/src/main/java/com/reactnativestripesdk/StripeSdkPackage.kt +1 -0
- package/android/src/main/java/com/reactnativestripesdk/customersheet/CustomerSheetManager.kt +2 -16
- package/android/src/main/java/com/reactnativestripesdk/utils/CheckoutMappers.kt +59 -33
- package/android/src/main/java/com/reactnativestripesdk/utils/DefaultActivityLifecycleCallbacks.kt +41 -0
- package/android/src/oldarch/java/com/reactnativestripesdk/NativeOnrampSdkModuleSpec.java +17 -3
- package/android/src/oldarch/java/com/reactnativestripesdk/NativeStripeSdkModuleSpec.java +5 -1
- package/android/src/onramp/java/com/reactnativestripesdk/OnrampMappers.kt +116 -0
- package/android/src/onramp/java/com/reactnativestripesdk/OnrampSdkModule.kt +109 -1
- package/android/src/test/java/com/reactnativestripesdk/DrawableLoadingTest.kt +6 -2
- package/android/src/test/java/com/reactnativestripesdk/mappers/OnrampMappersTest.kt +107 -0
- package/android/src/test/java/com/reactnativestripesdk/utils/CheckoutMappersTest.kt +39 -30
- package/android/src/test/java/com/reactnativestripesdk/utils/CheckoutTestFixtures.java +8 -0
- package/ios/CurrencySelectorElementManager.m +7 -0
- package/ios/CurrencySelectorElementView.swift +142 -7
- package/ios/EmbeddedPaymentElementView.swift +1 -1
- package/ios/Mappers+Checkout.swift +251 -107
- package/ios/Mappers.swift +90 -2
- package/ios/NewArch/StripeCurrencySelectorElementComponentView.mm +14 -0
- package/ios/OldArch/StripeSdkEventEmitterCompat.h +1 -0
- package/ios/OldArch/StripeSdkEventEmitterCompat.m +6 -0
- package/ios/PaymentOptionDisplayData+ReactNative.swift +1 -1
- package/ios/PaymentSheetAppearance.swift +1 -1
- package/ios/StripeOnrampSdk.mm +19 -0
- package/ios/StripeSdk.mm +17 -4
- package/ios/StripeSdkEmitter.swift +1 -0
- package/ios/StripeSdkImpl+Checkout.swift +75 -23
- package/ios/StripeSdkImpl+CustomerSheet.swift +1 -1
- package/ios/StripeSdkImpl+Embedded.swift +1 -1
- package/ios/StripeSdkImpl+PaymentSheet.swift +1 -1
- package/ios/StripeSdkImpl.swift +88 -8
- package/lib/commonjs/components/PaymentMethodMessagingElement.js +1 -1
- package/lib/commonjs/components/PaymentMethodMessagingElement.js.map +1 -1
- package/lib/commonjs/hooks/useCheckout.js +1 -1
- package/lib/commonjs/hooks/useCheckout.js.map +1 -1
- package/lib/commonjs/hooks/useOnramp.js +1 -1
- package/lib/commonjs/hooks/useOnramp.js.map +1 -1
- package/lib/commonjs/specs/NativeOnrampSdkModule.js.map +1 -1
- package/lib/commonjs/specs/NativeStripeSdkModule.js.map +1 -1
- package/lib/module/components/PaymentMethodMessagingElement.js +1 -1
- package/lib/module/components/PaymentMethodMessagingElement.js.map +1 -1
- package/lib/module/hooks/useCheckout.js +1 -1
- package/lib/module/hooks/useCheckout.js.map +1 -1
- package/lib/module/hooks/useOnramp.js +1 -1
- package/lib/module/hooks/useOnramp.js.map +1 -1
- package/lib/module/specs/NativeOnrampSdkModule.js.map +1 -1
- package/lib/module/specs/NativeStripeSdkModule.js.map +1 -1
- package/lib/typescript/src/components/PaymentMethodMessagingElement.d.ts +1 -1
- package/lib/typescript/src/components/PaymentMethodMessagingElement.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useCheckout.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useOnramp.d.ts +22 -0
- package/lib/typescript/src/hooks/useOnramp.d.ts.map +1 -1
- package/lib/typescript/src/specs/NativeOnrampSdkModule.d.ts +3 -0
- package/lib/typescript/src/specs/NativeOnrampSdkModule.d.ts.map +1 -1
- package/lib/typescript/src/specs/NativeStripeSdkModule.d.ts +2 -1
- package/lib/typescript/src/specs/NativeStripeSdkModule.d.ts.map +1 -1
- package/lib/typescript/src/types/Checkout.d.ts +266 -84
- package/lib/typescript/src/types/Checkout.d.ts.map +1 -1
- package/lib/typescript/src/types/Onramp.d.ts +94 -0
- package/lib/typescript/src/types/Onramp.d.ts.map +1 -1
- package/package.json +3 -2
- package/src/components/PaymentMethodMessagingElement.tsx +54 -52
- package/src/hooks/useCheckout.tsx +20 -4
- package/src/hooks/useOnramp.tsx +44 -0
- package/src/specs/NativeOnrampSdkModule.ts +5 -0
- package/src/specs/NativeStripeSdkModule.ts +8 -1
- package/src/types/Checkout.ts +289 -84
- package/src/types/Onramp.ts +109 -0
- package/stripe-react-native.podspec +1 -1
- package/ios/CurrencySelectorElementManager.swift +0 -12
|
@@ -6,188 +6,332 @@
|
|
|
6
6
|
//
|
|
7
7
|
|
|
8
8
|
import Foundation
|
|
9
|
-
@_spi(
|
|
9
|
+
@_spi(ReactNativeSDK) import StripePaymentSheet
|
|
10
10
|
|
|
11
11
|
extension Mappers {
|
|
12
|
+
|
|
13
|
+
// MARK: - State & Session
|
|
14
|
+
|
|
12
15
|
class func mapFromCheckoutState(_ state: Checkout.State) -> NSDictionary {
|
|
13
|
-
|
|
16
|
+
[
|
|
14
17
|
"status": state.isLoading ? "loading" : "loaded",
|
|
15
18
|
"session": mapFromCheckoutSession(state.session),
|
|
16
19
|
]
|
|
17
20
|
}
|
|
18
21
|
|
|
19
|
-
class func mapFromCheckoutSession(_ session:
|
|
22
|
+
class func mapFromCheckoutSession(_ session: Checkout.Session) -> NSDictionary {
|
|
20
23
|
let result = NSMutableDictionary()
|
|
21
24
|
result["id"] = session.id
|
|
22
|
-
result["paymentStatus"] = mapFromCheckoutPaymentStatus(session.paymentStatus)
|
|
23
25
|
result["livemode"] = session.livemode
|
|
24
|
-
result["lineItems"] = session.lineItems.map(
|
|
25
|
-
result["shippingOptions"] = session.shippingOptions.map(
|
|
26
|
-
result["
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
|
30
34
|
}
|
|
31
|
-
|
|
32
35
|
if let currency = session.currency {
|
|
33
36
|
result["currency"] = currency
|
|
34
37
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
result["totals"] = mapFromCheckoutTotals(totals)
|
|
38
|
+
if let email = session.email {
|
|
39
|
+
result["email"] = email
|
|
38
40
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
result["customerId"] = customerId
|
|
41
|
+
if let minorUnitsAmountDivisor = session.minorUnitsAmountDivisor {
|
|
42
|
+
result["minorUnitsAmountDivisor"] = minorUnitsAmountDivisor
|
|
42
43
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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)
|
|
46
52
|
}
|
|
47
|
-
|
|
48
53
|
if let billingAddress = session.billingAddress {
|
|
49
|
-
result["billingAddress"] =
|
|
54
|
+
result["billingAddress"] = mapFromContactAddress(billingAddress)
|
|
50
55
|
}
|
|
51
|
-
|
|
52
56
|
if let shippingAddress = session.shippingAddress {
|
|
53
|
-
result["shippingAddress"] =
|
|
57
|
+
result["shippingAddress"] = mapFromContactAddress(shippingAddress)
|
|
54
58
|
}
|
|
55
59
|
|
|
56
60
|
return result
|
|
57
61
|
}
|
|
58
62
|
|
|
59
|
-
|
|
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 {
|
|
60
82
|
let result = NSMutableDictionary()
|
|
61
|
-
result["
|
|
83
|
+
result["type"] = mapFromStatusType(status.type)
|
|
62
84
|
|
|
63
|
-
if let
|
|
64
|
-
result["
|
|
85
|
+
if let paymentStatus = status.paymentStatus {
|
|
86
|
+
result["paymentStatus"] = mapFromPaymentStatus(paymentStatus)
|
|
65
87
|
}
|
|
66
88
|
|
|
67
|
-
|
|
68
|
-
|
|
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"
|
|
69
99
|
}
|
|
100
|
+
}
|
|
70
101
|
|
|
71
|
-
|
|
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
|
+
}
|
|
72
110
|
}
|
|
73
111
|
|
|
74
|
-
|
|
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 {
|
|
75
130
|
let result = NSMutableDictionary()
|
|
76
|
-
result["
|
|
131
|
+
result["status"] = mapFromTaxStatus(tax.status)
|
|
77
132
|
|
|
78
|
-
if let
|
|
79
|
-
result["
|
|
133
|
+
if let taxAmounts = tax.taxAmounts {
|
|
134
|
+
result["taxAmounts"] = taxAmounts.map(mapFromTaxAmount)
|
|
80
135
|
}
|
|
81
136
|
|
|
82
|
-
|
|
83
|
-
|
|
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"
|
|
84
147
|
}
|
|
148
|
+
}
|
|
85
149
|
|
|
86
|
-
|
|
87
|
-
|
|
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)
|
|
88
195
|
}
|
|
89
196
|
|
|
90
|
-
|
|
91
|
-
|
|
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)
|
|
92
220
|
}
|
|
93
221
|
|
|
94
|
-
|
|
95
|
-
|
|
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)
|
|
96
233
|
}
|
|
97
234
|
|
|
98
235
|
return result
|
|
99
236
|
}
|
|
100
237
|
|
|
101
|
-
private class func
|
|
102
|
-
|
|
103
|
-
"
|
|
104
|
-
"
|
|
105
|
-
"due": totals.due,
|
|
106
|
-
"discount": totals.discount,
|
|
107
|
-
"shipping": totals.shipping,
|
|
108
|
-
"tax": totals.tax,
|
|
238
|
+
private class func mapFromDeliveryEstimateBound(_ bound: Checkout.DeliveryEstimate.Bound) -> NSDictionary {
|
|
239
|
+
[
|
|
240
|
+
"unit": mapFromDeliveryEstimateUnit(bound.unit),
|
|
241
|
+
"value": bound.value,
|
|
109
242
|
]
|
|
110
243
|
}
|
|
111
244
|
|
|
112
|
-
private class func
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
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
|
+
}
|
|
120
255
|
}
|
|
121
256
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
"
|
|
125
|
-
"
|
|
126
|
-
"amount": shippingOption.amount,
|
|
127
|
-
"currency": shippingOption.currency,
|
|
257
|
+
class func mapFromSelectedShipping(_ selectedShipping: Checkout.SelectedShipping) -> NSDictionary {
|
|
258
|
+
[
|
|
259
|
+
"shippingOption": mapFromShippingOption(selectedShipping.shippingOption),
|
|
260
|
+
"taxAmounts": selectedShipping.taxAmounts.map(mapFromTaxAmount),
|
|
128
261
|
]
|
|
129
262
|
}
|
|
130
263
|
|
|
131
|
-
|
|
264
|
+
// MARK: - Discounts
|
|
265
|
+
|
|
266
|
+
class func mapFromDiscountAmount(_ discountAmount: Checkout.DiscountAmount) -> NSDictionary {
|
|
132
267
|
let result = NSMutableDictionary()
|
|
133
|
-
result["
|
|
134
|
-
result["
|
|
268
|
+
result["amount"] = mapFromAmount(discountAmount.amount)
|
|
269
|
+
result["displayName"] = discountAmount.displayName
|
|
135
270
|
|
|
136
|
-
if let promotionCode =
|
|
271
|
+
if let promotionCode = discountAmount.promotionCode {
|
|
137
272
|
result["promotionCode"] = promotionCode
|
|
138
273
|
}
|
|
139
274
|
|
|
140
275
|
return result
|
|
141
276
|
}
|
|
142
277
|
|
|
143
|
-
|
|
278
|
+
// MARK: - Currency Options
|
|
279
|
+
|
|
280
|
+
class func mapFromCurrencyOption(_ currencyOption: Checkout.CurrencyOption) -> NSDictionary {
|
|
144
281
|
let result = NSMutableDictionary()
|
|
145
|
-
result["
|
|
282
|
+
result["amount"] = mapFromAmount(currencyOption.amount)
|
|
283
|
+
result["currency"] = currencyOption.currency
|
|
146
284
|
|
|
147
|
-
if let
|
|
148
|
-
result["
|
|
285
|
+
if let currencyConversion = currencyOption.currencyConversion {
|
|
286
|
+
result["currencyConversion"] = mapFromCurrencyConversion(currencyConversion)
|
|
149
287
|
}
|
|
150
288
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
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)
|
|
154
304
|
|
|
155
|
-
if let
|
|
156
|
-
result["
|
|
305
|
+
if let name = contactAddress.name {
|
|
306
|
+
result["name"] = name
|
|
307
|
+
}
|
|
308
|
+
if let phone = contactAddress.phone {
|
|
309
|
+
result["phone"] = phone
|
|
157
310
|
}
|
|
158
311
|
|
|
159
312
|
return result
|
|
160
313
|
}
|
|
161
314
|
|
|
162
|
-
private class func
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
case .expired:
|
|
169
|
-
return "expired"
|
|
170
|
-
case .unknown:
|
|
171
|
-
return "unknown"
|
|
172
|
-
case nil:
|
|
173
|
-
return nil
|
|
174
|
-
@unknown default:
|
|
175
|
-
return "unknown"
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
private class func mapFromCheckoutPaymentStatus(_ paymentStatus: Checkout.PaymentStatus) -> String {
|
|
180
|
-
switch paymentStatus {
|
|
181
|
-
case .paid:
|
|
182
|
-
return "paid"
|
|
183
|
-
case .unpaid:
|
|
184
|
-
return "unpaid"
|
|
185
|
-
case .noPaymentRequired:
|
|
186
|
-
return "noPaymentRequired"
|
|
187
|
-
case .unknown:
|
|
188
|
-
return "unknown"
|
|
189
|
-
@unknown default:
|
|
190
|
-
return "unknown"
|
|
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
|
|
191
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
|
|
192
336
|
}
|
|
193
337
|
}
|
package/ios/Mappers.swift
CHANGED
|
@@ -3,7 +3,7 @@ import Stripe
|
|
|
3
3
|
@_spi(ConfirmationTokensPublicPreview) import StripePayments
|
|
4
4
|
#if canImport(StripeCryptoOnramp)
|
|
5
5
|
@_spi(CryptoOnrampAlpha) import StripeCryptoOnramp
|
|
6
|
-
@_spi(
|
|
6
|
+
@_spi(CryptoOnrampAlpha) import StripePaymentSheet
|
|
7
7
|
#else
|
|
8
8
|
import StripePaymentSheet
|
|
9
9
|
#endif
|
|
@@ -1262,13 +1262,20 @@ class Mappers {
|
|
|
1262
1262
|
class func mapToKycInfo(_ params: [String: Any]) throws -> KycInfo {
|
|
1263
1263
|
let address = try mapOptionalKycAddress(params["address"])
|
|
1264
1264
|
let dateOfBirth = try mapOptionalDateOfBirth(params["dateOfBirth"])
|
|
1265
|
+
let nationalities = try mapOptionalNormalizedStringArray(
|
|
1266
|
+
params["nationalities"],
|
|
1267
|
+
field: "nationalities"
|
|
1268
|
+
)
|
|
1265
1269
|
|
|
1266
1270
|
return KycInfo(
|
|
1267
1271
|
firstName: normalizedString(params["firstName"]),
|
|
1268
1272
|
lastName: normalizedString(params["lastName"]),
|
|
1269
1273
|
idNumber: normalizedString(params["idNumber"]),
|
|
1270
1274
|
address: address,
|
|
1271
|
-
dateOfBirth: dateOfBirth
|
|
1275
|
+
dateOfBirth: dateOfBirth,
|
|
1276
|
+
birthCountry: normalizedString(params["birthCountry"]),
|
|
1277
|
+
birthCity: normalizedString(params["birthCity"]),
|
|
1278
|
+
nationalities: nationalities
|
|
1272
1279
|
)
|
|
1273
1280
|
}
|
|
1274
1281
|
|
|
@@ -1295,6 +1302,18 @@ class Mappers {
|
|
|
1295
1302
|
result["dateOfBirth"] = mapFromDateOfBirth(dateOfBirth)
|
|
1296
1303
|
}
|
|
1297
1304
|
|
|
1305
|
+
if let birthCountry = kycInfo.birthCountry {
|
|
1306
|
+
result["birthCountry"] = birthCountry
|
|
1307
|
+
}
|
|
1308
|
+
|
|
1309
|
+
if let birthCity = kycInfo.birthCity {
|
|
1310
|
+
result["birthCity"] = birthCity
|
|
1311
|
+
}
|
|
1312
|
+
|
|
1313
|
+
if let nationalities = kycInfo.nationalities {
|
|
1314
|
+
result["nationalities"] = nationalities
|
|
1315
|
+
}
|
|
1316
|
+
|
|
1298
1317
|
return result
|
|
1299
1318
|
}
|
|
1300
1319
|
|
|
@@ -1336,6 +1355,48 @@ class Mappers {
|
|
|
1336
1355
|
]
|
|
1337
1356
|
}
|
|
1338
1357
|
|
|
1358
|
+
class func mapToComplianceIdentifier(_ params: [String: Any]) throws -> ComplianceIdentifier {
|
|
1359
|
+
guard let type = normalizedString(params["type"]) else {
|
|
1360
|
+
throw ComplianceIdentifierError.invalidField("type")
|
|
1361
|
+
}
|
|
1362
|
+
|
|
1363
|
+
guard let value = normalizedString(params["value"]) else {
|
|
1364
|
+
throw ComplianceIdentifierError.invalidField("value")
|
|
1365
|
+
}
|
|
1366
|
+
|
|
1367
|
+
return ComplianceIdentifier(type: ComplianceIdentifierType(rawValue: type), value: value)
|
|
1368
|
+
}
|
|
1369
|
+
|
|
1370
|
+
class func mapFromComplianceIdentifierRequirements(_ requirements: ComplianceIdentifierRequirements) -> [String: Any] {
|
|
1371
|
+
[
|
|
1372
|
+
"identifiers": requirements.identifiers.map(mapFromComplianceIdentifierRequirement),
|
|
1373
|
+
"alternatives": requirements.alternatives.map(mapFromComplianceIdentifierAlternativeGroup),
|
|
1374
|
+
]
|
|
1375
|
+
}
|
|
1376
|
+
|
|
1377
|
+
class func mapFromSubmitIdentifiersResult(_ result: SubmitIdentifiersResult) -> [String: Any] {
|
|
1378
|
+
[
|
|
1379
|
+
"valid": result.valid,
|
|
1380
|
+
"identifiers": result.identifiers.map(mapFromComplianceIdentifierRequirement),
|
|
1381
|
+
"alternatives": result.alternatives.map(mapFromComplianceIdentifierAlternativeGroup),
|
|
1382
|
+
"invalidIdentifiers": result.invalidIdentifiers.map(\.rawValue),
|
|
1383
|
+
]
|
|
1384
|
+
}
|
|
1385
|
+
|
|
1386
|
+
private class func mapFromComplianceIdentifierRequirement(_ requirement: ComplianceIdentifierRequirement) -> [String: String] {
|
|
1387
|
+
[
|
|
1388
|
+
"type": requirement.type.rawValue,
|
|
1389
|
+
"regulation": requirement.regulation.rawValue,
|
|
1390
|
+
]
|
|
1391
|
+
}
|
|
1392
|
+
|
|
1393
|
+
private class func mapFromComplianceIdentifierAlternativeGroup(_ group: ComplianceIdentifierAlternativeGroup) -> [String: [String]] {
|
|
1394
|
+
[
|
|
1395
|
+
"originalMissingIdentifiers": group.originalMissingIdentifiers.map(\.rawValue),
|
|
1396
|
+
"alternativeMissingIdentifiers": group.alternativeMissingIdentifiers.map(\.rawValue),
|
|
1397
|
+
]
|
|
1398
|
+
}
|
|
1399
|
+
|
|
1339
1400
|
private class func mapOptionalKycAddress(_ value: Any?) throws -> Address? {
|
|
1340
1401
|
guard let value else {
|
|
1341
1402
|
return nil
|
|
@@ -1380,6 +1441,29 @@ class Mappers {
|
|
|
1380
1441
|
return nil
|
|
1381
1442
|
}
|
|
1382
1443
|
|
|
1444
|
+
private class func mapOptionalNormalizedStringArray(
|
|
1445
|
+
_ value: Any?,
|
|
1446
|
+
field: String
|
|
1447
|
+
) throws -> [String]? {
|
|
1448
|
+
guard let value else {
|
|
1449
|
+
return nil
|
|
1450
|
+
}
|
|
1451
|
+
|
|
1452
|
+
guard let values = value as? [Any] else {
|
|
1453
|
+
throw KycInfoError.invalidField(field)
|
|
1454
|
+
}
|
|
1455
|
+
|
|
1456
|
+
let normalizedValues = try values.map { value in
|
|
1457
|
+
guard let normalizedValue = normalizedString(value) else {
|
|
1458
|
+
throw KycInfoError.invalidField(field)
|
|
1459
|
+
}
|
|
1460
|
+
|
|
1461
|
+
return normalizedValue
|
|
1462
|
+
}
|
|
1463
|
+
|
|
1464
|
+
return normalizedValues.isEmpty ? nil : normalizedValues
|
|
1465
|
+
}
|
|
1466
|
+
|
|
1383
1467
|
private class func normalizedString(_ value: Any?) -> String? {
|
|
1384
1468
|
guard let stringValue = value as? String else {
|
|
1385
1469
|
return nil
|
|
@@ -1415,5 +1499,9 @@ class Mappers {
|
|
|
1415
1499
|
enum KycInfoError: Swift.Error {
|
|
1416
1500
|
case invalidField(String)
|
|
1417
1501
|
}
|
|
1502
|
+
|
|
1503
|
+
enum ComplianceIdentifierError: Swift.Error {
|
|
1504
|
+
case invalidField(String)
|
|
1505
|
+
}
|
|
1418
1506
|
#endif
|
|
1419
1507
|
}
|
|
@@ -41,6 +41,20 @@ using namespace facebook::react;
|
|
|
41
41
|
{
|
|
42
42
|
_view = [[StripeCurrencySelectorElementContainerView alloc] initWithFrame:self.frame];
|
|
43
43
|
self.contentView = _view;
|
|
44
|
+
|
|
45
|
+
__weak __typeof(self) weakSelf = self;
|
|
46
|
+
|
|
47
|
+
_view.onHeightChange = ^(NSDictionary *event) {
|
|
48
|
+
__typeof(self) strongSelf = weakSelf;
|
|
49
|
+
if (!strongSelf || !strongSelf->_eventEmitter) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
StripeCurrencySelectorElementEventEmitter::OnHeightChange emitterEvent = {
|
|
53
|
+
.height = [(NSNumber *)event[@"height"] doubleValue],
|
|
54
|
+
};
|
|
55
|
+
std::static_pointer_cast<const StripeCurrencySelectorElementEventEmitter>(strongSelf->_eventEmitter)
|
|
56
|
+
->onHeightChange(std::move(emitterEvent));
|
|
57
|
+
};
|
|
44
58
|
}
|
|
45
59
|
|
|
46
60
|
- (void)updateProps:(const facebook::react::Props::Shared &)props
|
|
@@ -26,5 +26,6 @@
|
|
|
26
26
|
- (void)emitOnCheckoutClientSecretRequested:(NSDictionary *)value;
|
|
27
27
|
- (void)emitPaymentMethodMessagingElementDidUpdateHeight:(NSDictionary *)value;
|
|
28
28
|
- (void)emitPaymentMethodMessagingElementConfigureResult:(NSDictionary *)value;
|
|
29
|
+
- (void)emitCheckoutSessionDidChangeState:(NSDictionary *)value;
|
|
29
30
|
@end
|
|
30
31
|
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
@"onCheckoutClientSecretRequested",
|
|
28
28
|
@"paymentMethodMessagingElementDidUpdateHeight",
|
|
29
29
|
@"paymentMethodMessagingElementConfigureResult",
|
|
30
|
+
@"checkoutSessionDidChangeState",
|
|
30
31
|
];
|
|
31
32
|
}
|
|
32
33
|
|
|
@@ -140,4 +141,9 @@
|
|
|
140
141
|
[self sendEventWithName:@"paymentMethodMessagingElementConfigureResult" body:value];
|
|
141
142
|
}
|
|
142
143
|
|
|
144
|
+
- (void)emitCheckoutSessionDidChangeState:(NSDictionary *)value
|
|
145
|
+
{
|
|
146
|
+
[self sendEventWithName:@"checkoutSessionDidChangeState" body:value];
|
|
147
|
+
}
|
|
148
|
+
|
|
143
149
|
@end
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
//
|
|
7
7
|
|
|
8
8
|
import Foundation
|
|
9
|
-
|
|
9
|
+
import StripePaymentSheet
|
|
10
10
|
|
|
11
11
|
extension EmbeddedPaymentElement.PaymentOptionDisplayData {
|
|
12
12
|
/// Convert `PaymentOptionDisplayData` into a dictionary compatible with React Native bridge.
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
//
|
|
5
5
|
// Created by Charles Cruzan on 5/11/22.
|
|
6
6
|
//
|
|
7
|
-
|
|
7
|
+
import StripePaymentSheet
|
|
8
8
|
|
|
9
9
|
internal class PaymentSheetAppearance {
|
|
10
10
|
class func buildAppearanceFromParams(userParams: NSDictionary?) throws -> PaymentSheet.Appearance {
|
package/ios/StripeOnrampSdk.mm
CHANGED
|
@@ -65,6 +65,25 @@ RCT_EXPORT_METHOD(attachKycInfo:(nonnull NSDictionary *)info
|
|
|
65
65
|
[StripeSdkImpl.shared attachKycInfo:info resolver:resolve rejecter:reject];
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
+
RCT_EXPORT_METHOD(retrieveMissingIdentifiers:(nonnull RCTPromiseResolveBlock)resolve
|
|
69
|
+
reject:(nonnull RCTPromiseRejectBlock)reject)
|
|
70
|
+
{
|
|
71
|
+
[StripeSdkImpl.shared retrieveMissingIdentifiers:resolve rejecter:reject];
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
RCT_EXPORT_METHOD(submitIdentifiers:(nonnull NSArray *)identifiers
|
|
75
|
+
resolve:(nonnull RCTPromiseResolveBlock)resolve
|
|
76
|
+
reject:(nonnull RCTPromiseRejectBlock)reject)
|
|
77
|
+
{
|
|
78
|
+
[StripeSdkImpl.shared submitIdentifiers:identifiers resolver:resolve rejecter:reject];
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
RCT_EXPORT_METHOD(presentCRSCARFDeclaration:(nonnull RCTPromiseResolveBlock)resolve
|
|
82
|
+
reject:(nonnull RCTPromiseRejectBlock)reject)
|
|
83
|
+
{
|
|
84
|
+
[StripeSdkImpl.shared presentCRSCARFDeclaration:resolve rejecter:reject];
|
|
85
|
+
}
|
|
86
|
+
|
|
68
87
|
RCT_EXPORT_METHOD(presentKycInfoVerification:(NSDictionary *)updatedAddress
|
|
69
88
|
resolve:(nonnull RCTPromiseResolveBlock)resolve
|
|
70
89
|
reject:(nonnull RCTPromiseRejectBlock)reject)
|