@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 CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.38.1 - 2024-06-28
6
+
7
+ **Fixes**
8
+
9
+ - Fixed `preferredNetworks` prop on CardForm on iOS not always being applied
10
+ - Updated `stripe-android` to 20.47.3
11
+
5
12
  ## 0.38.0 - 2024-05-24
6
13
 
7
14
  **Features**
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 { CardField, useStripe } from '@stripe/stripe-react-native';
127
+ import { useStripe } from '@stripe/stripe-react-native';
126
128
 
127
129
  export default function PaymentScreen() {
128
- const { confirmPayment } = useStripe();
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
- <CardField
132
- postalCodeEnabled={true}
133
- placeholders={{
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
  ```
@@ -1,3 +1,3 @@
1
1
  StripeSdk_kotlinVersion=1.8.0
2
2
  # Keep StripeSdk_stripeVersion in sync with https://github.com/stripe/stripe-identity-react-native/blob/main/android/gradle.properties
3
- StripeSdk_stripeVersion=20.44.+
3
+ StripeSdk_stripeVersion=20.47.3
@@ -65,7 +65,7 @@ object PushProvisioningProxy {
65
65
  )
66
66
  }
67
67
  } catch (e: Exception) {
68
- Log.e(TAG, "PushProvisioning dependency not found")
68
+ Log.e(TAG, "There was a problem using Stripe Android PushProvisioning: " + e.message)
69
69
  }
70
70
  }
71
71
 
@@ -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 dependency not found")
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 finding the class com.google.android.gms.tapandpay.issuer.TokenInfo. Make sure you've included Google's TapAndPay dependency.")
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 dependency not found.")
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
  }
@@ -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
- if let preferredNetworks = preferredNetworks {
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stripe/stripe-react-native",
3
- "version": "0.38.0",
3
+ "version": "0.38.1",
4
4
  "author": "Stripe",
5
5
  "description": "Stripe SDK for React Native",
6
6
  "main": "lib/commonjs/index",