@stripe/stripe-react-native 0.22.0 → 0.23.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/CHANGELOG.md +23 -0
- package/android/src/main/java/com/reactnativestripesdk/CardFieldView.kt +1 -2
- package/android/src/main/java/com/reactnativestripesdk/CardFormView.kt +2 -3
- package/android/src/main/java/com/reactnativestripesdk/GooglePayRequestHelper.kt +21 -9
- package/android/src/main/java/com/reactnativestripesdk/StripeSdkModule.kt +4 -2
- package/android/src/main/res/layout/googlepay_mark_button.xml +0 -2
- package/ios/ApplePayViewController.swift +23 -15
- package/ios/Mappers.swift +35 -16
- package/ios/PaymentMethodFactory.swift +1 -1
- package/ios/StripeSdk.m +1 -0
- package/ios/StripeSdk.swift +8 -5
- package/ios/Tests/ApplePayUtilsTests.swift +0 -1
- package/jest/mock.js +6 -0
- package/lib/commonjs/NativeStripeSdk.js.map +1 -1
- package/lib/commonjs/components/AddToWalletButton.js.map +1 -1
- package/lib/commonjs/components/AddressSheet.js.map +1 -1
- package/lib/commonjs/components/ApplePayButton.js +1 -1
- package/lib/commonjs/components/ApplePayButton.js.map +1 -1
- package/lib/commonjs/components/ApplePayButtonNative.js +2 -0
- package/lib/commonjs/components/ApplePayButtonNative.js.map +1 -0
- package/lib/commonjs/components/AuBECSDebitForm.js.map +1 -1
- package/lib/commonjs/components/CardField.js.map +1 -1
- package/lib/commonjs/components/CardForm.js.map +1 -1
- package/lib/commonjs/components/GooglePayButton.js +1 -1
- package/lib/commonjs/components/GooglePayButton.js.map +1 -1
- package/lib/commonjs/components/GooglePayButtonNative.js +2 -0
- package/lib/commonjs/components/GooglePayButtonNative.js.map +1 -0
- package/lib/commonjs/components/PlatformPayButton.js +1 -1
- package/lib/commonjs/components/PlatformPayButton.js.map +1 -1
- package/lib/commonjs/components/StripeContainer.js.map +1 -1
- package/lib/commonjs/components/StripeProvider.js.map +1 -1
- package/lib/commonjs/functions.js +1 -1
- package/lib/commonjs/functions.js.map +1 -1
- package/lib/commonjs/helpers.js.map +1 -1
- package/lib/commonjs/hooks/useApplePay.js +1 -1
- package/lib/commonjs/hooks/useApplePay.js.map +1 -1
- package/lib/commonjs/hooks/useConfirmPayment.js.map +1 -1
- package/lib/commonjs/hooks/useConfirmSetupIntent.js.map +1 -1
- package/lib/commonjs/hooks/useFinancialConnectionsSheet.js.map +1 -1
- package/lib/commonjs/hooks/useGooglePay.js.map +1 -1
- package/lib/commonjs/hooks/usePaymentSheet.js.map +1 -1
- package/lib/commonjs/hooks/usePlatformPay.js +1 -1
- package/lib/commonjs/hooks/usePlatformPay.js.map +1 -1
- package/lib/commonjs/hooks/useStripe.js +1 -1
- package/lib/commonjs/hooks/useStripe.js.map +1 -1
- package/lib/commonjs/index.js +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/plugin/withStripe.js.map +1 -1
- package/lib/commonjs/types/ApplePay.js.map +1 -1
- package/lib/commonjs/types/Common.js.map +1 -1
- package/lib/commonjs/types/Errors.js.map +1 -1
- package/lib/commonjs/types/FinancialConnections.js.map +1 -1
- package/lib/commonjs/types/GooglePay.js.map +1 -1
- package/lib/commonjs/types/NextAction.js.map +1 -1
- package/lib/commonjs/types/PaymentIntent.js.map +1 -1
- package/lib/commonjs/types/PaymentMethod.js.map +1 -1
- package/lib/commonjs/types/PaymentSheet.js.map +1 -1
- package/lib/commonjs/types/PlatformPay.js.map +1 -1
- package/lib/commonjs/types/PushProvisioning.js.map +1 -1
- package/lib/commonjs/types/SetupIntent.js.map +1 -1
- package/lib/commonjs/types/ThreeDSecure.js.map +1 -1
- package/lib/commonjs/types/Token.js.map +1 -1
- package/lib/commonjs/types/components/ApplePayButtonComponent.js.map +1 -1
- package/lib/commonjs/types/components/AuBECSDebitFormComponent.js.map +1 -1
- package/lib/commonjs/types/components/CardFieldInput.js.map +1 -1
- package/lib/commonjs/types/components/CardFormView.js.map +1 -1
- package/lib/commonjs/types/components/GooglePayButtonComponent.js +2 -0
- package/lib/commonjs/types/components/GooglePayButtonComponent.js.map +1 -0
- package/lib/commonjs/types/index.js +1 -1
- package/lib/commonjs/types/index.js.map +1 -1
- package/lib/module/NativeStripeSdk.js.map +1 -1
- package/lib/module/components/AddToWalletButton.js.map +1 -1
- package/lib/module/components/AddressSheet.js.map +1 -1
- package/lib/module/components/ApplePayButton.js +1 -1
- package/lib/module/components/ApplePayButton.js.map +1 -1
- package/lib/module/components/ApplePayButtonNative.js +2 -0
- package/lib/module/components/ApplePayButtonNative.js.map +1 -0
- package/lib/module/components/AuBECSDebitForm.js.map +1 -1
- package/lib/module/components/CardField.js.map +1 -1
- package/lib/module/components/CardForm.js.map +1 -1
- package/lib/module/components/GooglePayButton.js +1 -1
- package/lib/module/components/GooglePayButton.js.map +1 -1
- package/lib/module/components/GooglePayButtonNative.js +2 -0
- package/lib/module/components/GooglePayButtonNative.js.map +1 -0
- package/lib/module/components/PlatformPayButton.js +1 -1
- package/lib/module/components/PlatformPayButton.js.map +1 -1
- package/lib/module/components/StripeContainer.js.map +1 -1
- package/lib/module/components/StripeProvider.js.map +1 -1
- package/lib/module/functions.js +1 -1
- package/lib/module/functions.js.map +1 -1
- package/lib/module/helpers.js.map +1 -1
- package/lib/module/hooks/useApplePay.js +1 -1
- package/lib/module/hooks/useApplePay.js.map +1 -1
- package/lib/module/hooks/useConfirmPayment.js.map +1 -1
- package/lib/module/hooks/useConfirmSetupIntent.js.map +1 -1
- package/lib/module/hooks/useFinancialConnectionsSheet.js.map +1 -1
- package/lib/module/hooks/useGooglePay.js.map +1 -1
- package/lib/module/hooks/usePaymentSheet.js.map +1 -1
- package/lib/module/hooks/usePlatformPay.js +1 -1
- package/lib/module/hooks/usePlatformPay.js.map +1 -1
- package/lib/module/hooks/useStripe.js +1 -1
- package/lib/module/hooks/useStripe.js.map +1 -1
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/plugin/withStripe.js.map +1 -1
- package/lib/module/types/ApplePay.js.map +1 -1
- package/lib/module/types/Common.js.map +1 -1
- package/lib/module/types/Errors.js.map +1 -1
- package/lib/module/types/FinancialConnections.js.map +1 -1
- package/lib/module/types/GooglePay.js.map +1 -1
- package/lib/module/types/NextAction.js.map +1 -1
- package/lib/module/types/PaymentIntent.js.map +1 -1
- package/lib/module/types/PaymentMethod.js.map +1 -1
- package/lib/module/types/PaymentSheet.js.map +1 -1
- package/lib/module/types/PlatformPay.js.map +1 -1
- package/lib/module/types/PushProvisioning.js.map +1 -1
- package/lib/module/types/SetupIntent.js.map +1 -1
- package/lib/module/types/ThreeDSecure.js.map +1 -1
- package/lib/module/types/Token.js.map +1 -1
- package/lib/module/types/components/ApplePayButtonComponent.js.map +1 -1
- package/lib/module/types/components/AuBECSDebitFormComponent.js.map +1 -1
- package/lib/module/types/components/CardFieldInput.js.map +1 -1
- package/lib/module/types/components/CardFormView.js.map +1 -1
- package/lib/module/types/components/GooglePayButtonComponent.js +2 -0
- package/lib/module/types/components/GooglePayButtonComponent.js.map +1 -0
- package/lib/module/types/index.js +1 -1
- package/lib/module/types/index.js.map +1 -1
- package/lib/typescript/src/NativeStripeSdk.d.ts +1 -1
- package/lib/typescript/src/components/AddToWalletButton.d.ts +1 -1
- package/lib/typescript/src/components/ApplePayButton.d.ts +1 -1
- package/lib/typescript/src/components/ApplePayButtonNative.d.ts +3 -0
- package/lib/typescript/src/components/GooglePayButtonNative.d.ts +3 -0
- package/lib/typescript/src/functions.d.ts +8 -2
- package/lib/typescript/src/hooks/usePlatformPay.d.ts +6 -0
- package/lib/typescript/src/hooks/useStripe.d.ts +1 -0
- package/lib/typescript/src/index.d.ts +22 -11
- package/lib/typescript/src/types/PaymentSheet.d.ts +1 -1
- package/lib/typescript/src/types/PlatformPay.d.ts +6 -1
- package/lib/typescript/src/types/PushProvisioning.d.ts +1 -1
- package/lib/typescript/src/types/Token.d.ts +1 -0
- package/lib/typescript/src/types/components/ApplePayButtonComponent.d.ts +12 -1
- package/lib/typescript/src/types/components/GooglePayButtonComponent.d.ts +6 -0
- package/lib/typescript/src/types/index.d.ts +3 -2
- package/package.json +4 -4
- package/src/NativeStripeSdk.tsx +3 -2
- package/src/components/AddToWalletButton.tsx +1 -1
- package/src/components/ApplePayButton.tsx +3 -10
- package/src/components/ApplePayButtonNative.tsx +5 -0
- package/src/components/GooglePayButton.tsx +1 -3
- package/src/components/GooglePayButtonNative.tsx +7 -0
- package/src/components/PlatformPayButton.tsx +2 -4
- package/src/functions.ts +35 -4
- package/src/hooks/useApplePay.tsx +1 -2
- package/src/hooks/usePlatformPay.tsx +19 -0
- package/src/hooks/useStripe.tsx +11 -0
- package/src/index.tsx +22 -36
- package/src/types/PaymentSheet.ts +1 -1
- package/src/types/PlatformPay.ts +9 -1
- package/src/types/PushProvisioning.ts +1 -1
- package/src/types/Token.ts +1 -0
- package/src/types/components/ApplePayButtonComponent.ts +18 -2
- package/src/types/components/GooglePayButtonComponent.ts +6 -0
- package/src/types/index.ts +3 -1
- package/stripe-react-native.podspec +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,29 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 0.23.0 - 2023-01-09
|
|
6
|
+
|
|
7
|
+
### Breaking changes
|
|
8
|
+
|
|
9
|
+
- `createPlatformPayPaymentMethod` no longer returns a `token` object. [#1236](https://github.com/stripe/stripe-react-native/issues/1236)
|
|
10
|
+
- If your integration depends on Stripe's Tokens API, please use `createPlatformPayToken`, which accepts identical arguments.
|
|
11
|
+
|
|
12
|
+
## Fixes
|
|
13
|
+
|
|
14
|
+
- Fixed an issue with `createPlatformPayPaymentMethod` on iOS where a "Canceled" error could be returned in production. [#1236](https://github.com/stripe/stripe-react-native/issues/1236)
|
|
15
|
+
- Fixed an issue where the `PlatformPayButton` with `type={PlatformPay.ButtonType.GooglePayMark}` would be unclickable. [#1236](https://github.com/stripe/stripe-react-native/issues/1236)
|
|
16
|
+
- Fixed an issue on Android where `CardField` would render without the necessary padding. [48debb2](https://github.com/stripe/stripe-react-native/commit/48debb27de4b02d8309b4e42737be066cdf33835)
|
|
17
|
+
- Fixed an issue on iOS where providing a `null` value to certain method parameters would result in a crash. [#1252](https://github.com/stripe/stripe-react-native/pull/1252)
|
|
18
|
+
|
|
19
|
+
## 0.22.1 - 2022-12-07
|
|
20
|
+
|
|
21
|
+
## Fixes
|
|
22
|
+
|
|
23
|
+
- Fixed the `ShippingMethod` type to contain the `isPending` field instead of a `type` field (which previously was never correct). This reflects the inputs accepted. [#1227](https://github.com/stripe/stripe-react-native/pull/1227)
|
|
24
|
+
- Fixed the `ShippingMethod` type to contain the `startDate` and `endDate` keys, if applicable. [#1227](https://github.com/stripe/stripe-react-native/pull/1227)
|
|
25
|
+
- Fixed instances of the "duplicate registered views" error. [#1233](https://github.com/stripe/stripe-react-native/pull/1233)
|
|
26
|
+
- Fixed extra margin that was being added to `<CardForm />` on Android. [#1234](https://github.com/stripe/stripe-react-native/pull/1234)
|
|
27
|
+
|
|
5
28
|
## 0.22.0 - 2022-12-02
|
|
6
29
|
|
|
7
30
|
### Breaking changes
|
|
@@ -2,7 +2,6 @@ package com.reactnativestripesdk
|
|
|
2
2
|
|
|
3
3
|
import android.content.res.ColorStateList
|
|
4
4
|
import android.graphics.Color
|
|
5
|
-
import android.graphics.Typeface
|
|
6
5
|
import android.os.Build
|
|
7
6
|
import android.text.Editable
|
|
8
7
|
import android.text.InputFilter
|
|
@@ -143,7 +142,7 @@ class CardFieldView(context: ThemedReactContext) : FrameLayout(context) {
|
|
|
143
142
|
}
|
|
144
143
|
}
|
|
145
144
|
|
|
146
|
-
mCardWidget.setPadding(
|
|
145
|
+
mCardWidget.setPadding(20, 0, 20, 0)
|
|
147
146
|
mCardWidget.background = MaterialShapeDrawable(
|
|
148
147
|
ShapeAppearanceModel()
|
|
149
148
|
.toBuilder()
|
|
@@ -2,12 +2,12 @@ package com.reactnativestripesdk
|
|
|
2
2
|
|
|
3
3
|
import android.content.res.ColorStateList
|
|
4
4
|
import android.graphics.Color
|
|
5
|
-
import android.graphics.Typeface
|
|
6
5
|
import android.os.Build
|
|
7
6
|
import android.text.InputFilter
|
|
8
7
|
import android.view.View
|
|
9
8
|
import android.view.View.OnFocusChangeListener
|
|
10
9
|
import android.widget.FrameLayout
|
|
10
|
+
import androidx.core.view.setMargins
|
|
11
11
|
import com.facebook.react.bridge.ReadableMap
|
|
12
12
|
import com.facebook.react.uimanager.PixelUtil
|
|
13
13
|
import com.facebook.react.uimanager.ThemedReactContext
|
|
@@ -40,7 +40,7 @@ class CardFormView(context: ThemedReactContext) : FrameLayout(context) {
|
|
|
40
40
|
init {
|
|
41
41
|
cardFormViewBinding.cardMultilineWidgetContainer.isFocusable = true
|
|
42
42
|
cardFormViewBinding.cardMultilineWidgetContainer.isFocusableInTouchMode = true
|
|
43
|
-
|
|
43
|
+
(cardFormViewBinding.cardMultilineWidgetContainer.layoutParams as MarginLayoutParams).setMargins(0)
|
|
44
44
|
addView(cardForm)
|
|
45
45
|
setListeners()
|
|
46
46
|
|
|
@@ -191,7 +191,6 @@ class CardFormView(context: ThemedReactContext) : FrameLayout(context) {
|
|
|
191
191
|
}
|
|
192
192
|
}
|
|
193
193
|
|
|
194
|
-
cardFormViewBinding.cardMultilineWidgetContainer.setPadding(40, 0, 40, 0)
|
|
195
194
|
cardFormViewBinding.cardMultilineWidgetContainer.background = MaterialShapeDrawable(
|
|
196
195
|
ShapeAppearanceModel()
|
|
197
196
|
.toBuilder()
|
|
@@ -51,11 +51,11 @@ class GooglePayRequestHelper {
|
|
|
51
51
|
val isPhoneNumberRequired = params?.getBooleanOr("isPhoneNumberRequired", false)
|
|
52
52
|
val isRequired = params?.getBooleanOr("isRequired", false)
|
|
53
53
|
val allowedCountryCodes = if (params?.hasKey("allowedCountryCodes") == true)
|
|
54
|
-
params.getArray("allowedCountryCodes") as
|
|
54
|
+
params.getArray("allowedCountryCodes")?.toArrayList()?.toSet() as? Set<String> else null
|
|
55
55
|
|
|
56
56
|
return GooglePayJsonFactory.ShippingAddressParameters(
|
|
57
57
|
isRequired = isRequired ?: false,
|
|
58
|
-
allowedCountryCodes = allowedCountryCodes.toSet(),
|
|
58
|
+
allowedCountryCodes = allowedCountryCodes ?: Locale.getISOCountries().toSet(),
|
|
59
59
|
phoneNumberRequired = isPhoneNumberRequired ?: false
|
|
60
60
|
)
|
|
61
61
|
}
|
|
@@ -98,12 +98,16 @@ class GooglePayRequestHelper {
|
|
|
98
98
|
)
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
internal fun handleGooglePaymentMethodResult(resultCode: Int, data: Intent?, stripe: Stripe, promise: Promise) {
|
|
101
|
+
internal fun handleGooglePaymentMethodResult(resultCode: Int, data: Intent?, stripe: Stripe, forToken: Boolean, promise: Promise) {
|
|
102
102
|
when (resultCode) {
|
|
103
103
|
Activity.RESULT_OK -> {
|
|
104
104
|
data?.let { intent ->
|
|
105
105
|
PaymentData.getFromIntent(intent)?.let {
|
|
106
|
-
|
|
106
|
+
if (forToken) {
|
|
107
|
+
resolveWithToken(it, promise)
|
|
108
|
+
} else {
|
|
109
|
+
resolveWithPaymentMethod(it, stripe, promise)
|
|
110
|
+
}
|
|
107
111
|
}
|
|
108
112
|
}
|
|
109
113
|
}
|
|
@@ -118,13 +122,9 @@ class GooglePayRequestHelper {
|
|
|
118
122
|
}
|
|
119
123
|
}
|
|
120
124
|
|
|
121
|
-
private fun
|
|
125
|
+
private fun resolveWithPaymentMethod(paymentData: PaymentData, stripe: Stripe, promise: Promise) {
|
|
122
126
|
val paymentInformation = JSONObject(paymentData.toJson())
|
|
123
|
-
val googlePayResult = GooglePayResult.fromJson(paymentInformation)
|
|
124
127
|
val promiseResult = WritableNativeMap()
|
|
125
|
-
googlePayResult.token?.let {
|
|
126
|
-
promiseResult.putMap("token", mapFromToken(it))
|
|
127
|
-
}
|
|
128
128
|
stripe.createPaymentMethod(
|
|
129
129
|
PaymentMethodCreateParams.createFromGooglePay(paymentInformation),
|
|
130
130
|
callback = object : ApiResultCallback<PaymentMethod> {
|
|
@@ -139,6 +139,18 @@ class GooglePayRequestHelper {
|
|
|
139
139
|
}
|
|
140
140
|
)
|
|
141
141
|
}
|
|
142
|
+
|
|
143
|
+
private fun resolveWithToken(paymentData: PaymentData, promise: Promise) {
|
|
144
|
+
val paymentInformation = JSONObject(paymentData.toJson())
|
|
145
|
+
val googlePayResult = GooglePayResult.fromJson(paymentInformation)
|
|
146
|
+
val promiseResult = WritableNativeMap()
|
|
147
|
+
googlePayResult.token?.let {
|
|
148
|
+
promiseResult.putMap("token", mapFromToken(it))
|
|
149
|
+
promise.resolve(promiseResult)
|
|
150
|
+
} ?: run {
|
|
151
|
+
promise.resolve(createError("Failed", "Unexpected response from Google Pay. No token was found."))
|
|
152
|
+
}
|
|
153
|
+
}
|
|
142
154
|
}
|
|
143
155
|
}
|
|
144
156
|
|
|
@@ -40,6 +40,7 @@ class StripeSdkModule(reactContext: ReactApplicationContext) : ReactContextBaseJ
|
|
|
40
40
|
private var confirmPromise: Promise? = null
|
|
41
41
|
private var confirmPaymentClientSecret: String? = null
|
|
42
42
|
private var createPlatformPayPaymentMethodPromise: Promise? = null
|
|
43
|
+
private var platformPayUsesDeprecatedTokenFlow = false
|
|
43
44
|
|
|
44
45
|
private var paymentSheetFragment: PaymentSheetFragment? = null
|
|
45
46
|
private var googlePayFragment: GooglePayFragment? = null
|
|
@@ -65,7 +66,7 @@ class StripeSdkModule(reactContext: ReactApplicationContext) : ReactContextBaseJ
|
|
|
65
66
|
when (requestCode) {
|
|
66
67
|
GooglePayRequestHelper.LOAD_PAYMENT_DATA_REQUEST_CODE -> {
|
|
67
68
|
createPlatformPayPaymentMethodPromise?.let {
|
|
68
|
-
GooglePayRequestHelper.handleGooglePaymentMethodResult(resultCode, data, stripe, it)
|
|
69
|
+
GooglePayRequestHelper.handleGooglePaymentMethodResult(resultCode, data, stripe, platformPayUsesDeprecatedTokenFlow, it)
|
|
69
70
|
createPlatformPayPaymentMethodPromise = null
|
|
70
71
|
} ?: run { Log.d("StripeReactNative", "No promise was found, Google Pay result went unhandled,") }
|
|
71
72
|
}
|
|
@@ -654,11 +655,12 @@ class StripeSdkModule(reactContext: ReactApplicationContext) : ReactContextBaseJ
|
|
|
654
655
|
}
|
|
655
656
|
|
|
656
657
|
@ReactMethod
|
|
657
|
-
fun createPlatformPayPaymentMethod(params: ReadableMap, promise: Promise) {
|
|
658
|
+
fun createPlatformPayPaymentMethod(params: ReadableMap, usesDeprecatedTokenFlow: Boolean, promise: Promise) {
|
|
658
659
|
val googlePayParams: ReadableMap = params.getMap("googlePay") ?: run {
|
|
659
660
|
promise.resolve(createError(GooglePayErrorType.Failed.toString(), "You must provide the `googlePay` parameter."))
|
|
660
661
|
return
|
|
661
662
|
}
|
|
663
|
+
platformPayUsesDeprecatedTokenFlow = usesDeprecatedTokenFlow
|
|
662
664
|
createPlatformPayPaymentMethodPromise = promise
|
|
663
665
|
getCurrentActivityOrResolveWithError(promise)?.let {
|
|
664
666
|
val request = GooglePayRequestHelper.createPaymentRequest(
|
|
@@ -7,9 +7,7 @@
|
|
|
7
7
|
android:focusable="true"
|
|
8
8
|
android:minWidth="1dp"
|
|
9
9
|
android:background="@drawable/googlepay_mark_background">
|
|
10
|
-
|
|
11
10
|
<ImageView
|
|
12
|
-
android:id="@+id/imageView2"
|
|
13
11
|
android:layout_width="wrap_content"
|
|
14
12
|
android:layout_height="wrap_content"
|
|
15
13
|
android:cropToPadding="true"
|
|
@@ -15,23 +15,31 @@ extension StripeSdk : PKPaymentAuthorizationViewControllerDelegate, STPApplePayC
|
|
|
15
15
|
handler completion: @escaping (PKPaymentAuthorizationResult) -> Void
|
|
16
16
|
) {
|
|
17
17
|
applePaymentMethodFlowCanBeCanceled = false
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
18
|
+
|
|
19
|
+
if (platformPayUsesDeprecatedTokenFlow) {
|
|
20
|
+
STPAPIClient.shared.createToken(with: payment) { token, error in
|
|
21
|
+
if let error = error {
|
|
22
|
+
self.createPlatformPayPaymentMethodResolver?(Errors.createError(ErrorType.Failed, error))
|
|
23
|
+
} else {
|
|
24
|
+
let promiseResult = [
|
|
25
|
+
"token": token != nil ? Mappers.mapFromToken(token: token!.splitApplePayAddressByNewline()) : [:]
|
|
26
|
+
]
|
|
27
|
+
self.createPlatformPayPaymentMethodResolver?(promiseResult)
|
|
28
|
+
}
|
|
29
|
+
completion(PKPaymentAuthorizationResult.init(status: .success, errors: nil))
|
|
30
|
+
}
|
|
31
|
+
} else {
|
|
32
|
+
STPAPIClient.shared.createPaymentMethod(with: payment) { paymentMethod, error in
|
|
33
|
+
if let error = error {
|
|
34
|
+
self.createPlatformPayPaymentMethodResolver?(Errors.createError(ErrorType.Failed, error))
|
|
35
|
+
} else {
|
|
36
|
+
let promiseResult = [
|
|
37
|
+
"paymentMethod": Mappers.mapFromPaymentMethod(paymentMethod?.splitApplePayAddressByNewline()) ?? [:]
|
|
38
|
+
]
|
|
39
|
+
self.createPlatformPayPaymentMethodResolver?(promiseResult)
|
|
32
40
|
}
|
|
41
|
+
completion(PKPaymentAuthorizationResult.init(status: .success, errors: nil))
|
|
33
42
|
}
|
|
34
|
-
completion(PKPaymentAuthorizationResult.init(status: .success, errors: nil))
|
|
35
43
|
}
|
|
36
44
|
}
|
|
37
45
|
|
package/ios/Mappers.swift
CHANGED
|
@@ -146,7 +146,7 @@ class Mappers {
|
|
|
146
146
|
let tokenMap: NSDictionary = [
|
|
147
147
|
"id": token.tokenId,
|
|
148
148
|
"bankAccount": mapFromBankAccount(token.bankAccount) ?? NSNull(),
|
|
149
|
-
"created":
|
|
149
|
+
"created": convertDateToUnixTimestampMilliseconds(date: token.created) ?? NSNull(),
|
|
150
150
|
"card": mapFromCard(token.card) ?? NSNull(),
|
|
151
151
|
"livemode": token.livemode,
|
|
152
152
|
"type": mapFromTokenType(token.type) ?? NSNull(),
|
|
@@ -180,13 +180,24 @@ class Mappers {
|
|
|
180
180
|
}
|
|
181
181
|
|
|
182
182
|
class func mapFromShippingMethod(shippingMethod: PKShippingMethod) -> NSDictionary {
|
|
183
|
-
let method:
|
|
183
|
+
let method: NSMutableDictionary = [
|
|
184
184
|
"detail": shippingMethod.detail ?? "",
|
|
185
185
|
"identifier": shippingMethod.identifier ?? "",
|
|
186
186
|
"amount": shippingMethod.amount.stringValue,
|
|
187
|
-
"
|
|
187
|
+
"isPending": shippingMethod.type == .pending,
|
|
188
188
|
"label": shippingMethod.label
|
|
189
189
|
]
|
|
190
|
+
|
|
191
|
+
if #available(iOS 15.0, *) {
|
|
192
|
+
if let dateComponentsRange = shippingMethod.dateComponentsRange {
|
|
193
|
+
method.setObject(
|
|
194
|
+
convertDateToUnixTimestampSeconds(date: dateComponentsRange.startDateComponents.date) ?? NSNull(),
|
|
195
|
+
forKey: "startDate" as NSCopying)
|
|
196
|
+
method.setObject(
|
|
197
|
+
convertDateToUnixTimestampSeconds(date: dateComponentsRange.endDateComponents.date) ?? NSNull(),
|
|
198
|
+
forKey: "endDate" as NSCopying)
|
|
199
|
+
}
|
|
200
|
+
}
|
|
190
201
|
|
|
191
202
|
return method
|
|
192
203
|
}
|
|
@@ -372,7 +383,7 @@ class Mappers {
|
|
|
372
383
|
"paymentMethodId": paymentIntent.paymentMethodId ?? NSNull(),
|
|
373
384
|
"captureMethod": mapCaptureMethod(paymentIntent.captureMethod),
|
|
374
385
|
"confirmationMethod": mapConfirmationMethod(paymentIntent.confirmationMethod),
|
|
375
|
-
"created":
|
|
386
|
+
"created": convertDateToUnixTimestampMilliseconds(date: paymentIntent.created) ?? NSNull(),
|
|
376
387
|
"amount": paymentIntent.amount,
|
|
377
388
|
"lastPaymentError": NSNull(),
|
|
378
389
|
"shipping": NSNull(),
|
|
@@ -397,7 +408,7 @@ class Mappers {
|
|
|
397
408
|
}
|
|
398
409
|
|
|
399
410
|
if let canceledAt = paymentIntent.canceledAt {
|
|
400
|
-
intent.setValue(
|
|
411
|
+
intent.setValue(convertDateToUnixTimestampMilliseconds(date: canceledAt), forKey: "canceledAt")
|
|
401
412
|
}
|
|
402
413
|
|
|
403
414
|
return intent;
|
|
@@ -491,19 +502,19 @@ class Mappers {
|
|
|
491
502
|
return nil
|
|
492
503
|
}
|
|
493
504
|
let billing = STPPaymentMethodBillingDetails()
|
|
494
|
-
billing.email =
|
|
495
|
-
billing.phone =
|
|
496
|
-
billing.name =
|
|
505
|
+
billing.email = billingDetails["email"] as? String
|
|
506
|
+
billing.phone = billingDetails["phone"] as? String
|
|
507
|
+
billing.name = billingDetails["name"] as? String
|
|
497
508
|
|
|
498
509
|
let address = STPPaymentMethodAddress()
|
|
499
510
|
|
|
500
511
|
if let addressMap = billingDetails["address"] as? NSDictionary {
|
|
501
|
-
address.city =
|
|
502
|
-
address.postalCode =
|
|
503
|
-
address.country =
|
|
504
|
-
address.line1 =
|
|
505
|
-
address.line2 =
|
|
506
|
-
address.state =
|
|
512
|
+
address.city = addressMap["city"] as? String
|
|
513
|
+
address.postalCode = addressMap["postalCode"] as? String
|
|
514
|
+
address.country = addressMap["country"] as? String
|
|
515
|
+
address.line1 = addressMap["line1"] as? String
|
|
516
|
+
address.line2 = addressMap["line2"] as? String
|
|
517
|
+
address.state = addressMap["state"] as? String
|
|
507
518
|
}
|
|
508
519
|
|
|
509
520
|
billing.address = address
|
|
@@ -718,7 +729,7 @@ class Mappers {
|
|
|
718
729
|
}
|
|
719
730
|
|
|
720
731
|
intent.setValue(types, forKey: "paymentMethodTypes")
|
|
721
|
-
intent.setValue(
|
|
732
|
+
intent.setValue(convertDateToUnixTimestampMilliseconds(date: setupIntent.created), forKey: "created")
|
|
722
733
|
|
|
723
734
|
if let lastSetupError = setupIntent.lastSetupError {
|
|
724
735
|
let setupError: NSMutableDictionary = [
|
|
@@ -928,13 +939,21 @@ class Mappers {
|
|
|
928
939
|
return uiCustomization
|
|
929
940
|
}
|
|
930
941
|
|
|
931
|
-
class func
|
|
942
|
+
class func convertDateToUnixTimestampMilliseconds(date: Date?) -> String? {
|
|
932
943
|
if let date = date {
|
|
933
944
|
let value = date.timeIntervalSince1970 * 1000.0
|
|
934
945
|
return String(format: "%.0f", value)
|
|
935
946
|
}
|
|
936
947
|
return nil
|
|
937
948
|
}
|
|
949
|
+
|
|
950
|
+
class func convertDateToUnixTimestampSeconds(date: Date?) -> String? {
|
|
951
|
+
if let date = date {
|
|
952
|
+
let value = date.timeIntervalSince1970
|
|
953
|
+
return String(format: "%.0f", value)
|
|
954
|
+
}
|
|
955
|
+
return nil
|
|
956
|
+
}
|
|
938
957
|
|
|
939
958
|
class func mapFromCardValidationState(state: STPCardValidationState?) -> String {
|
|
940
959
|
if let state = state {
|
|
@@ -158,7 +158,7 @@ class PaymentMethodFactory {
|
|
|
158
158
|
private func createCardPaymentMethodParams() throws -> STPPaymentMethodParams {
|
|
159
159
|
if let token = paymentMethodData?["token"] as? String {
|
|
160
160
|
let methodParams = STPPaymentMethodCardParams()
|
|
161
|
-
methodParams.token =
|
|
161
|
+
methodParams.token = token
|
|
162
162
|
return STPPaymentMethodParams(card: methodParams, billingDetails: billingDetailsParams, metadata: nil)
|
|
163
163
|
}
|
|
164
164
|
|
package/ios/StripeSdk.m
CHANGED
package/ios/StripeSdk.swift
CHANGED
|
@@ -29,6 +29,7 @@ class StripeSdk: RCTEventEmitter, STPBankSelectionViewControllerDelegate, UIAdap
|
|
|
29
29
|
|
|
30
30
|
var applePaymentAuthorizationController: PKPaymentAuthorizationViewController? = nil
|
|
31
31
|
var createPlatformPayPaymentMethodResolver: RCTPromiseResolveBlock? = nil
|
|
32
|
+
var platformPayUsesDeprecatedTokenFlow = false
|
|
32
33
|
var applePaymentMethodFlowCanBeCanceled = false
|
|
33
34
|
|
|
34
35
|
var confirmPaymentClientSecret: String? = nil
|
|
@@ -93,10 +94,10 @@ class StripeSdk: RCTEventEmitter, STPBankSelectionViewControllerDelegate, UIAdap
|
|
|
93
94
|
StripeAPI.defaultPublishableKey = publishableKey
|
|
94
95
|
STPAPIClient.shared.stripeAccount = stripeAccountId
|
|
95
96
|
|
|
96
|
-
let name =
|
|
97
|
-
let partnerId =
|
|
98
|
-
let version =
|
|
99
|
-
let url =
|
|
97
|
+
let name = appInfo["name"] as? String ?? ""
|
|
98
|
+
let partnerId = appInfo["partnerId"] as? String ?? ""
|
|
99
|
+
let version = appInfo["version"] as? String ?? ""
|
|
100
|
+
let url = appInfo["url"] as? String ?? ""
|
|
100
101
|
|
|
101
102
|
STPAPIClient.shared.appInfo = STPAppInfo(name: name, partnerId: partnerId, version: version, url: url)
|
|
102
103
|
self.merchantIdentifier = merchantIdentifier
|
|
@@ -536,8 +537,9 @@ class StripeSdk: RCTEventEmitter, STPBankSelectionViewControllerDelegate, UIAdap
|
|
|
536
537
|
resolve(StripeAPI.deviceSupportsApplePay())
|
|
537
538
|
}
|
|
538
539
|
|
|
539
|
-
@objc(createPlatformPayPaymentMethod:resolver:rejecter:)
|
|
540
|
+
@objc(createPlatformPayPaymentMethod:usesDeprecatedTokenFlow:resolver:rejecter:)
|
|
540
541
|
func createPlatformPayPaymentMethod(params: NSDictionary,
|
|
542
|
+
usesDeprecatedTokenFlow: Bool,
|
|
541
543
|
resolver resolve: @escaping RCTPromiseResolveBlock,
|
|
542
544
|
rejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
543
545
|
guard let applePayPatams = params["applePay"] as? NSDictionary else {
|
|
@@ -554,6 +556,7 @@ class StripeSdk: RCTEventEmitter, STPBankSelectionViewControllerDelegate, UIAdap
|
|
|
554
556
|
self.applePayShippingMethods = paymentRequest.shippingMethods ?? []
|
|
555
557
|
self.applePayShippingAddressErrors = nil
|
|
556
558
|
self.applePayCouponCodeErrors = nil
|
|
559
|
+
platformPayUsesDeprecatedTokenFlow = usesDeprecatedTokenFlow
|
|
557
560
|
applePaymentMethodFlowCanBeCanceled = true
|
|
558
561
|
createPlatformPayPaymentMethodResolver = resolve
|
|
559
562
|
self.applePaymentAuthorizationController = PKPaymentAuthorizationViewController(paymentRequest: paymentRequest)
|
package/jest/mock.js
CHANGED
|
@@ -34,6 +34,9 @@ const mockFunctions = {
|
|
|
34
34
|
dismissPlatformPay: jest.fn(async () => true),
|
|
35
35
|
createPlatformPayPaymentMethod: jest.fn(async () => ({
|
|
36
36
|
paymentMethod: {},
|
|
37
|
+
error: null,
|
|
38
|
+
})),
|
|
39
|
+
createPlatformPayToken: jest.fn(async () => ({
|
|
37
40
|
token: {},
|
|
38
41
|
error: null,
|
|
39
42
|
})),
|
|
@@ -177,6 +180,9 @@ const mockHooks = {
|
|
|
177
180
|
createPlatformPayPaymentMethod: jest.fn(async () => ({
|
|
178
181
|
...mockFunctions.createPlatformPayPaymentMethod(),
|
|
179
182
|
})),
|
|
183
|
+
createPlatformPayToken: jest.fn(async () => ({
|
|
184
|
+
...mockFunctions.createPlatformPayToken(),
|
|
185
|
+
})),
|
|
180
186
|
updatePlatformPaySheet: jest.fn(async () => ({
|
|
181
187
|
...mockFunctions.updatePlatformPaySheet(),
|
|
182
188
|
})),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["StripeSdk","NativeModules"],"sources":["NativeStripeSdk.tsx"],"sourcesContent":["import { NativeModules } from 'react-native';\nimport type {\n PaymentMethod,\n PaymentIntent,\n ApplePay,\n PlatformPay,\n PaymentSheet,\n SetupIntent,\n InitialiseParams,\n CreatePaymentMethodResult,\n RetrievePaymentIntentResult,\n RetrieveSetupIntentResult,\n ConfirmPaymentResult,\n HandleNextActionResult,\n ConfirmSetupIntentResult,\n CreateTokenForCVCUpdateResult,\n InitPaymentSheetResult,\n PresentPaymentSheetResult,\n ConfirmPaymentSheetPaymentResult,\n ApplePayResult,\n CreateTokenResult,\n GooglePayInitResult,\n PayWithGooglePayResult,\n CreateGooglePayPaymentMethodResult,\n GooglePay,\n OpenApplePaySetupResult,\n Token,\n VerifyMicrodepositsParams,\n IsCardInWalletResult,\n CanAddCardToWalletParams,\n CanAddCardToWalletResult,\n FinancialConnections,\n} from './types';\n\ntype NativeStripeSdkType = {\n initialise(params: InitialiseParams): Promise<void>;\n createPaymentMethod(\n params: PaymentMethod.CreateParams,\n options: PaymentMethod.CreateOptions\n ): Promise<CreatePaymentMethodResult>;\n handleNextAction(\n paymentIntentClientSecret: string,\n returnURL?: string | null\n ): Promise<HandleNextActionResult>;\n confirmPayment(\n paymentIntentClientSecret: string,\n params?: PaymentIntent.ConfirmParams,\n options?: PaymentIntent.ConfirmOptions\n ): Promise<ConfirmPaymentResult>;\n isApplePaySupported(): Promise<boolean>;\n presentApplePay(params: ApplePay.PresentParams): Promise<ApplePayResult>;\n confirmApplePayPayment(clientSecret: string): Promise<void>;\n updateApplePaySummaryItems(\n summaryItems: ApplePay.CartSummaryItem[],\n errorAddressFields: Array<{\n field: ApplePay.AddressFields;\n message?: string;\n }>\n ): Promise<void>;\n confirmSetupIntent(\n paymentIntentClientSecret: string,\n params: SetupIntent.ConfirmParams,\n options: SetupIntent.ConfirmOptions\n ): Promise<ConfirmSetupIntentResult>;\n retrievePaymentIntent(\n clientSecret: string\n ): Promise<RetrievePaymentIntentResult>;\n retrieveSetupIntent(clientSecret: string): Promise<RetrieveSetupIntentResult>;\n initPaymentSheet(\n params: PaymentSheet.SetupParams\n ): Promise<InitPaymentSheetResult>;\n presentPaymentSheet(): Promise<PresentPaymentSheetResult>;\n confirmPaymentSheetPayment(): Promise<ConfirmPaymentSheetPaymentResult>;\n createTokenForCVCUpdate(cvc: string): Promise<CreateTokenForCVCUpdateResult>;\n handleURLCallback(url: string): Promise<boolean>;\n createToken(params: Token.CreateParams): Promise<CreateTokenResult>;\n isGooglePaySupported(params: GooglePay.IsSupportedParams): Promise<boolean>;\n initGooglePay(params: GooglePay.InitParams): Promise<GooglePayInitResult>;\n presentGooglePay(\n params: GooglePay.PresentParams\n ): Promise<PayWithGooglePayResult>;\n createGooglePayPaymentMethod(\n params: GooglePay.CreatePaymentMethodParams\n ): Promise<CreateGooglePayPaymentMethodResult>;\n openApplePaySetup(): Promise<OpenApplePaySetupResult>;\n verifyMicrodeposits(\n isPaymentIntent: boolean,\n clientSecret: string,\n params: VerifyMicrodepositsParams\n ): Promise<ConfirmSetupIntentResult | ConfirmPaymentResult>;\n collectBankAccount(\n isPaymentIntent: boolean,\n clientSecret: string,\n params: PaymentMethod.CollectBankAccountParams\n ): Promise<ConfirmSetupIntentResult | ConfirmPaymentResult>;\n getConstants(): { API_VERSIONS: { CORE: string; ISSUING: string } };\n canAddCardToWallet(\n params: CanAddCardToWalletParams\n ): Promise<CanAddCardToWalletResult>;\n isCardInWallet(params: {\n cardLastFour: string;\n }): Promise<IsCardInWalletResult>;\n collectBankAccountToken(\n clientSecret: string\n ): Promise<FinancialConnections.TokenResult>;\n collectFinancialConnectionsAccounts(\n clientSecret: string\n ): Promise<FinancialConnections.SessionResult>;\n resetPaymentSheetCustomer(): Promise<null>;\n isPlatformPaySupported(params: {\n googlePay?: GooglePay.IsSupportedParams;\n }): Promise<boolean>;\n createPlatformPayPaymentMethod(\n params: PlatformPay.PaymentMethodParams,\n usesDeprecatedTokenFlow: boolean\n ): Promise<PlatformPay.PaymentMethodResult | PlatformPay.TokenResult>;\n dismissPlatformPay(): Promise<boolean>;\n updatePlatformPaySheet(\n summaryItems: Array<ApplePay.CartSummaryItem>,\n shippingMethods: Array<ApplePay.ShippingMethod>,\n errors: Array<PlatformPay.ApplePaySheetError>\n ): Promise<void>;\n confirmPlatformPay(\n clientSecret: string,\n params: PlatformPay.ConfirmParams,\n isPaymentIntent: boolean\n ): Promise<\n PlatformPay.ConfirmPaymentResult | PlatformPay.ConfirmSetupIntentResult\n >;\n};\n\nconst { StripeSdk } = NativeModules;\n\nexport default StripeSdk as NativeStripeSdkType;\n"],"mappings":"gFAAA,yCAmIA,GAAQA,UAAS,CAAKC,0BAAa,CAA3BD,SAAS,CAAmB,aAErBA,SAAS"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["AddToWalletButtonNative","requireNativeComponent","AddToWalletButton","onComplete","props","value","nativeEvent"],"sources":["AddToWalletButton.tsx"],"sourcesContent":["import React from 'react';\nimport {\n AccessibilityProps,\n StyleProp,\n ViewStyle,\n requireNativeComponent,\n NativeSyntheticEvent,\n ImageSourcePropType,\n} from 'react-native';\nimport type {\n Token,\n CardActionError,\n StripeError,\n GooglePayCardToken,\n} from '../types';\n\nconst AddToWalletButtonNative =\n requireNativeComponent<any>('AddToWalletButton');\n\n/**\n * Add to wallet button component props\n */\nexport interface Props extends AccessibilityProps {\n style?: StyleProp<ViewStyle>;\n /** Sets the Apple Wallet/Google Pay button style. If the button is placed over a dark background, set this to 'onDarkBackground', otherwise set to 'onLightBackground'. */\n iOSButtonStyle?: 'onDarkBackground' | 'onLightBackground';\n /** The image asset to use as the Google Pay button. Downloadable from https://developers.google.com/pay/issuers/apis/push-provisioning/android/downloads/flutter/googlepay_flutter_buttons.zip */\n androidAssetSource: ImageSourcePropType;\n testID?: string;\n /** iOS only. Set this to `true` until shipping through TestFlight || App Store. If false, you must be using live cards, and have the proper iOS entitlement set up. See https://stripe.com/docs/issuing/cards/digital-wallets?platform=react-native#requesting-access-for-ios */\n testEnv?: boolean;\n /** Details of the Issued Card you'd like added to the device's wallet */\n cardDetails: {\n /** The `primary_account_identifier` value from the issued card. */\n primaryAccountIdentifier: string | null;\n /** The card holder name (used only on iOS) */\n name: string;\n /** A user-facing description of the card. Required on Android.*/\n description: string;\n /** Last 4 digits of the card, only used on iOS */\n lastFour?: string;\n /** Optional, only used on iOS */\n brand?: Token.CardBrand;\n };\n // Optional, only for Android and only for cards that are in the \"yellow path\" (as defined by Google- https://developers.google.com/pay/issuers/apis/push-provisioning/android/wallet-operations#resolving_yellow_path). Obtain this value via the `isCardInWallet` method.\n token?: GooglePayCardToken | null;\n /** Used by stripe to securely obtain card info of the card being provisioned. */\n ephemeralKey: object;\n /** Called when the flow completes. If the `error` field is `null`, then the card was successfully added to the user's native wallet. */\n onComplete(result: { error: StripeError<CardActionError> | null }): void;\n}\n\n/**\n * Add to wallet button\n *\n * @example\n * ```ts\n * <AddToWalletButton\n * testEnv={true}\n * style={styles.myButtonStyle}\n * iOSButtonStyle=\"onLightBackground\"\n * cardDetails={{\n * primaryAccountIdentifier: \"V-123\",\n * name: \"David Wallace\",\n * lastFour: \"4242\",\n * }}\n * ephemeralKey={myEphemeralKey} // This object is retrieved from your server. See https://stripe.com/docs/issuing/cards/digital-wallets?platform=react-native#update-your-backend\n * onComplete={(error) => {\n * Alert.alert(\n * error ? error.code : 'Success',\n * error\n * ? error.message\n * : 'Card was successfully added to the wallet.'\n * );\n * }}\n * />\n * ```\n * @param __namedParameters Props\n * @returns JSX.Element\n * @category ReactComponents\n */\nexport function AddToWalletButton({ onComplete, ...props }: Props) {\n return (\n <AddToWalletButtonNative\n {...props}\n onCompleteAction={(\n value: NativeSyntheticEvent<{\n error: StripeError<CardActionError> | null;\n }>\n ) => onComplete(value.nativeEvent)}\n />\n );\n}\n"],"mappings":"wXAAA,oDACA,yCAOsB,qIAQtB,GAAMA,wBAAuB,CAC3B,GAAAC,mCAAsB,EAAM,mBAAmB,CAAC,CAgE3C,QAASC,kBAAiB,MAAkC,IAA/BC,WAAU,MAAVA,UAAU,CAAKC,KAAK,uDACtD,MACE,8BAAC,uBAAuB,0BAClBA,KAAK,EACT,gBAAgB,CAAE,0BAChBC,KAEE,QACCF,WAAU,CAACE,KAAK,CAACC,WAAW,CAAC,EAAC,6EACnC,CAEN"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["AddressSheetNative","requireNativeComponent","AddressSheet","onSubmit","onError","props","value","nativeEvent","error"],"sources":["AddressSheet.tsx"],"sourcesContent":["import React from 'react';\nimport {\n AccessibilityProps,\n requireNativeComponent,\n NativeSyntheticEvent,\n} from 'react-native';\nimport type {\n PaymentSheet,\n AddressDetails,\n StripeError,\n AddressSheetError,\n} from '../types';\n\nconst AddressSheetNative = requireNativeComponent<any>('AddressSheetView');\n\n/**\n * Props\n */\nexport interface Props extends AccessibilityProps {\n /** Whether the sheet is visible. Defaults to false. */\n visible: boolean;\n /** Controls how the modal is presented (after animation). iOS only. Defaults to `popover`. */\n presentationStyle?: 'fullscreen' | 'popover';\n /** Controls how the modal animates. iOS only. */\n animationStyle?: 'flip' | 'curl' | 'slide' | 'dissolve';\n /** Configuration for the look and feel of the UI. */\n appearance?: PaymentSheet.AppearanceParams;\n /** The values to prepopulate the sheet's fields with. */\n defaultValues?: AddressDetails;\n /** Configuration for additional fields besides the physical address */\n additionalFields?: {\n /** Determines whether the phone number is hidden, required, or optional. Defaults to hidden. */\n phoneNumber?: 'hidden' | 'optional' | 'required';\n /** The label of a checkbox displayed below other fields. If null or undefined, the checkbox is not displayed. */\n checkboxLabel?: string;\n };\n /** A list of two-letter country codes representing countries the customers can select. If the list is empty (the default), we display all countries. */\n allowedCountries?: Array<string>;\n /** A list of two-letter country codes representing countries that support address autocomplete. Defaults to a list of countries that Stripe has audited to ensure a good autocomplete experience. */\n autocompleteCountries?: Array<string>;\n /** The title of the primary button displayed at the bottom of the screen. Defaults to \"Save Address\". */\n primaryButtonTitle?: string;\n /** Title displayed at the top of the sheet. Defaults to \"Address\". */\n sheetTitle?: string;\n /** Android only. Google Places api key used to provide autocomplete suggestions. When null, autocomplete is disabled on Android. */\n googlePlacesApiKey?: string;\n /** Called when the user submits their information */\n onSubmit: (result: CollectAddressResult) => void;\n /** Called when the user taps the button to close the sheet before submitting their information, or when an error occurs. */\n onError: (error: StripeError<AddressSheetError>) => void;\n}\n\nexport type CollectAddressResult = Required<AddressDetails>;\n\n/**\n *\n *\n * @example\n * ```ts\n * <AddressSheet\n *\n * />\n * ```\n * @param __namedParameters Props\n * @returns JSX.Element\n * @category ReactComponents\n */\nexport function AddressSheet({ onSubmit, onError, ...props }: Props) {\n return (\n <AddressSheetNative\n {...props}\n onSubmitAction={(value: NativeSyntheticEvent<CollectAddressResult>) =>\n onSubmit(value.nativeEvent)\n }\n onErrorAction={(\n value: NativeSyntheticEvent<{\n error: StripeError<AddressSheetError>;\n }>\n ) => onError(value.nativeEvent.error)}\n />\n );\n}\n"],"mappings":"8WAAA,oDACA,yCAIsB,wIAQtB,GAAMA,mBAAkB,CAAG,GAAAC,mCAAsB,EAAM,kBAAkB,CAAC,CAsDnE,QAASC,aAAY,MAAyC,IAAtCC,SAAQ,MAARA,QAAQ,CAAEC,OAAO,MAAPA,OAAO,CAAKC,KAAK,uDACxD,MACE,8BAAC,kBAAkB,0BACbA,KAAK,EACT,cAAc,CAAE,wBAACC,KAAiD,QAChEH,SAAQ,CAACG,KAAK,CAACC,WAAW,CAAC,EAC5B,CACD,aAAa,CAAE,uBACbD,KAEE,QACCF,QAAO,CAACE,KAAK,CAACC,WAAW,CAACC,KAAK,CAAC,EAAC,6EACtC,CAEN"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.ApplePayButton=ApplePayButton;var _extends2=_interopRequireDefault(require("@babel/runtime/helpers/extends"));var _objectWithoutProperties2=_interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));var _react=_interopRequireWildcard(require("react"));var
|
|
1
|
+
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.ApplePayButton=ApplePayButton;var _extends2=_interopRequireDefault(require("@babel/runtime/helpers/extends"));var _objectWithoutProperties2=_interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));var _react=_interopRequireWildcard(require("react"));var _ApplePayButtonNative=_interopRequireDefault(require("./ApplePayButtonNative"));var _jsxFileName="/Users/charliecruzan/stripe/stripe-react-native/src/components/ApplePayButton.tsx";var _excluded=["onPress","buttonStyle","type","borderRadius"];function _getRequireWildcardCache(nodeInterop){if(typeof WeakMap!=="function")return null;var cacheBabelInterop=new WeakMap();var cacheNodeInterop=new WeakMap();return(_getRequireWildcardCache=function _getRequireWildcardCache(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop;})(nodeInterop);}function _interopRequireWildcard(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule){return obj;}if(obj===null||typeof obj!=="object"&&typeof obj!=="function"){return{default:obj};}var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj)){return cache.get(obj);}var newObj={};var hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj){if(key!=="default"&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;if(desc&&(desc.get||desc.set)){Object.defineProperty(newObj,key,desc);}else{newObj[key]=obj[key];}}}newObj.default=obj;if(cache){cache.set(obj,newObj);}return newObj;}function ApplePayButton(_ref){var onPress=_ref.onPress,_ref$buttonStyle=_ref.buttonStyle,buttonStyle=_ref$buttonStyle===void 0?'black':_ref$buttonStyle,_ref$type=_ref.type,type=_ref$type===void 0?'plain':_ref$type,_ref$borderRadius=_ref.borderRadius,borderRadius=_ref$borderRadius===void 0?4:_ref$borderRadius,props=(0,_objectWithoutProperties2.default)(_ref,_excluded);var buttonType=(0,_react.useMemo)(function(){return mapButtonType(type);},[type]);var style=(0,_react.useMemo)(function(){return mapButtonStyle(buttonStyle);},[buttonStyle]);return _react.default.createElement(_ApplePayButtonNative.default,(0,_extends2.default)({type:buttonType,buttonStyle:style,borderRadius:borderRadius,onPressAction:onPress},props,{__self:this,__source:{fileName:_jsxFileName,lineNumber:46,columnNumber:5}}));}function mapButtonType(type){switch(type){case'plain':return 0;case'buy':return 1;case'setUp':return 2;case'inStore':return 3;case'donate':return 4;case'checkout':return 5;case'book':return 6;case'subscribe':return 7;case'reload':return 8;case'addMoney':return 9;case'topUp':return 10;case'order':return 11;case'rent':return 12;case'support':return 13;case'contribute':return 14;case'tip':return 15;default:return 0;}}function mapButtonStyle(type){switch(type){case'white':return 0;case'whiteOutline':return 1;case'black':return 2;case'automatic':return 3;default:return 2;}}
|
|
2
2
|
//# sourceMappingURL=ApplePayButton.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["ApplePayButton","onPress","buttonStyle","type","borderRadius","props","buttonType","useMemo","mapButtonType","style","mapButtonStyle"],"sources":["ApplePayButton.tsx"],"sourcesContent":["import React, { useMemo } from 'react';\nimport ApplePayButtonNative from './ApplePayButtonNative';\nimport type { AccessibilityProps, StyleProp, ViewStyle } from 'react-native';\nimport type { ApplePayButtonComponent } from '../types';\n\n/**\n * Apple Pay Button Component Props\n */\nexport interface Props extends AccessibilityProps {\n style?: StyleProp<ViewStyle>;\n type?: ApplePayButtonComponent.Type;\n buttonStyle?: ApplePayButtonComponent.Style;\n borderRadius?: number;\n onPress(): void;\n testID?: string;\n}\n\n/**\n * Apple Pay Button Component\n *\n * @example\n * ```ts\n * <ApplePayButton\n * onPress={pay}\n * type=\"plain\"\n * buttonStyle=\"black\"\n * borderRadius={4}\n * style={styles.payButton}\n * />\n * ```\n * @param __namedParameters Props\n * @returns JSX.Element\n * @category ReactComponents\n */\nexport function ApplePayButton({\n onPress,\n buttonStyle = 'black',\n type = 'plain',\n borderRadius = 4,\n ...props\n}: Props) {\n const buttonType = useMemo(() => mapButtonType(type), [type]);\n const style = useMemo(() => mapButtonStyle(buttonStyle), [buttonStyle]);\n\n return (\n <ApplePayButtonNative\n type={buttonType}\n buttonStyle={style}\n borderRadius={borderRadius}\n onPressAction={onPress}\n {...props}\n />\n );\n}\n\nfunction mapButtonType(type: ApplePayButtonComponent.Type) {\n switch (type) {\n case 'plain':\n return 0;\n case 'buy':\n return 1;\n case 'setUp':\n return 2;\n case 'inStore':\n return 3;\n case 'donate':\n return 4;\n case 'checkout':\n return 5;\n case 'book':\n return 6;\n case 'subscribe':\n return 7;\n case 'reload':\n return 8;\n case 'addMoney':\n return 9;\n case 'topUp':\n return 10;\n case 'order':\n return 11;\n case 'rent':\n return 12;\n case 'support':\n return 13;\n case 'contribute':\n return 14;\n case 'tip':\n return 15;\n default:\n return 0;\n }\n}\n\nfunction mapButtonStyle(type: ApplePayButtonComponent.Style) {\n switch (type) {\n case 'white':\n return 0;\n case 'whiteOutline':\n return 1;\n case 'black':\n return 2;\n case 'automatic':\n return 3;\n default:\n return 2;\n }\n}\n"],"mappings":"kXAAA,qDACA,oFAA0D,6pCAiCnD,QAASA,eAAc,MAMpB,IALRC,QAAO,MAAPA,OAAO,uBACPC,WAAW,CAAXA,WAAW,2BAAG,OAAO,iCACrBC,IAAI,CAAJA,IAAI,oBAAG,OAAO,kCACdC,YAAY,CAAZA,YAAY,4BAAG,CAAC,mBACbC,KAAK,uDAER,GAAMC,WAAU,CAAG,GAAAC,cAAO,EAAC,iBAAMC,cAAa,CAACL,IAAI,CAAC,GAAE,CAACA,IAAI,CAAC,CAAC,CAC7D,GAAMM,MAAK,CAAG,GAAAF,cAAO,EAAC,iBAAMG,eAAc,CAACR,WAAW,CAAC,GAAE,CAACA,WAAW,CAAC,CAAC,CAEvE,MACE,8BAAC,6BAAoB,wBACnB,IAAI,CAAEI,UAAW,CACjB,WAAW,CAAEG,KAAM,CACnB,YAAY,CAAEL,YAAa,CAC3B,aAAa,CAAEH,OAAQ,EACnBI,KAAK,8EACT,CAEN,CAEA,QAASG,cAAa,CAACL,IAAkC,CAAE,CACzD,OAAQA,IAAI,EACV,IAAK,OAAO,CACV,MAAO,EAAC,CACV,IAAK,KAAK,CACR,MAAO,EAAC,CACV,IAAK,OAAO,CACV,MAAO,EAAC,CACV,IAAK,SAAS,CACZ,MAAO,EAAC,CACV,IAAK,QAAQ,CACX,MAAO,EAAC,CACV,IAAK,UAAU,CACb,MAAO,EAAC,CACV,IAAK,MAAM,CACT,MAAO,EAAC,CACV,IAAK,WAAW,CACd,MAAO,EAAC,CACV,IAAK,QAAQ,CACX,MAAO,EAAC,CACV,IAAK,UAAU,CACb,MAAO,EAAC,CACV,IAAK,OAAO,CACV,MAAO,GAAE,CACX,IAAK,OAAO,CACV,MAAO,GAAE,CACX,IAAK,MAAM,CACT,MAAO,GAAE,CACX,IAAK,SAAS,CACZ,MAAO,GAAE,CACX,IAAK,YAAY,CACf,MAAO,GAAE,CACX,IAAK,KAAK,CACR,MAAO,GAAE,CACX,QACE,MAAO,EAAC,CAAC,CAEf,CAEA,QAASO,eAAc,CAACP,IAAmC,CAAE,CAC3D,OAAQA,IAAI,EACV,IAAK,OAAO,CACV,MAAO,EAAC,CACV,IAAK,cAAc,CACjB,MAAO,EAAC,CACV,IAAK,OAAO,CACV,MAAO,EAAC,CACV,IAAK,WAAW,CACd,MAAO,EAAC,CACV,QACE,MAAO,EAAC,CAAC,CAEf"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _reactNative=require("react-native");var ApplePayButtonNative=(0,_reactNative.requireNativeComponent)('ApplePayButton');var _default=ApplePayButtonNative;exports.default=_default;
|
|
2
|
+
//# sourceMappingURL=ApplePayButtonNative.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["ApplePayButtonNative","requireNativeComponent"],"sources":["ApplePayButtonNative.tsx"],"sourcesContent":["import { requireNativeComponent } from 'react-native';\nimport type { ApplePayButtonComponent } from '../types';\nconst ApplePayButtonNative =\n requireNativeComponent<ApplePayButtonComponent.NativeProps>('ApplePayButton');\nexport default ApplePayButtonNative;\n"],"mappings":"gFAAA,yCAEA,GAAMA,qBAAoB,CACxB,GAAAC,mCAAsB,EAAsC,gBAAgB,CAAC,CAAC,aACjED,oBAAoB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["AuBECSDebitFormNative","requireNativeComponent","AuBECSDebitForm","onComplete","companyName","formStyle","props","value","nativeEvent"],"sources":["AuBECSDebitForm.tsx"],"sourcesContent":["import React from 'react';\nimport {\n AccessibilityProps,\n requireNativeComponent,\n StyleProp,\n ViewStyle,\n} from 'react-native';\nimport type { AuBECSDebitFormComponent } from '../types';\n\nconst AuBECSDebitFormNative =\n requireNativeComponent<AuBECSDebitFormComponent.NativeProps>(\n 'AuBECSDebitForm'\n );\n\n/**\n * BECS Debit Form Component Props\n */\nexport interface Props extends AccessibilityProps {\n companyName: string;\n onComplete(value: AuBECSDebitFormComponent.FormDetails): void;\n formStyle?: AuBECSDebitFormComponent.Styles;\n style?: StyleProp<ViewStyle>;\n testID?: string;\n}\n\n/**\n * BECS Debit form component\n *\n * @example\n * ```ts\n * <AuBECSDebitForm\n * companyName=\"Example Company Inc.\"\n * onComplete={value => onComplete(value)}\n * style={{ width: '100%', height: 500 }}\n * />\n * ```\n * @param __namedParameters Props\n * @returns JSX.Element\n * @category ReactComponents\n */\nexport function AuBECSDebitForm({\n onComplete,\n companyName,\n formStyle,\n ...props\n}: Props) {\n return (\n <AuBECSDebitFormNative\n onCompleteAction={(value) => onComplete(value.nativeEvent)}\n companyName={companyName}\n formStyle={{ ...formStyle }}\n {...props}\n />\n );\n}\n"],"mappings":"oXAAA,oDACA,yCAKsB,6JAGtB,GAAMA,sBAAqB,CACzB,GAAAC,mCAAsB,EACpB,iBAAiB,CAClB,CA4BI,QAASC,gBAAe,MAKrB,IAJRC,WAAU,MAAVA,UAAU,CACVC,WAAW,MAAXA,WAAW,CACXC,SAAS,MAATA,SAAS,CACNC,KAAK,uDAER,MACE,8BAAC,qBAAqB,wBACpB,gBAAgB,CAAE,0BAACC,KAAK,QAAKJ,WAAU,CAACI,KAAK,CAACC,WAAW,CAAC,EAAC,CAC3D,WAAW,CAAEJ,WAAY,CACzB,SAAS,kBAAOC,SAAS,CAAG,EACxBC,KAAK,8EACT,CAEN"}
|