@stripe/stripe-react-native 0.38.0 → 0.38.1
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 +7 -0
- package/README.md +31 -23
- package/android/gradle.properties +1 -1
- package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/PushProvisioningProxy.kt +1 -1
- package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/TapAndPayProxy.kt +5 -7
- package/ios/CardFormView.swift +8 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -105,6 +105,8 @@ You'll need to run `pod install` in your `ios` directory to install the native d
|
|
|
105
105
|
|
|
106
106
|
## Usage example
|
|
107
107
|
|
|
108
|
+
For a complete example, [visit our docs](https://docs.stripe.com/payments/accept-a-payment?platform=react-native).
|
|
109
|
+
|
|
108
110
|
```tsx
|
|
109
111
|
// App.ts
|
|
110
112
|
import { StripeProvider } from '@stripe/stripe-react-native';
|
|
@@ -122,33 +124,39 @@ function App() {
|
|
|
122
124
|
}
|
|
123
125
|
|
|
124
126
|
// PaymentScreen.ts
|
|
125
|
-
import {
|
|
127
|
+
import { useStripe } from '@stripe/stripe-react-native';
|
|
126
128
|
|
|
127
129
|
export default function PaymentScreen() {
|
|
128
|
-
const {
|
|
130
|
+
const { initPaymentSheet, presentPaymentSheet } = useStripe();
|
|
131
|
+
|
|
132
|
+
const setup = async () => {
|
|
133
|
+
const { error } = await initPaymentSheet({
|
|
134
|
+
merchantDisplayName: 'Example, Inc.',
|
|
135
|
+
paymentIntentClientSecret: paymentIntent, // retrieve this from your server
|
|
136
|
+
});
|
|
137
|
+
if (error) {
|
|
138
|
+
// handle error
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
useEffect(() => {
|
|
143
|
+
setup();
|
|
144
|
+
}, []);
|
|
145
|
+
|
|
146
|
+
const checkout = async () => {
|
|
147
|
+
const { error } = await presentPaymentSheet();
|
|
148
|
+
|
|
149
|
+
if (error) {
|
|
150
|
+
// handle error
|
|
151
|
+
} else {
|
|
152
|
+
// success
|
|
153
|
+
}
|
|
154
|
+
};
|
|
129
155
|
|
|
130
156
|
return (
|
|
131
|
-
<
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
number: '4242 4242 4242 4242',
|
|
135
|
-
}}
|
|
136
|
-
cardStyle={{
|
|
137
|
-
backgroundColor: '#FFFFFF',
|
|
138
|
-
textColor: '#000000',
|
|
139
|
-
}}
|
|
140
|
-
style={{
|
|
141
|
-
width: '100%',
|
|
142
|
-
height: 50,
|
|
143
|
-
marginVertical: 30,
|
|
144
|
-
}}
|
|
145
|
-
onCardChange={(cardDetails) => {
|
|
146
|
-
console.log('cardDetails', cardDetails);
|
|
147
|
-
}}
|
|
148
|
-
onFocus={(focusedField) => {
|
|
149
|
-
console.log('focusField', focusedField);
|
|
150
|
-
}}
|
|
151
|
-
/>
|
|
157
|
+
<View>
|
|
158
|
+
<Button title="Checkout" onPress={checkout} />
|
|
159
|
+
</View>
|
|
152
160
|
);
|
|
153
161
|
}
|
|
154
162
|
```
|
|
@@ -28,7 +28,7 @@ object TapAndPayProxy {
|
|
|
28
28
|
|
|
29
29
|
listTokensMethod.invoke(client) as Task<List<Any>>
|
|
30
30
|
} catch (e: Exception) {
|
|
31
|
-
Log.e(TAG, "Google TapAndPay
|
|
31
|
+
Log.e(TAG, "There was a problem listing tokens with Google TapAndPay: " + e.message)
|
|
32
32
|
null
|
|
33
33
|
}
|
|
34
34
|
}
|
|
@@ -39,7 +39,7 @@ object TapAndPayProxy {
|
|
|
39
39
|
val existingFpanLastFour = getFpanLastFourMethod.invoke(token) as String
|
|
40
40
|
existingFpanLastFour == newLastFour
|
|
41
41
|
} catch (e: Exception) {
|
|
42
|
-
Log.e(TAG, "There was a problem
|
|
42
|
+
Log.e(TAG, "There was a problem getting the FPAN with Google TapAndPay: " + e.message)
|
|
43
43
|
false
|
|
44
44
|
}
|
|
45
45
|
}
|
|
@@ -79,7 +79,7 @@ object TapAndPayProxy {
|
|
|
79
79
|
token.getInt("network"),
|
|
80
80
|
REQUEST_CODE_TOKENIZE)
|
|
81
81
|
} catch (e: Exception) {
|
|
82
|
-
Log.e(TAG, "Google TapAndPay
|
|
82
|
+
Log.e(TAG, "There was a problem tokenizing with Google TapAndPay: " + e.message)
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
|
|
@@ -114,8 +114,7 @@ object TapAndPayProxy {
|
|
|
114
114
|
"serviceProvider",
|
|
115
115
|
tokenInfoClass.getMethod("getTokenServiceProvider").invoke(it) as Int)
|
|
116
116
|
} catch (e: Exception) {
|
|
117
|
-
Log.e(TAG,
|
|
118
|
-
"There was a problem finding the class com.google.android.gms.tapandpay.issuer.TokenInfo. Make sure you've included Google's TapAndPay dependency.")
|
|
117
|
+
Log.e(TAG, "There was a problem mapping the token information with Google TapAndPay: " + e.message)
|
|
119
118
|
}
|
|
120
119
|
}
|
|
121
120
|
return result
|
|
@@ -134,8 +133,7 @@ object TapAndPayProxy {
|
|
|
134
133
|
else -> "UNKNOWN"
|
|
135
134
|
}
|
|
136
135
|
} catch (e: Exception) {
|
|
137
|
-
Log.e(TAG,
|
|
138
|
-
"There was a problem finding Google's TapAndPay dependency.")
|
|
136
|
+
Log.e(TAG, "There was a problem mapping the token state with Google TapAndPay: " + e.message)
|
|
139
137
|
return "UNKNOWN"
|
|
140
138
|
}
|
|
141
139
|
}
|
package/ios/CardFormView.swift
CHANGED
|
@@ -13,9 +13,7 @@ class CardFormView: UIView, STPCardFormViewDelegate {
|
|
|
13
13
|
@objc var disabled: Bool = false
|
|
14
14
|
@objc var preferredNetworks: Array<Int>? {
|
|
15
15
|
didSet {
|
|
16
|
-
|
|
17
|
-
cardForm?.preferredNetworks = preferredNetworks.map(Mappers.intToCardBrand).compactMap { $0 }
|
|
18
|
-
}
|
|
16
|
+
setPreferredNetworks()
|
|
19
17
|
}
|
|
20
18
|
}
|
|
21
19
|
|
|
@@ -36,6 +34,7 @@ class CardFormView: UIView, STPCardFormViewDelegate {
|
|
|
36
34
|
self.cardForm = _cardForm
|
|
37
35
|
self.addSubview(_cardForm)
|
|
38
36
|
setStyles()
|
|
37
|
+
setPreferredNetworks()
|
|
39
38
|
}
|
|
40
39
|
|
|
41
40
|
@objc var cardStyle: NSDictionary = NSDictionary() {
|
|
@@ -107,6 +106,12 @@ class CardFormView: UIView, STPCardFormViewDelegate {
|
|
|
107
106
|
// }
|
|
108
107
|
}
|
|
109
108
|
|
|
109
|
+
func setPreferredNetworks() {
|
|
110
|
+
if let preferredNetworks = preferredNetworks {
|
|
111
|
+
cardForm?.preferredNetworks = preferredNetworks.map(Mappers.intToCardBrand).compactMap { $0 }
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
110
115
|
override init(frame: CGRect) {
|
|
111
116
|
super.init(frame: frame)
|
|
112
117
|
}
|