Skip to content

Commit

Permalink
Update native libraries & add support for google pay amount & label p…
Browse files Browse the repository at this point in the history
…arams (#1511)

* Update native libraries

* changelog
  • Loading branch information
charliecruzan-stripe authored Sep 21, 2023
1 parent 48b547c commit 17e3553
Show file tree
Hide file tree
Showing 13 changed files with 124 additions and 68 deletions.
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,27 @@

## Unreleased

**Features**

- Added the `amount` and `label` params to `initPaymentSheet`'s `googlePay` field configuration. Use this to diplay the amount for setup intents.
- Added the `amount` and `label` params `createPlatformPayPaymentMethod`, `confirmPlatformPayPayment`, and `confirmPlatformPaySetupIntent`.
- PaymentSheet now supports the following payment methods on both iOS and Android (previously some of the following were iOS only) for SetupIntents and PaymentIntents with setup for future usage:
- Alipay
- BECS Direct Debit
- Cash App Pay
- iDEAL
- SEPA
- Sofort
- Bancontact
- BLIK
- Boleto
- Revolut Pay
- OXXO (PaymentIntents only)
- Konbini (PaymentIntents only)
- PaymentSheet now supports the following payment methods on iOS only for SetupIntents and PaymentIntents with setup for future usage:
- PayNow
- PromptPay

## 0.32.0 - 2023-09-15

**Features**
Expand Down
2 changes: 1 addition & 1 deletion android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
StripeSdk_kotlinVersion=1.8.0
# Keep StripeSdk_stripeVersion in sync with https://github.com/stripe/stripe-identity-react-native/blob/main/android/gradle.properties
StripeSdk_stripeVersion=20.29.+
StripeSdk_stripeVersion=20.31.+
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ class GooglePayLauncherFragment : Fragment() {
private lateinit var mode: Mode
private lateinit var configuration: GooglePayLauncher.Config
private lateinit var currencyCode: String
private var amount: Int? = null
private var label: String? = null
private lateinit var callback: (result: GooglePayLauncher.Result?, error: WritableMap?) -> Unit

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
Expand All @@ -47,6 +49,8 @@ class GooglePayLauncherFragment : Fragment() {
this.mode = mode
this.callback = callback
this.currencyCode = googlePayParams.getString("currencyCode") ?: "USD"
this.amount = googlePayParams.getInt("amount")
this.label = googlePayParams.getString("label")
this.configuration = GooglePayLauncher.Config(
environment = if (googlePayParams.getBoolean("testEnv")) GooglePayEnvironment.Test else GooglePayEnvironment.Production,
merchantCountryCode = googlePayParams.getString("merchantCountryCode").orEmpty(),
Expand Down Expand Up @@ -89,10 +93,10 @@ class GooglePayLauncherFragment : Fragment() {
if (isReady) {
when (mode) {
Mode.ForSetup -> {
launcher.presentForSetupIntent(clientSecret, currencyCode)
launcher.presentForSetupIntent(clientSecret, currencyCode, amount?.toLong(), label)
}
Mode.ForPayment -> {
launcher.presentForPaymentIntent(clientSecret)
launcher.presentForPaymentIntent(clientSecret, label)
}
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,14 @@ class GooglePayRequestHelper {
val countryCode = params.getString("merchantCountryCode").orEmpty()
val currencyCode = params.getString("currencyCode") ?: "USD"
val amount = params.getInt("amount")
val label = params.getString("label")

return GooglePayJsonFactory.TransactionInfo(
currencyCode = currencyCode,
totalPriceStatus = GooglePayJsonFactory.TransactionInfo.TotalPriceStatus.Estimated,
countryCode = countryCode,
totalPrice = amount,
totalPriceLabel = label,
checkoutOption = GooglePayJsonFactory.TransactionInfo.CheckoutOption.Default
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,8 @@ class PaymentLauncherFragment(
private fun isNextActionSuccessState(nextAction: StripeIntent.NextActionType?): Boolean {
return when (nextAction) {
StripeIntent.NextActionType.DisplayOxxoDetails,
StripeIntent.NextActionType.DisplayBoletoDetails,
StripeIntent.NextActionType.DisplayKonbiniDetails,
StripeIntent.NextActionType.VerifyWithMicrodeposits -> true
StripeIntent.NextActionType.RedirectToUrl,
StripeIntent.NextActionType.UseStripeSdk,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,11 +354,15 @@ class PaymentSheetFragment(
val countryCode = params.getString("merchantCountryCode").orEmpty()
val currencyCode = params.getString("currencyCode").orEmpty()
val testEnv = params.getBoolean("testEnv")
val amount = params.getString("amount")?.toLongOrNull()
val label = params.getString("label")

return PaymentSheet.GooglePayConfiguration(
environment = if (testEnv) PaymentSheet.GooglePayConfiguration.Environment.Test else PaymentSheet.GooglePayConfiguration.Environment.Production,
countryCode = countryCode,
currencyCode = currencyCode
currencyCode = currencyCode,
amount = amount,
label = label
)
}

Expand Down
12 changes: 12 additions & 0 deletions android/src/main/java/com/reactnativestripesdk/utils/Mappers.kt
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,18 @@ internal fun mapNextAction(type: NextActionType?, data: NextActionData?): Writab
NextActionType.CashAppRedirect, NextActionType.BlikAuthorize, NextActionType.UseStripeSdk, NextActionType.UpiAwaitNotification, null -> {
return null
}
NextActionType.DisplayBoletoDetails -> {
(data as? NextActionData.DisplayBoletoDetails)?.let {
nextActionMap.putString("type", "boletoVoucher")
nextActionMap.putString("voucherURL", it.hostedVoucherUrl)
}
}
NextActionType.DisplayKonbiniDetails -> {
(data as? NextActionData.DisplayKonbiniDetails)?.let {
nextActionMap.putString("type", "konbiniVoucher")
nextActionMap.putString("voucherURL", it.hostedVoucherUrl)
}
}
}
return nextActionMap
}
Expand Down
102 changes: 51 additions & 51 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -368,50 +368,50 @@ PODS:
- React-Core
- React-RCTImage
- SocketRocket (0.6.0)
- Stripe (23.15.0):
- StripeApplePay (= 23.15.0)
- StripeCore (= 23.15.0)
- StripePayments (= 23.15.0)
- StripePaymentsUI (= 23.15.0)
- StripeUICore (= 23.15.0)
- stripe-react-native (0.30.0):
- Stripe (23.16.0):
- StripeApplePay (= 23.16.0)
- StripeCore (= 23.16.0)
- StripePayments (= 23.16.0)
- StripePaymentsUI (= 23.16.0)
- StripeUICore (= 23.16.0)
- stripe-react-native (0.32.0):
- React-Core
- Stripe (~> 23.15.0)
- StripeApplePay (~> 23.15.0)
- StripeFinancialConnections (~> 23.15.0)
- StripePayments (~> 23.15.0)
- StripePaymentSheet (~> 23.15.0)
- StripePaymentsUI (~> 23.15.0)
- stripe-react-native/Tests (0.30.0):
- Stripe (~> 23.16.0)
- StripeApplePay (~> 23.16.0)
- StripeFinancialConnections (~> 23.16.0)
- StripePayments (~> 23.16.0)
- StripePaymentSheet (~> 23.16.0)
- StripePaymentsUI (~> 23.16.0)
- stripe-react-native/Tests (0.32.0):
- React-Core
- Stripe (~> 23.15.0)
- StripeApplePay (~> 23.15.0)
- StripeFinancialConnections (~> 23.15.0)
- StripePayments (~> 23.15.0)
- StripePaymentSheet (~> 23.15.0)
- StripePaymentsUI (~> 23.15.0)
- StripeApplePay (23.15.0):
- StripeCore (= 23.15.0)
- StripeCore (23.15.0)
- StripeFinancialConnections (23.15.0):
- StripeCore (= 23.15.0)
- StripeUICore (= 23.15.0)
- StripePayments (23.15.0):
- StripeCore (= 23.15.0)
- StripePayments/Stripe3DS2 (= 23.15.0)
- StripePayments/Stripe3DS2 (23.15.0):
- StripeCore (= 23.15.0)
- StripePaymentSheet (23.15.0):
- StripeApplePay (= 23.15.0)
- StripeCore (= 23.15.0)
- StripePayments (= 23.15.0)
- StripePaymentsUI (= 23.15.0)
- StripePaymentsUI (23.15.0):
- StripeCore (= 23.15.0)
- StripePayments (= 23.15.0)
- StripeUICore (= 23.15.0)
- StripeUICore (23.15.0):
- StripeCore (= 23.15.0)
- Stripe (~> 23.16.0)
- StripeApplePay (~> 23.16.0)
- StripeFinancialConnections (~> 23.16.0)
- StripePayments (~> 23.16.0)
- StripePaymentSheet (~> 23.16.0)
- StripePaymentsUI (~> 23.16.0)
- StripeApplePay (23.16.0):
- StripeCore (= 23.16.0)
- StripeCore (23.16.0)
- StripeFinancialConnections (23.16.0):
- StripeCore (= 23.16.0)
- StripeUICore (= 23.16.0)
- StripePayments (23.16.0):
- StripeCore (= 23.16.0)
- StripePayments/Stripe3DS2 (= 23.16.0)
- StripePayments/Stripe3DS2 (23.16.0):
- StripeCore (= 23.16.0)
- StripePaymentSheet (23.16.0):
- StripeApplePay (= 23.16.0)
- StripeCore (= 23.16.0)
- StripePayments (= 23.16.0)
- StripePaymentsUI (= 23.16.0)
- StripePaymentsUI (23.16.0):
- StripeCore (= 23.16.0)
- StripePayments (= 23.16.0)
- StripeUICore (= 23.16.0)
- StripeUICore (23.16.0):
- StripeCore (= 23.16.0)
- Yoga (1.14.0)
- YogaKit (1.18.1):
- Yoga (~> 1.14)
Expand Down Expand Up @@ -636,15 +636,15 @@ SPEC CHECKSUMS:
RNCPicker: 0bf8ef8f7800524f32d2bb2a8bcadd53eda0ecd1
RNScreens: 34cc502acf1b916c582c60003dc3089fa01dc66d
SocketRocket: fccef3f9c5cedea1353a9ef6ada904fde10d6608
Stripe: 04a77d66ea24646b438079d64e28e856408a3966
stripe-react-native: aaee952dff969febd66f6f5d6b7326adb729b827
StripeApplePay: 25018ddbd381d23c4a6afe776c6495b6690e2036
StripeCore: d18d981490314b875319020fb25055e528677dcc
StripeFinancialConnections: 93ec77db4be974f71e6af6c530a28fedc8e66dfc
StripePayments: 3c0bf055692bcbc420779bd2e2119e5b6049c8b9
StripePaymentSheet: 12fb5829063dc6f1ad178eb4787b6d85e4b6155f
StripePaymentsUI: 0c9413c07110770da2abc0ebd5766470374e3565
StripeUICore: c85381f005c7ee585ec4032858fc22baa7bae4ec
Stripe: fcab417424a45d995aa1e62a39bc942233b61ba3
stripe-react-native: 91be4dfebcbc1fbf20d8a33167b6527eea3ce6c3
StripeApplePay: 81de266a964b3ad02fb25e8b22fd8c235d2916a8
StripeCore: ac141047bca25f5ae945a1cbdd00a90b0d08c616
StripeFinancialConnections: d7a452e4bed1195d8978ee4f6c0ba2f82c89fdf4
StripePayments: 5804cb9b02cca488042e5cf8cf57a86a5080006b
StripePaymentSheet: 06ea6bbf49be869769c46bf31be4fbc3e23b5b19
StripePaymentsUI: 24a0349ae8c7e8c7402086703720fe06c52ddea0
StripeUICore: ce85e040a22bf0335061d14973d37757528b3d2d
Yoga: 0b84a956f7393ef1f37f3bb213c516184e4a689d
YogaKit: f782866e155069a2cca2517aafea43200b01fd5a

Expand Down
18 changes: 10 additions & 8 deletions ios/Mappers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -451,14 +451,16 @@ class Mappers {
"voucherURL": it.oxxoDisplayDetails?.hostedVoucherURL.absoluteString ?? NSNull(),
"voucherNumber": it.oxxoDisplayDetails?.number ?? NSNull(),
]
// TODO: Not supported on Android
// case .boletoDisplayDetails:
// return [
// "type": "boletoVoucher",
// "expiration": it.boletoDisplayDetails?.expiresAt.timeIntervalSince1970.description ?? NSNull(),
// "voucherURL": it.boletoDisplayDetails?.hostedVoucherURL.absoluteString ?? NSNull(),
// "voucherNumber": it.boletoDisplayDetails?.number ?? NSNull(),
// ]
case .boletoDisplayDetails:
return [
"type": "boletoVoucher",
"voucherURL": it.boletoDisplayDetails?.hostedVoucherURL.absoluteString ?? NSNull(),
]
case .konbiniDisplayDetails:
return [
"type": "konbiniVoucher",
"voucherURL": it.konbiniDisplayDetails?.hostedVoucherURL.absoluteString ?? NSNull(),
]
default: // .useStripeSDK, .BLIKAuthorize, .unknown
return nil
}
Expand Down
7 changes: 5 additions & 2 deletions src/types/NextAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,12 @@ export type AlipayRedirectAction = {

export type BoletoVoucherAction = {
type: 'boletoVoucher';
expiration: number;
voucherURL: string;
voucherNumber: string;
};

export type KonbiniVoucherAction = {
type: 'konbiniVoucher';
voucherURL: string;
};

export type OxxoVoucherAction = {
Expand Down
4 changes: 4 additions & 0 deletions src/types/PaymentSheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ export type GooglePayParams = {
currencyCode?: string;
/** Whether or not to use the Google Pay test environment. Set to `true` until you have applied for and been granted access to the Production environment. */
testEnv?: boolean;
/** An optional label to display with the amount. Google Pay may or may not display this label depending on its own internal logic. Defaults to a generic label if none is provided. */
label?: string;
/** An optional amount to display for setup intents. Google Pay may or may not display this amount depending on its own internal logic. Defaults to 0 if none is provided. */
amount?: string;
};

/**
Expand Down
6 changes: 4 additions & 2 deletions src/types/PlatformPay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,13 @@ export type GooglePayBaseParams = {
/** Defines what address fields to collect. Defaults to BillingAddressFormat.Min */
format?: BillingAddressFormat;
};
/** An optional label to display with the amount. Google Pay may or may not display this label depending on its own internal logic. Defaults to a generic label if none is provided. */
label?: string;
/** An optional amount to display for setup intents. Google Pay may or may not display this amount depending on its own internal logic. Defaults to 0 if none is provided. */
amount?: number;
};

export type GooglePayPaymentMethodParams = {
/** Total monetary value of the transaction. */
amount: number;
/** Describes the configuration for shipping address collection in the Google Pay sheet. */
shippingAddressConfig?: {
/** Set to true if shipping address is required for payment. Defaults to false. */
Expand Down
2 changes: 1 addition & 1 deletion stripe-react-native.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ require 'json'

package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
# Keep stripe_version in sync with https://github.com/stripe/stripe-identity-react-native/blob/main/stripe-identity-react-native.podspec
stripe_version = '~> 23.15.0'
stripe_version = '~> 23.16.0'

Pod::Spec.new do |s|
s.name = 'stripe-react-native'
Expand Down

0 comments on commit 17e3553

Please sign in to comment.