diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index eec7b0c79..d858b9071 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -29,7 +29,7 @@ jobs: - name: Setup Node.js environment uses: actions/setup-node@v2.1.5 with: - node-version: 14.4.0 + node-version: 14.15.0 - name: Install React Native CLI run: npm install react-native-cli @@ -41,7 +41,9 @@ jobs: - name: Run Android Emulator and app uses: reactivecircus/android-emulator-runner@v2 with: - api-level: 29 + api-level: 28 + target: google_apis + arch: x86 script: | yarn run-example-android sleep 15 @@ -88,7 +90,7 @@ jobs: - name: Setup Node.js environment uses: actions/setup-node@v2.1.5 with: - node-version: 14.4.0 + node-version: 14.15.0 - name: Install React Native CLI run: | diff --git a/.npmrc b/.npmrc index 409911452..c17894564 100644 --- a/.npmrc +++ b/.npmrc @@ -1 +1 @@ -chromedriver_version=74.0.3729.6 +chromedriver_version=2.44 diff --git a/android/src/main/java/com/reactnativestripesdk/Constants.kt b/android/src/main/java/com/reactnativestripesdk/Constants.kt index 94791591c..f615e5f59 100644 --- a/android/src/main/java/com/reactnativestripesdk/Constants.kt +++ b/android/src/main/java/com/reactnativestripesdk/Constants.kt @@ -5,3 +5,8 @@ var ON_PAYMENT_OPTION_ACTION = "com.reactnativestripesdk.PAYMENT_OPTION_ACTION" var ON_CONFIGURE_FLOW_CONTROLLER = "com.reactnativestripesdk.CONFIGURE_FLOW_CONTROLLER_ACTION" var ON_INIT_PAYMENT_SHEET = "com.reactnativestripesdk.INIT_PAYMENT_SHEET" var ON_FRAGMENT_CREATED = "com.reactnativestripesdk.FRAGMENT_CREATED_ACTION" + +var ON_GOOGLE_PAY_FRAGMENT_CREATED = "com.reactnativestripesdk.ON_GOOGLE_PAY_FRAGMENT_CREATED" +var ON_INIT_GOOGLE_PAY = "com.reactnativestripesdk.ON_INIT_GOOGLE_PAY" +var ON_GOOGLE_PAY_RESULT = "com.reactnativestripesdk.ON_GOOGLE_PAY_RESULT" +var ON_GOOGLE_PAYMENT_METHOD_RESULT = "com.reactnativestripesdk.ON_GOOGLE_PAYMENT_METHOD_RESULT" diff --git a/android/src/main/java/com/reactnativestripesdk/Errors.kt b/android/src/main/java/com/reactnativestripesdk/Errors.kt index eea67eb43..8b8229356 100644 --- a/android/src/main/java/com/reactnativestripesdk/Errors.kt +++ b/android/src/main/java/com/reactnativestripesdk/Errors.kt @@ -37,6 +37,10 @@ enum class PaymentSheetErrorType { Failed, Canceled } +enum class GooglePayErrorType { + Failed, Canceled, Unknown +} + internal fun mapError(code: String, message: String?, localizedMessage: String?, declineCode: String?, type: String?, stripeErrorCode: String?): WritableMap { val map: WritableMap = WritableNativeMap() val details: WritableMap = WritableNativeMap() diff --git a/android/src/main/java/com/reactnativestripesdk/GooglePayButtonManager.kt b/android/src/main/java/com/reactnativestripesdk/GooglePayButtonManager.kt new file mode 100644 index 000000000..19d87e49d --- /dev/null +++ b/android/src/main/java/com/reactnativestripesdk/GooglePayButtonManager.kt @@ -0,0 +1,30 @@ +package com.reactnativestripesdk + +import com.facebook.react.uimanager.SimpleViewManager +import com.facebook.react.uimanager.ThemedReactContext +import com.facebook.react.uimanager.annotations.ReactProp + +class GooglePayButtonManager : SimpleViewManager() { + override fun getName(): String { + return REACT_CLASS + } + + override fun onAfterUpdateTransaction(view: GooglePayButtonView) { + super.onAfterUpdateTransaction(view) + + view.initialize() + } + + @ReactProp(name = "buttonType") + fun buttonType(view: GooglePayButtonView, buttonType: String) { + view.setType(buttonType) + } + + override fun createViewInstance(reactContext: ThemedReactContext): GooglePayButtonView { + return GooglePayButtonView(reactContext) + } + + companion object { + const val REACT_CLASS = "GooglePayButton" + } +} diff --git a/android/src/main/java/com/reactnativestripesdk/GooglePayButtonView.kt b/android/src/main/java/com/reactnativestripesdk/GooglePayButtonView.kt new file mode 100644 index 000000000..b8f0f9ad9 --- /dev/null +++ b/android/src/main/java/com/reactnativestripesdk/GooglePayButtonView.kt @@ -0,0 +1,28 @@ +package com.reactnativestripesdk + +import android.view.LayoutInflater +import android.widget.FrameLayout +import com.facebook.react.uimanager.ThemedReactContext + +class GooglePayButtonView(private val context: ThemedReactContext) : FrameLayout(context) { + var buttonType: String? = null + + fun initialize() { + val type = when (buttonType) { + "pay" -> R.layout.pay_with_googlepay_button_no_shadow + "pay_shadow" -> R.layout.pay_with_googlepay_button + "standard_shadow" -> R.layout.googlepay_button + "standard" -> R.layout.googlepay_button_no_shadow + else -> R.layout.googlepay_button + } + val button = LayoutInflater.from(context).inflate( + type, null + ) + + addView(button) + } + + fun setType(type: String) { + buttonType = type + } +} diff --git a/android/src/main/java/com/reactnativestripesdk/GooglePayFragment.kt b/android/src/main/java/com/reactnativestripesdk/GooglePayFragment.kt new file mode 100644 index 000000000..c19951c58 --- /dev/null +++ b/android/src/main/java/com/reactnativestripesdk/GooglePayFragment.kt @@ -0,0 +1,173 @@ +package com.reactnativestripesdk + +import android.content.Intent +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.FrameLayout +import androidx.fragment.app.Fragment +import com.facebook.react.bridge.WritableNativeMap +import com.stripe.android.googlepaylauncher.GooglePayEnvironment +import com.stripe.android.googlepaylauncher.GooglePayLauncher +import com.stripe.android.googlepaylauncher.GooglePayPaymentMethodLauncher +import com.stripe.android.model.StripeIntent + +class GooglePayFragment : Fragment() { + private var googlePayLauncher: GooglePayLauncher? = null + private var googlePayMethodLauncher: GooglePayPaymentMethodLauncher? = null + + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ): View { + return FrameLayout(requireActivity()).also { + it.visibility = View.GONE + } + } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + val testEnv = arguments?.getBoolean("testEnv") + val merchantName = arguments?.getString("merchantName").orEmpty() + val countryCode = arguments?.getString("countryCode").orEmpty() + val isEmailRequired = arguments?.getBoolean("isEmailRequired") ?: false + val existingPaymentMethodRequired = arguments?.getBoolean("existingPaymentMethodRequired") ?: false + + val billingAddressConfigBundle = arguments?.getBundle("billingAddressConfig") ?: Bundle() + val isRequired = billingAddressConfigBundle.getBoolean("isRequired") + val formatString = billingAddressConfigBundle.getString("format").orEmpty() + val isPhoneNumberRequired = billingAddressConfigBundle.getBoolean("isPhoneNumberRequired") + + val billingAddressConfig = mapToGooglePayPaymentMethodLauncherBillingAddressConfig(formatString, isRequired, isPhoneNumberRequired) + + googlePayMethodLauncher = GooglePayPaymentMethodLauncher( + fragment = this, + config = GooglePayPaymentMethodLauncher.Config( + environment = if (testEnv == true) GooglePayEnvironment.Test else GooglePayEnvironment.Production, + merchantCountryCode = countryCode, + merchantName = merchantName, + billingAddressConfig = billingAddressConfig, + isEmailRequired = isEmailRequired, + existingPaymentMethodRequired = existingPaymentMethodRequired + ), + readyCallback = ::onGooglePayReady, + resultCallback = ::onGooglePayResult + ) + + val paymentMethodBillingAddressConfig = mapToGooglePayLauncherBillingAddressConfig(formatString, isRequired, isPhoneNumberRequired) + googlePayLauncher = GooglePayLauncher( + fragment = this, + config = GooglePayLauncher.Config( + environment = if (testEnv == true) GooglePayEnvironment.Test else GooglePayEnvironment.Production, + merchantCountryCode = countryCode, + merchantName = merchantName, + billingAddressConfig = paymentMethodBillingAddressConfig, + isEmailRequired = isEmailRequired, + existingPaymentMethodRequired = existingPaymentMethodRequired + ), + readyCallback = ::onGooglePayReady, + resultCallback = ::onGooglePayResult + ) + + val intent = Intent(ON_GOOGLE_PAY_FRAGMENT_CREATED) + activity?.sendBroadcast(intent) + } + + fun presentForPaymentIntent(clientSecret: String) { + val launcher = googlePayLauncher ?: run { + val intent = Intent(ON_GOOGLE_PAY_RESULT) + intent.putExtra("error", "GooglePayLauncher is not initialized.") + activity?.sendBroadcast(intent) + return + } + runCatching { + launcher.presentForPaymentIntent(clientSecret) + }.onFailure { + val intent = Intent(ON_GOOGLE_PAY_RESULT) + intent.putExtra("error", it.localizedMessage) + activity?.sendBroadcast(intent) + } + } + + fun presentForSetupIntent(clientSecret: String, currencyCode: String) { + val launcher = googlePayLauncher ?: run { + val intent = Intent(ON_GOOGLE_PAY_RESULT) + intent.putExtra("error", "GooglePayLauncher is not initialized.") + activity?.sendBroadcast(intent) + return + } + runCatching { + launcher.presentForSetupIntent(clientSecret, currencyCode) + }.onFailure { + val intent = Intent(ON_GOOGLE_PAY_RESULT) + intent.putExtra("error", it.localizedMessage) + activity?.sendBroadcast(intent) + } + } + + fun createPaymentMethod(currencyCode: String, amount: Int) { + val launcher = googlePayMethodLauncher ?: run { + val intent = Intent(ON_GOOGLE_PAYMENT_METHOD_RESULT) + intent.putExtra("error", "GooglePayPaymentMethodLauncher is not initialized.") + activity?.sendBroadcast(intent) + return + } + + runCatching { + launcher.present( + currencyCode = currencyCode, + amount = amount + ) + }.onFailure { + val intent = Intent(ON_GOOGLE_PAYMENT_METHOD_RESULT) + intent.putExtra("error", it.localizedMessage) + activity?.sendBroadcast(intent) + } + } + + private fun onGooglePayReady(isReady: Boolean) { + val intent = Intent(ON_INIT_GOOGLE_PAY) + intent.putExtra("isReady", isReady) + activity?.sendBroadcast(intent) + } + + private fun onGooglePayResult(result: GooglePayLauncher.Result) { + val intent = Intent(ON_GOOGLE_PAY_RESULT) + intent.putExtra("paymentResult", result) + activity?.sendBroadcast(intent) + } + + private fun onGooglePayResult(result: GooglePayPaymentMethodLauncher.Result) { + val intent = Intent(ON_GOOGLE_PAYMENT_METHOD_RESULT) + intent.putExtra("paymentResult", result) + activity?.sendBroadcast(intent) + } + + private fun mapToGooglePayLauncherBillingAddressConfig(formatString: String, isRequired: Boolean, isPhoneNumberRequired: Boolean): GooglePayLauncher.BillingAddressConfig { + val format = when (formatString) { + "FULL" -> GooglePayLauncher.BillingAddressConfig.Format.Full + "MIN" -> GooglePayLauncher.BillingAddressConfig.Format.Min + else -> GooglePayLauncher.BillingAddressConfig.Format.Min + } + return GooglePayLauncher.BillingAddressConfig( + isRequired = isRequired, + format = format, + isPhoneNumberRequired = isPhoneNumberRequired + ) + } + + private fun mapToGooglePayPaymentMethodLauncherBillingAddressConfig(formatString: String, isRequired: Boolean, isPhoneNumberRequired: Boolean): GooglePayPaymentMethodLauncher.BillingAddressConfig { + val format = when (formatString) { + "FULL" -> GooglePayPaymentMethodLauncher.BillingAddressConfig.Format.Full + "MIN" -> GooglePayPaymentMethodLauncher.BillingAddressConfig.Format.Min + else -> GooglePayPaymentMethodLauncher.BillingAddressConfig.Format.Min + } + return GooglePayPaymentMethodLauncher.BillingAddressConfig( + isRequired = isRequired, + format = format, + isPhoneNumberRequired = isPhoneNumberRequired + ) + } +} diff --git a/android/src/main/java/com/reactnativestripesdk/Mappers.kt b/android/src/main/java/com/reactnativestripesdk/Mappers.kt index d17557cf7..2be43650a 100644 --- a/android/src/main/java/com/reactnativestripesdk/Mappers.kt +++ b/android/src/main/java/com/reactnativestripesdk/Mappers.kt @@ -1,5 +1,7 @@ package com.reactnativestripesdk +import android.os.Bundle +import android.util.Log import com.facebook.react.bridge.* import com.stripe.android.PaymentAuthConfig import com.stripe.android.model.* @@ -702,3 +704,28 @@ fun mapToPaymentIntentFutureUsage(type: String?): ConfirmPaymentIntentParams.Set else -> null } } + +fun toBundleObject(readableMap: ReadableMap?): Bundle? { + val result = Bundle() + if (readableMap == null) { + return result + } + val iterator = readableMap.keySetIterator() + while (iterator.hasNextKey()) { + val key = iterator.nextKey() + when (readableMap.getType(key)) { + ReadableType.Null -> result.putString(key, null) + ReadableType.Boolean -> result.putBoolean(key, readableMap.getBoolean(key)) + ReadableType.Number -> try { + result.putInt(key, readableMap.getInt(key)) + } catch (e: Exception) { + result.putDouble(key, readableMap.getDouble(key)) + } + ReadableType.String -> result.putString(key, readableMap.getString(key)) + ReadableType.Map -> result.putBundle(key, toBundleObject(readableMap.getMap(key))) + ReadableType.Array -> Log.e("toBundleException", "Cannot put arrays of objects into bundles. Failed on: $key.") + else -> Log.e("toBundleException", "Could not convert object with key: $key.") + } + } + return result +} diff --git a/android/src/main/java/com/reactnativestripesdk/PaymentSheetFragment.kt b/android/src/main/java/com/reactnativestripesdk/PaymentSheetFragment.kt index 7d74da5fc..47ae4d5cf 100644 --- a/android/src/main/java/com/reactnativestripesdk/PaymentSheetFragment.kt +++ b/android/src/main/java/com/reactnativestripesdk/PaymentSheetFragment.kt @@ -41,7 +41,7 @@ class PaymentSheetFragment : Fragment() { val merchantDisplayName = arguments?.getString("merchantDisplayName").orEmpty() val customerId = arguments?.getString("customerId").orEmpty() val customerEphemeralKeySecret = arguments?.getString("customerEphemeralKeySecret").orEmpty() - val countryCode = arguments?.getString("countryCode").orEmpty() + val countryCode = arguments?.getString("merchantCountryCode").orEmpty() val googlePayEnabled = arguments?.getBoolean("googlePay") val testEnv = arguments?.getBoolean("testEnv") paymentIntentClientSecret = arguments?.getString("paymentIntentClientSecret").orEmpty() diff --git a/android/src/main/java/com/reactnativestripesdk/StripeSdkModule.kt b/android/src/main/java/com/reactnativestripesdk/StripeSdkModule.kt index f8dbdeb7a..6992023a6 100644 --- a/android/src/main/java/com/reactnativestripesdk/StripeSdkModule.kt +++ b/android/src/main/java/com/reactnativestripesdk/StripeSdkModule.kt @@ -14,6 +14,8 @@ import androidx.appcompat.app.AppCompatActivity import androidx.lifecycle.lifecycleScope import com.facebook.react.bridge.* import com.stripe.android.* +import com.stripe.android.googlepaylauncher.GooglePayLauncher +import com.stripe.android.googlepaylauncher.GooglePayPaymentMethodLauncher import com.stripe.android.model.* import com.stripe.android.paymentsheet.PaymentSheetResult import com.stripe.android.view.AddPaymentMethodActivityStarter @@ -41,6 +43,10 @@ class StripeSdkModule(reactContext: ReactApplicationContext, cardFieldManager: S private var initPaymentSheetPromise: Promise? = null private var confirmPaymentClientSecret: String? = null + private var googlePayFragment: GooglePayFragment? = null + private var initGooglePayPromise: Promise? = null + private var presentGooglePayPromise: Promise? = null + private val mActivityEventListener = object : BaseActivityEventListener() { override fun onActivityResult(activity: Activity, requestCode: Int, resultCode: Int, data: Intent?) { if (::stripe.isInitialized) { @@ -125,6 +131,7 @@ class StripeSdkModule(reactContext: ReactApplicationContext, cardFieldManager: S }) paymentSheetFragment?.activity?.activityResultRegistry?.dispatchResult(requestCode, resultCode, data) + googlePayFragment?.activity?.activityResultRegistry?.dispatchResult(requestCode, resultCode, data) try { val result = AddPaymentMethodActivityStarter.Result.fromIntent(data) @@ -158,6 +165,51 @@ class StripeSdkModule(reactContext: ReactApplicationContext, cardFieldManager: S ) } + private val googlePayReceiver: BroadcastReceiver = object : BroadcastReceiver() { + override fun onReceive(context: Context?, intent: Intent) { + if (intent.action == ON_GOOGLE_PAY_FRAGMENT_CREATED) { + googlePayFragment = (currentActivity as AppCompatActivity).supportFragmentManager.findFragmentByTag("google_pay_launch_fragment") as GooglePayFragment + } + if (intent.action == ON_INIT_GOOGLE_PAY) { + initGooglePayPromise?.resolve(WritableNativeMap()) + } + if (intent.action == ON_GOOGLE_PAYMENT_METHOD_RESULT) { + intent.extras?.getString("error")?.let { + presentGooglePayPromise?.resolve(createError(GooglePayErrorType.Failed.toString(), it)) + return + } + when (val result = intent.extras?.getParcelable("paymentResult")) { + is GooglePayPaymentMethodLauncher.Result.Completed -> { + presentGooglePayPromise?.resolve(createResult("paymentMethod", mapFromPaymentMethod(result.paymentMethod))) + } + GooglePayPaymentMethodLauncher.Result.Canceled -> { + presentGooglePayPromise?.resolve(createError(GooglePayErrorType.Failed.toString(), "Google Pay has been canceled")) + } + is GooglePayPaymentMethodLauncher.Result.Failed -> { + presentGooglePayPromise?.resolve(createError(GooglePayErrorType.Failed.toString(), result.error)) + } + } + } + if (intent.action == ON_GOOGLE_PAY_RESULT) { + intent.extras?.getString("error")?.let { + presentGooglePayPromise?.resolve(createError(GooglePayErrorType.Failed.toString(), it)) + return + } + when (val result = intent.extras?.getParcelable("paymentResult")) { + GooglePayLauncher.Result.Completed -> { + presentGooglePayPromise?.resolve(WritableNativeMap()) + } + GooglePayLauncher.Result.Canceled -> { + presentGooglePayPromise?.resolve(createError(GooglePayErrorType.Failed.toString(), "Google Pay has been canceled")) + } + is GooglePayLauncher.Result.Failed -> { + presentGooglePayPromise?.resolve(createError(GooglePayErrorType.Failed.toString(), result.error)) + } + } + } + } + } + private val mPaymentSheetReceiver: BroadcastReceiver = object : BroadcastReceiver() { override fun onReceive(context: Context?, intent: Intent) { if (intent.action == ON_FRAGMENT_CREATED) { @@ -241,6 +293,11 @@ class StripeSdkModule(reactContext: ReactApplicationContext, cardFieldManager: S this.currentActivity?.registerReceiver(mPaymentSheetReceiver, IntentFilter(ON_FRAGMENT_CREATED)); this.currentActivity?.registerReceiver(mPaymentSheetReceiver, IntentFilter(ON_INIT_PAYMENT_SHEET)); + this.currentActivity?.registerReceiver(googlePayReceiver, IntentFilter(ON_GOOGLE_PAY_FRAGMENT_CREATED)) + this.currentActivity?.registerReceiver(googlePayReceiver, IntentFilter(ON_INIT_GOOGLE_PAY)) + this.currentActivity?.registerReceiver(googlePayReceiver, IntentFilter(ON_GOOGLE_PAY_RESULT)) + this.currentActivity?.registerReceiver(googlePayReceiver, IntentFilter(ON_GOOGLE_PAYMENT_METHOD_RESULT)) + promise.resolve(null) } @@ -252,30 +309,11 @@ class StripeSdkModule(reactContext: ReactApplicationContext, cardFieldManager: S promise.resolve(createError("Failed", "Activity doesn't exist")) return } - val customFlow = getBooleanOrNull(params, "customFlow") ?: false - val customerId = getValOr(params, "customerId") - val customerEphemeralKeySecret = getValOr(params, "customerEphemeralKeySecret") - val paymentIntentClientSecret = getValOr(params, "paymentIntentClientSecret") - val setupIntentClientSecret = getValOr(params, "setupIntentClientSecret") - val merchantDisplayName = getValOr(params, "merchantDisplayName") - val countryCode = getValOr(params, "merchantCountryCode") - val testEnv = getBooleanOrNull(params, "testEnv") ?: false - val googlePay = getBooleanOrNull(params, "googlePay") ?: false this.initPaymentSheetPromise = promise val fragment = PaymentSheetFragment().also { - val bundle = Bundle() - bundle.putString("customerId", customerId) - bundle.putString("customerEphemeralKeySecret", customerEphemeralKeySecret) - bundle.putString("paymentIntentClientSecret", paymentIntentClientSecret) - bundle.putString("setupIntentClientSecret", setupIntentClientSecret) - bundle.putString("merchantDisplayName", merchantDisplayName) - bundle.putString("countryCode", countryCode) - bundle.putBoolean("customFlow", customFlow) - bundle.putBoolean("testEnv", testEnv) - bundle.putBoolean("googlePay", googlePay) - + val bundle = toBundleObject(params) it.arguments = bundle } activity.supportFragmentManager.beginTransaction() @@ -523,6 +561,54 @@ class StripeSdkModule(reactContext: ReactApplicationContext, cardFieldManager: S } } + @ReactMethod + fun initGooglePay(params: ReadableMap, promise: Promise) { + val activity = currentActivity as AppCompatActivity + val fragment = GooglePayFragment().also { + val bundle = toBundleObject(params) + it.arguments = bundle + } + + initGooglePayPromise = promise + + activity.supportFragmentManager.beginTransaction() + .add(fragment, "google_pay_launch_fragment") + .commit() + } + + @ReactMethod + fun presentGooglePay(params: ReadableMap, promise: Promise) { + val clientSecret = getValOr(params, "clientSecret") ?: run { + promise.resolve(createError(GooglePayErrorType.Failed.toString(), "you must provide clientSecret")) + return + } + presentGooglePayPromise = promise + if (getBooleanOrFalse(params, "forSetupIntent")) { + val currencyCode = getValOr(params, "currencyCode") ?: run { + promise.resolve(createError(GooglePayErrorType.Failed.toString(), "you must provide currencyCode")) + return + } + googlePayFragment?.presentForSetupIntent(clientSecret, currencyCode) + } else { + googlePayFragment?.presentForPaymentIntent(clientSecret) + } + } + + @ReactMethod + fun createGooglePayPaymentMethod(params: ReadableMap, promise: Promise) { + val currencyCode = getValOr(params, "currencyCode", null) ?: run { + promise.resolve(createError(GooglePayErrorType.Failed.toString(), "you must provide currencyCode")) + return + } + val amount = getIntOrNull(params, "amount") ?: run { + promise.resolve(createError(GooglePayErrorType.Failed.toString(), "you must provide amount")) + return + } + presentGooglePayPromise = promise + googlePayFragment?.createPaymentMethod(currencyCode, amount) + } + + /// Check paymentIntent.nextAction is voucher-based payment method. /// If it's voucher-based, the paymentIntent status stays in requiresAction until the voucher is paid or expired. /// Currently only OXXO payment is voucher-based. diff --git a/android/src/main/java/com/reactnativestripesdk/StripeSdkPackage.kt b/android/src/main/java/com/reactnativestripesdk/StripeSdkPackage.kt index a140b026c..e37bf9fdf 100644 --- a/android/src/main/java/com/reactnativestripesdk/StripeSdkPackage.kt +++ b/android/src/main/java/com/reactnativestripesdk/StripeSdkPackage.kt @@ -21,6 +21,6 @@ class StripeSdkPackage : ReactPackage { if (!this::cardFieldManager.isInitialized) { cardFieldManager = StripeSdkCardViewManager() } - return Arrays.asList>(cardFieldManager, AuBECSDebitFormViewManager(), StripeContainerManager()) + return Arrays.asList>(cardFieldManager, AuBECSDebitFormViewManager(), StripeContainerManager(), GooglePayButtonManager()) } } diff --git a/android/src/main/res/drawable-ar-night/pay_with_googlepay_button_content.xml b/android/src/main/res/drawable-ar-night/pay_with_googlepay_button_content.xml new file mode 100755 index 000000000..1fec38767 --- /dev/null +++ b/android/src/main/res/drawable-ar-night/pay_with_googlepay_button_content.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/android/src/main/res/drawable-ar/pay_with_googlepay_button_content.xml b/android/src/main/res/drawable-ar/pay_with_googlepay_button_content.xml new file mode 100755 index 000000000..1f8f2fb68 --- /dev/null +++ b/android/src/main/res/drawable-ar/pay_with_googlepay_button_content.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/android/src/main/res/drawable-bg-night/pay_with_googlepay_button_content.xml b/android/src/main/res/drawable-bg-night/pay_with_googlepay_button_content.xml new file mode 100755 index 000000000..1f3c00268 --- /dev/null +++ b/android/src/main/res/drawable-bg-night/pay_with_googlepay_button_content.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/android/src/main/res/drawable-bg/pay_with_googlepay_button_content.xml b/android/src/main/res/drawable-bg/pay_with_googlepay_button_content.xml new file mode 100755 index 000000000..628df018f --- /dev/null +++ b/android/src/main/res/drawable-bg/pay_with_googlepay_button_content.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/android/src/main/res/drawable-ca-night/pay_with_googlepay_button_content.xml b/android/src/main/res/drawable-ca-night/pay_with_googlepay_button_content.xml new file mode 100755 index 000000000..c234377c9 --- /dev/null +++ b/android/src/main/res/drawable-ca-night/pay_with_googlepay_button_content.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/android/src/main/res/drawable-ca/pay_with_googlepay_button_content.xml b/android/src/main/res/drawable-ca/pay_with_googlepay_button_content.xml new file mode 100755 index 000000000..17310dd69 --- /dev/null +++ b/android/src/main/res/drawable-ca/pay_with_googlepay_button_content.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/android/src/main/res/drawable-cs-night/pay_with_googlepay_button_content.xml b/android/src/main/res/drawable-cs-night/pay_with_googlepay_button_content.xml new file mode 100755 index 000000000..91fc12463 --- /dev/null +++ b/android/src/main/res/drawable-cs-night/pay_with_googlepay_button_content.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/android/src/main/res/drawable-cs/pay_with_googlepay_button_content.xml b/android/src/main/res/drawable-cs/pay_with_googlepay_button_content.xml new file mode 100755 index 000000000..64c604fa6 --- /dev/null +++ b/android/src/main/res/drawable-cs/pay_with_googlepay_button_content.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/android/src/main/res/drawable-da-night/pay_with_googlepay_button_content.xml b/android/src/main/res/drawable-da-night/pay_with_googlepay_button_content.xml new file mode 100755 index 000000000..4162dd38a --- /dev/null +++ b/android/src/main/res/drawable-da-night/pay_with_googlepay_button_content.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/android/src/main/res/drawable-da/pay_with_googlepay_button_content.xml b/android/src/main/res/drawable-da/pay_with_googlepay_button_content.xml new file mode 100755 index 000000000..ad631165a --- /dev/null +++ b/android/src/main/res/drawable-da/pay_with_googlepay_button_content.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/android/src/main/res/drawable-de-night/pay_with_googlepay_button_content.xml b/android/src/main/res/drawable-de-night/pay_with_googlepay_button_content.xml new file mode 100755 index 000000000..8ec9aa3c0 --- /dev/null +++ b/android/src/main/res/drawable-de-night/pay_with_googlepay_button_content.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/android/src/main/res/drawable-de/pay_with_googlepay_button_content.xml b/android/src/main/res/drawable-de/pay_with_googlepay_button_content.xml new file mode 100755 index 000000000..e15fdac7c --- /dev/null +++ b/android/src/main/res/drawable-de/pay_with_googlepay_button_content.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/android/src/main/res/drawable-el-night/pay_with_googlepay_button_content.xml b/android/src/main/res/drawable-el-night/pay_with_googlepay_button_content.xml new file mode 100755 index 000000000..132e08909 --- /dev/null +++ b/android/src/main/res/drawable-el-night/pay_with_googlepay_button_content.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/android/src/main/res/drawable-el/pay_with_googlepay_button_content.xml b/android/src/main/res/drawable-el/pay_with_googlepay_button_content.xml new file mode 100755 index 000000000..91689728e --- /dev/null +++ b/android/src/main/res/drawable-el/pay_with_googlepay_button_content.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/android/src/main/res/drawable-es-night/pay_with_googlepay_button_content.xml b/android/src/main/res/drawable-es-night/pay_with_googlepay_button_content.xml new file mode 100755 index 000000000..4bc0b60b0 --- /dev/null +++ b/android/src/main/res/drawable-es-night/pay_with_googlepay_button_content.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/android/src/main/res/drawable-es/pay_with_googlepay_button_content.xml b/android/src/main/res/drawable-es/pay_with_googlepay_button_content.xml new file mode 100755 index 000000000..121dd4092 --- /dev/null +++ b/android/src/main/res/drawable-es/pay_with_googlepay_button_content.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/android/src/main/res/drawable-et-night/pay_with_googlepay_button_content.xml b/android/src/main/res/drawable-et-night/pay_with_googlepay_button_content.xml new file mode 100755 index 000000000..e91d6ef8e --- /dev/null +++ b/android/src/main/res/drawable-et-night/pay_with_googlepay_button_content.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/android/src/main/res/drawable-et/pay_with_googlepay_button_content.xml b/android/src/main/res/drawable-et/pay_with_googlepay_button_content.xml new file mode 100755 index 000000000..63c1c997f --- /dev/null +++ b/android/src/main/res/drawable-et/pay_with_googlepay_button_content.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/android/src/main/res/drawable-fi-night/pay_with_googlepay_button_content.xml b/android/src/main/res/drawable-fi-night/pay_with_googlepay_button_content.xml new file mode 100755 index 000000000..fc67d5090 --- /dev/null +++ b/android/src/main/res/drawable-fi-night/pay_with_googlepay_button_content.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/android/src/main/res/drawable-fi/pay_with_googlepay_button_content.xml b/android/src/main/res/drawable-fi/pay_with_googlepay_button_content.xml new file mode 100755 index 000000000..c0bb35b9b --- /dev/null +++ b/android/src/main/res/drawable-fi/pay_with_googlepay_button_content.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/android/src/main/res/drawable-fr-night/pay_with_googlepay_button_content.xml b/android/src/main/res/drawable-fr-night/pay_with_googlepay_button_content.xml new file mode 100755 index 000000000..49a158fb0 --- /dev/null +++ b/android/src/main/res/drawable-fr-night/pay_with_googlepay_button_content.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/android/src/main/res/drawable-fr/pay_with_googlepay_button_content.xml b/android/src/main/res/drawable-fr/pay_with_googlepay_button_content.xml new file mode 100755 index 000000000..2028253ec --- /dev/null +++ b/android/src/main/res/drawable-fr/pay_with_googlepay_button_content.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/android/src/main/res/drawable-hdpi/googlepay_button_background_image.9.png b/android/src/main/res/drawable-hdpi/googlepay_button_background_image.9.png new file mode 100755 index 000000000..1d6c0e373 Binary files /dev/null and b/android/src/main/res/drawable-hdpi/googlepay_button_background_image.9.png differ diff --git a/android/src/main/res/drawable-hdpi/googlepay_button_background_image_focused.9.png b/android/src/main/res/drawable-hdpi/googlepay_button_background_image_focused.9.png new file mode 100755 index 000000000..342f248e8 Binary files /dev/null and b/android/src/main/res/drawable-hdpi/googlepay_button_background_image_focused.9.png differ diff --git a/android/src/main/res/drawable-hdpi/googlepay_button_background_image_pressed.9.png b/android/src/main/res/drawable-hdpi/googlepay_button_background_image_pressed.9.png new file mode 100755 index 000000000..337c9325c Binary files /dev/null and b/android/src/main/res/drawable-hdpi/googlepay_button_background_image_pressed.9.png differ diff --git a/android/src/main/res/drawable-hdpi/googlepay_button_no_shadow_background_image.9.png b/android/src/main/res/drawable-hdpi/googlepay_button_no_shadow_background_image.9.png new file mode 100755 index 000000000..affa0d38c Binary files /dev/null and b/android/src/main/res/drawable-hdpi/googlepay_button_no_shadow_background_image.9.png differ diff --git a/android/src/main/res/drawable-hdpi/googlepay_button_no_shadow_background_image_focused.9.png b/android/src/main/res/drawable-hdpi/googlepay_button_no_shadow_background_image_focused.9.png new file mode 100755 index 000000000..b82ca103a Binary files /dev/null and b/android/src/main/res/drawable-hdpi/googlepay_button_no_shadow_background_image_focused.9.png differ diff --git a/android/src/main/res/drawable-hdpi/googlepay_button_no_shadow_background_image_pressed.9.png b/android/src/main/res/drawable-hdpi/googlepay_button_no_shadow_background_image_pressed.9.png new file mode 100755 index 000000000..35a44a23c Binary files /dev/null and b/android/src/main/res/drawable-hdpi/googlepay_button_no_shadow_background_image_pressed.9.png differ diff --git a/android/src/main/res/drawable-hr-night/pay_with_googlepay_button_content.xml b/android/src/main/res/drawable-hr-night/pay_with_googlepay_button_content.xml new file mode 100755 index 000000000..6c23066ca --- /dev/null +++ b/android/src/main/res/drawable-hr-night/pay_with_googlepay_button_content.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/android/src/main/res/drawable-hr/pay_with_googlepay_button_content.xml b/android/src/main/res/drawable-hr/pay_with_googlepay_button_content.xml new file mode 100755 index 000000000..47149bc7b --- /dev/null +++ b/android/src/main/res/drawable-hr/pay_with_googlepay_button_content.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/android/src/main/res/drawable-id-night/pay_with_googlepay_button_content.xml b/android/src/main/res/drawable-id-night/pay_with_googlepay_button_content.xml new file mode 100755 index 000000000..ace6d99f0 --- /dev/null +++ b/android/src/main/res/drawable-id-night/pay_with_googlepay_button_content.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/android/src/main/res/drawable-id/pay_with_googlepay_button_content.xml b/android/src/main/res/drawable-id/pay_with_googlepay_button_content.xml new file mode 100755 index 000000000..bc6256342 --- /dev/null +++ b/android/src/main/res/drawable-id/pay_with_googlepay_button_content.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/android/src/main/res/drawable-it-night/pay_with_googlepay_button_content.xml b/android/src/main/res/drawable-it-night/pay_with_googlepay_button_content.xml new file mode 100755 index 000000000..ed9444317 --- /dev/null +++ b/android/src/main/res/drawable-it-night/pay_with_googlepay_button_content.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/android/src/main/res/drawable-it/pay_with_googlepay_button_content.xml b/android/src/main/res/drawable-it/pay_with_googlepay_button_content.xml new file mode 100755 index 000000000..110018a5f --- /dev/null +++ b/android/src/main/res/drawable-it/pay_with_googlepay_button_content.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/android/src/main/res/drawable-ja-night/pay_with_googlepay_button_content.xml b/android/src/main/res/drawable-ja-night/pay_with_googlepay_button_content.xml new file mode 100755 index 000000000..9a8239d4f --- /dev/null +++ b/android/src/main/res/drawable-ja-night/pay_with_googlepay_button_content.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/android/src/main/res/drawable-ja/pay_with_googlepay_button_content.xml b/android/src/main/res/drawable-ja/pay_with_googlepay_button_content.xml new file mode 100755 index 000000000..8e3be7031 --- /dev/null +++ b/android/src/main/res/drawable-ja/pay_with_googlepay_button_content.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/android/src/main/res/drawable-ko-night/pay_with_googlepay_button_content.xml b/android/src/main/res/drawable-ko-night/pay_with_googlepay_button_content.xml new file mode 100755 index 000000000..3793c159e --- /dev/null +++ b/android/src/main/res/drawable-ko-night/pay_with_googlepay_button_content.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/android/src/main/res/drawable-ko/pay_with_googlepay_button_content.xml b/android/src/main/res/drawable-ko/pay_with_googlepay_button_content.xml new file mode 100755 index 000000000..7ffc332cc --- /dev/null +++ b/android/src/main/res/drawable-ko/pay_with_googlepay_button_content.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/android/src/main/res/drawable-mdpi/googlepay_button_background_image.9.png b/android/src/main/res/drawable-mdpi/googlepay_button_background_image.9.png new file mode 100755 index 000000000..98ece61c9 Binary files /dev/null and b/android/src/main/res/drawable-mdpi/googlepay_button_background_image.9.png differ diff --git a/android/src/main/res/drawable-mdpi/googlepay_button_background_image_focused.9.png b/android/src/main/res/drawable-mdpi/googlepay_button_background_image_focused.9.png new file mode 100755 index 000000000..4b0729484 Binary files /dev/null and b/android/src/main/res/drawable-mdpi/googlepay_button_background_image_focused.9.png differ diff --git a/android/src/main/res/drawable-mdpi/googlepay_button_background_image_pressed.9.png b/android/src/main/res/drawable-mdpi/googlepay_button_background_image_pressed.9.png new file mode 100755 index 000000000..4964cdc1b Binary files /dev/null and b/android/src/main/res/drawable-mdpi/googlepay_button_background_image_pressed.9.png differ diff --git a/android/src/main/res/drawable-mdpi/googlepay_button_no_shadow_background_image.9.png b/android/src/main/res/drawable-mdpi/googlepay_button_no_shadow_background_image.9.png new file mode 100755 index 000000000..5d2ca4a44 Binary files /dev/null and b/android/src/main/res/drawable-mdpi/googlepay_button_no_shadow_background_image.9.png differ diff --git a/android/src/main/res/drawable-mdpi/googlepay_button_no_shadow_background_image_focused.9.png b/android/src/main/res/drawable-mdpi/googlepay_button_no_shadow_background_image_focused.9.png new file mode 100755 index 000000000..c98d387b1 Binary files /dev/null and b/android/src/main/res/drawable-mdpi/googlepay_button_no_shadow_background_image_focused.9.png differ diff --git a/android/src/main/res/drawable-mdpi/googlepay_button_no_shadow_background_image_pressed.9.png b/android/src/main/res/drawable-mdpi/googlepay_button_no_shadow_background_image_pressed.9.png new file mode 100755 index 000000000..340d4494a Binary files /dev/null and b/android/src/main/res/drawable-mdpi/googlepay_button_no_shadow_background_image_pressed.9.png differ diff --git a/android/src/main/res/drawable-ms-night/pay_with_googlepay_button_content.xml b/android/src/main/res/drawable-ms-night/pay_with_googlepay_button_content.xml new file mode 100755 index 000000000..ace6d99f0 --- /dev/null +++ b/android/src/main/res/drawable-ms-night/pay_with_googlepay_button_content.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/android/src/main/res/drawable-ms/pay_with_googlepay_button_content.xml b/android/src/main/res/drawable-ms/pay_with_googlepay_button_content.xml new file mode 100755 index 000000000..bc6256342 --- /dev/null +++ b/android/src/main/res/drawable-ms/pay_with_googlepay_button_content.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/android/src/main/res/drawable-night-hdpi/googlepay_button_background_image.9.png b/android/src/main/res/drawable-night-hdpi/googlepay_button_background_image.9.png new file mode 100755 index 000000000..7091d810a Binary files /dev/null and b/android/src/main/res/drawable-night-hdpi/googlepay_button_background_image.9.png differ diff --git a/android/src/main/res/drawable-night-hdpi/googlepay_button_no_shadow_background_image.9.png b/android/src/main/res/drawable-night-hdpi/googlepay_button_no_shadow_background_image.9.png new file mode 100755 index 000000000..4f9bc6ba7 Binary files /dev/null and b/android/src/main/res/drawable-night-hdpi/googlepay_button_no_shadow_background_image.9.png differ diff --git a/android/src/main/res/drawable-night-mdpi/googlepay_button_background_image.9.png b/android/src/main/res/drawable-night-mdpi/googlepay_button_background_image.9.png new file mode 100755 index 000000000..a60464a36 Binary files /dev/null and b/android/src/main/res/drawable-night-mdpi/googlepay_button_background_image.9.png differ diff --git a/android/src/main/res/drawable-night-mdpi/googlepay_button_no_shadow_background_image.9.png b/android/src/main/res/drawable-night-mdpi/googlepay_button_no_shadow_background_image.9.png new file mode 100755 index 000000000..d0be7ed2d Binary files /dev/null and b/android/src/main/res/drawable-night-mdpi/googlepay_button_no_shadow_background_image.9.png differ diff --git a/android/src/main/res/drawable-night-v21/googlepay_button_background.xml b/android/src/main/res/drawable-night-v21/googlepay_button_background.xml new file mode 100755 index 000000000..4873ef242 --- /dev/null +++ b/android/src/main/res/drawable-night-v21/googlepay_button_background.xml @@ -0,0 +1,7 @@ + + + + + diff --git a/android/src/main/res/drawable-night-v21/googlepay_button_no_shadow_background.xml b/android/src/main/res/drawable-night-v21/googlepay_button_no_shadow_background.xml new file mode 100755 index 000000000..d44e9eb62 --- /dev/null +++ b/android/src/main/res/drawable-night-v21/googlepay_button_no_shadow_background.xml @@ -0,0 +1,7 @@ + + + + + diff --git a/android/src/main/res/drawable-night-xhdpi/googlepay_button_background_image.9.png b/android/src/main/res/drawable-night-xhdpi/googlepay_button_background_image.9.png new file mode 100755 index 000000000..40f767d53 Binary files /dev/null and b/android/src/main/res/drawable-night-xhdpi/googlepay_button_background_image.9.png differ diff --git a/android/src/main/res/drawable-night-xhdpi/googlepay_button_no_shadow_background_image.9.png b/android/src/main/res/drawable-night-xhdpi/googlepay_button_no_shadow_background_image.9.png new file mode 100755 index 000000000..969cc52a9 Binary files /dev/null and b/android/src/main/res/drawable-night-xhdpi/googlepay_button_no_shadow_background_image.9.png differ diff --git a/android/src/main/res/drawable-night-xxhdpi/googlepay_button_background_image.9.png b/android/src/main/res/drawable-night-xxhdpi/googlepay_button_background_image.9.png new file mode 100755 index 000000000..91035e2a4 Binary files /dev/null and b/android/src/main/res/drawable-night-xxhdpi/googlepay_button_background_image.9.png differ diff --git a/android/src/main/res/drawable-night-xxhdpi/googlepay_button_no_shadow_background_image.9.png b/android/src/main/res/drawable-night-xxhdpi/googlepay_button_no_shadow_background_image.9.png new file mode 100755 index 000000000..dda66dfd0 Binary files /dev/null and b/android/src/main/res/drawable-night-xxhdpi/googlepay_button_no_shadow_background_image.9.png differ diff --git a/android/src/main/res/drawable-night-xxxhdpi/googlepay_button_background_image.9.png b/android/src/main/res/drawable-night-xxxhdpi/googlepay_button_background_image.9.png new file mode 100755 index 000000000..ab905289b Binary files /dev/null and b/android/src/main/res/drawable-night-xxxhdpi/googlepay_button_background_image.9.png differ diff --git a/android/src/main/res/drawable-night-xxxhdpi/googlepay_button_no_shadow_background_image.9.png b/android/src/main/res/drawable-night-xxxhdpi/googlepay_button_no_shadow_background_image.9.png new file mode 100755 index 000000000..e67fdaf51 Binary files /dev/null and b/android/src/main/res/drawable-night-xxxhdpi/googlepay_button_no_shadow_background_image.9.png differ diff --git a/android/src/main/res/drawable-night/googlepay_button_background.xml b/android/src/main/res/drawable-night/googlepay_button_background.xml new file mode 100755 index 000000000..b81005b06 --- /dev/null +++ b/android/src/main/res/drawable-night/googlepay_button_background.xml @@ -0,0 +1,6 @@ + + + + + diff --git a/android/src/main/res/drawable-night/googlepay_button_content.xml b/android/src/main/res/drawable-night/googlepay_button_content.xml new file mode 100755 index 000000000..b2cdb1d52 --- /dev/null +++ b/android/src/main/res/drawable-night/googlepay_button_content.xml @@ -0,0 +1,48 @@ + + + + + + + + + diff --git a/android/src/main/res/drawable-night/googlepay_button_no_shadow_background.xml b/android/src/main/res/drawable-night/googlepay_button_no_shadow_background.xml new file mode 100755 index 000000000..9543c4bcb --- /dev/null +++ b/android/src/main/res/drawable-night/googlepay_button_no_shadow_background.xml @@ -0,0 +1,6 @@ + + + + + diff --git a/android/src/main/res/drawable-night/googlepay_button_overlay.xml b/android/src/main/res/drawable-night/googlepay_button_overlay.xml new file mode 100755 index 000000000..70c7a9227 --- /dev/null +++ b/android/src/main/res/drawable-night/googlepay_button_overlay.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + diff --git a/android/src/main/res/drawable-night/pay_with_googlepay_button_content.xml b/android/src/main/res/drawable-night/pay_with_googlepay_button_content.xml new file mode 100755 index 000000000..436489473 --- /dev/null +++ b/android/src/main/res/drawable-night/pay_with_googlepay_button_content.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/android/src/main/res/drawable-nl-night/pay_with_googlepay_button_content.xml b/android/src/main/res/drawable-nl-night/pay_with_googlepay_button_content.xml new file mode 100755 index 000000000..4cdc0f2c6 --- /dev/null +++ b/android/src/main/res/drawable-nl-night/pay_with_googlepay_button_content.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/android/src/main/res/drawable-nl/pay_with_googlepay_button_content.xml b/android/src/main/res/drawable-nl/pay_with_googlepay_button_content.xml new file mode 100755 index 000000000..b310e330b --- /dev/null +++ b/android/src/main/res/drawable-nl/pay_with_googlepay_button_content.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/android/src/main/res/drawable-no-night/pay_with_googlepay_button_content.xml b/android/src/main/res/drawable-no-night/pay_with_googlepay_button_content.xml new file mode 100755 index 000000000..4162dd38a --- /dev/null +++ b/android/src/main/res/drawable-no-night/pay_with_googlepay_button_content.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/android/src/main/res/drawable-no/pay_with_googlepay_button_content.xml b/android/src/main/res/drawable-no/pay_with_googlepay_button_content.xml new file mode 100755 index 000000000..ad631165a --- /dev/null +++ b/android/src/main/res/drawable-no/pay_with_googlepay_button_content.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/android/src/main/res/drawable-pl-night/pay_with_googlepay_button_content.xml b/android/src/main/res/drawable-pl-night/pay_with_googlepay_button_content.xml new file mode 100755 index 000000000..f013a6ff7 --- /dev/null +++ b/android/src/main/res/drawable-pl-night/pay_with_googlepay_button_content.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/android/src/main/res/drawable-pl/pay_with_googlepay_button_content.xml b/android/src/main/res/drawable-pl/pay_with_googlepay_button_content.xml new file mode 100755 index 000000000..c6e7ea558 --- /dev/null +++ b/android/src/main/res/drawable-pl/pay_with_googlepay_button_content.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/android/src/main/res/drawable-pt-night/pay_with_googlepay_button_content.xml b/android/src/main/res/drawable-pt-night/pay_with_googlepay_button_content.xml new file mode 100755 index 000000000..befc1599a --- /dev/null +++ b/android/src/main/res/drawable-pt-night/pay_with_googlepay_button_content.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/android/src/main/res/drawable-pt/pay_with_googlepay_button_content.xml b/android/src/main/res/drawable-pt/pay_with_googlepay_button_content.xml new file mode 100755 index 000000000..37090c642 --- /dev/null +++ b/android/src/main/res/drawable-pt/pay_with_googlepay_button_content.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/android/src/main/res/drawable-ru-night/pay_with_googlepay_button_content.xml b/android/src/main/res/drawable-ru-night/pay_with_googlepay_button_content.xml new file mode 100755 index 000000000..2ea5f1ffb --- /dev/null +++ b/android/src/main/res/drawable-ru-night/pay_with_googlepay_button_content.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/android/src/main/res/drawable-ru/pay_with_googlepay_button_content.xml b/android/src/main/res/drawable-ru/pay_with_googlepay_button_content.xml new file mode 100755 index 000000000..118067b1e --- /dev/null +++ b/android/src/main/res/drawable-ru/pay_with_googlepay_button_content.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/android/src/main/res/drawable-sk-night/pay_with_googlepay_button_content.xml b/android/src/main/res/drawable-sk-night/pay_with_googlepay_button_content.xml new file mode 100755 index 000000000..f0404b360 --- /dev/null +++ b/android/src/main/res/drawable-sk-night/pay_with_googlepay_button_content.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/android/src/main/res/drawable-sk/pay_with_googlepay_button_content.xml b/android/src/main/res/drawable-sk/pay_with_googlepay_button_content.xml new file mode 100755 index 000000000..506832e15 --- /dev/null +++ b/android/src/main/res/drawable-sk/pay_with_googlepay_button_content.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/android/src/main/res/drawable-sl-night/pay_with_googlepay_button_content.xml b/android/src/main/res/drawable-sl-night/pay_with_googlepay_button_content.xml new file mode 100755 index 000000000..0b55d1218 --- /dev/null +++ b/android/src/main/res/drawable-sl-night/pay_with_googlepay_button_content.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/android/src/main/res/drawable-sl/pay_with_googlepay_button_content.xml b/android/src/main/res/drawable-sl/pay_with_googlepay_button_content.xml new file mode 100755 index 000000000..077317361 --- /dev/null +++ b/android/src/main/res/drawable-sl/pay_with_googlepay_button_content.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/android/src/main/res/drawable-sr-night/pay_with_googlepay_button_content.xml b/android/src/main/res/drawable-sr-night/pay_with_googlepay_button_content.xml new file mode 100755 index 000000000..3adb9adc0 --- /dev/null +++ b/android/src/main/res/drawable-sr-night/pay_with_googlepay_button_content.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/android/src/main/res/drawable-sr/pay_with_googlepay_button_content.xml b/android/src/main/res/drawable-sr/pay_with_googlepay_button_content.xml new file mode 100755 index 000000000..13d2fb381 --- /dev/null +++ b/android/src/main/res/drawable-sr/pay_with_googlepay_button_content.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/android/src/main/res/drawable-sv-night/pay_with_googlepay_button_content.xml b/android/src/main/res/drawable-sv-night/pay_with_googlepay_button_content.xml new file mode 100755 index 000000000..b90882836 --- /dev/null +++ b/android/src/main/res/drawable-sv-night/pay_with_googlepay_button_content.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/android/src/main/res/drawable-sv/pay_with_googlepay_button_content.xml b/android/src/main/res/drawable-sv/pay_with_googlepay_button_content.xml new file mode 100755 index 000000000..5a5c82862 --- /dev/null +++ b/android/src/main/res/drawable-sv/pay_with_googlepay_button_content.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/android/src/main/res/drawable-th-night/pay_with_googlepay_button_content.xml b/android/src/main/res/drawable-th-night/pay_with_googlepay_button_content.xml new file mode 100755 index 000000000..83c41e77f --- /dev/null +++ b/android/src/main/res/drawable-th-night/pay_with_googlepay_button_content.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/android/src/main/res/drawable-th/pay_with_googlepay_button_content.xml b/android/src/main/res/drawable-th/pay_with_googlepay_button_content.xml new file mode 100755 index 000000000..8339725db --- /dev/null +++ b/android/src/main/res/drawable-th/pay_with_googlepay_button_content.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/android/src/main/res/drawable-tr-night/pay_with_googlepay_button_content.xml b/android/src/main/res/drawable-tr-night/pay_with_googlepay_button_content.xml new file mode 100755 index 000000000..8022db766 --- /dev/null +++ b/android/src/main/res/drawable-tr-night/pay_with_googlepay_button_content.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/android/src/main/res/drawable-tr/pay_with_googlepay_button_content.xml b/android/src/main/res/drawable-tr/pay_with_googlepay_button_content.xml new file mode 100755 index 000000000..a33a285af --- /dev/null +++ b/android/src/main/res/drawable-tr/pay_with_googlepay_button_content.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/android/src/main/res/drawable-uk-night/pay_with_googlepay_button_content.xml b/android/src/main/res/drawable-uk-night/pay_with_googlepay_button_content.xml new file mode 100755 index 000000000..36d287377 --- /dev/null +++ b/android/src/main/res/drawable-uk-night/pay_with_googlepay_button_content.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/android/src/main/res/drawable-uk/pay_with_googlepay_button_content.xml b/android/src/main/res/drawable-uk/pay_with_googlepay_button_content.xml new file mode 100755 index 000000000..1f8e8f652 --- /dev/null +++ b/android/src/main/res/drawable-uk/pay_with_googlepay_button_content.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/android/src/main/res/drawable-v21/googlepay_button_background.xml b/android/src/main/res/drawable-v21/googlepay_button_background.xml new file mode 100755 index 000000000..b0a94f391 --- /dev/null +++ b/android/src/main/res/drawable-v21/googlepay_button_background.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + diff --git a/android/src/main/res/drawable-v21/googlepay_button_no_shadow_background.xml b/android/src/main/res/drawable-v21/googlepay_button_no_shadow_background.xml new file mode 100755 index 000000000..c39fc11f0 --- /dev/null +++ b/android/src/main/res/drawable-v21/googlepay_button_no_shadow_background.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + diff --git a/android/src/main/res/drawable-xhdpi/googlepay_button_background_image.9.png b/android/src/main/res/drawable-xhdpi/googlepay_button_background_image.9.png new file mode 100755 index 000000000..2424f9686 Binary files /dev/null and b/android/src/main/res/drawable-xhdpi/googlepay_button_background_image.9.png differ diff --git a/android/src/main/res/drawable-xhdpi/googlepay_button_background_image_focused.9.png b/android/src/main/res/drawable-xhdpi/googlepay_button_background_image_focused.9.png new file mode 100755 index 000000000..9f1fb5748 Binary files /dev/null and b/android/src/main/res/drawable-xhdpi/googlepay_button_background_image_focused.9.png differ diff --git a/android/src/main/res/drawable-xhdpi/googlepay_button_background_image_pressed.9.png b/android/src/main/res/drawable-xhdpi/googlepay_button_background_image_pressed.9.png new file mode 100755 index 000000000..59161bae9 Binary files /dev/null and b/android/src/main/res/drawable-xhdpi/googlepay_button_background_image_pressed.9.png differ diff --git a/android/src/main/res/drawable-xhdpi/googlepay_button_no_shadow_background_image.9.png b/android/src/main/res/drawable-xhdpi/googlepay_button_no_shadow_background_image.9.png new file mode 100755 index 000000000..95482f4f5 Binary files /dev/null and b/android/src/main/res/drawable-xhdpi/googlepay_button_no_shadow_background_image.9.png differ diff --git a/android/src/main/res/drawable-xhdpi/googlepay_button_no_shadow_background_image_focused.9.png b/android/src/main/res/drawable-xhdpi/googlepay_button_no_shadow_background_image_focused.9.png new file mode 100755 index 000000000..210493a58 Binary files /dev/null and b/android/src/main/res/drawable-xhdpi/googlepay_button_no_shadow_background_image_focused.9.png differ diff --git a/android/src/main/res/drawable-xhdpi/googlepay_button_no_shadow_background_image_pressed.9.png b/android/src/main/res/drawable-xhdpi/googlepay_button_no_shadow_background_image_pressed.9.png new file mode 100755 index 000000000..e246559b7 Binary files /dev/null and b/android/src/main/res/drawable-xhdpi/googlepay_button_no_shadow_background_image_pressed.9.png differ diff --git a/android/src/main/res/drawable-xxhdpi/googlepay_button_background_image.9.png b/android/src/main/res/drawable-xxhdpi/googlepay_button_background_image.9.png new file mode 100755 index 000000000..a6a1b1876 Binary files /dev/null and b/android/src/main/res/drawable-xxhdpi/googlepay_button_background_image.9.png differ diff --git a/android/src/main/res/drawable-xxhdpi/googlepay_button_background_image_focused.9.png b/android/src/main/res/drawable-xxhdpi/googlepay_button_background_image_focused.9.png new file mode 100755 index 000000000..e766ccb29 Binary files /dev/null and b/android/src/main/res/drawable-xxhdpi/googlepay_button_background_image_focused.9.png differ diff --git a/android/src/main/res/drawable-xxhdpi/googlepay_button_background_image_pressed.9.png b/android/src/main/res/drawable-xxhdpi/googlepay_button_background_image_pressed.9.png new file mode 100755 index 000000000..e544a4f38 Binary files /dev/null and b/android/src/main/res/drawable-xxhdpi/googlepay_button_background_image_pressed.9.png differ diff --git a/android/src/main/res/drawable-xxhdpi/googlepay_button_no_shadow_background_image.9.png b/android/src/main/res/drawable-xxhdpi/googlepay_button_no_shadow_background_image.9.png new file mode 100755 index 000000000..69b834009 Binary files /dev/null and b/android/src/main/res/drawable-xxhdpi/googlepay_button_no_shadow_background_image.9.png differ diff --git a/android/src/main/res/drawable-xxhdpi/googlepay_button_no_shadow_background_image_focused.9.png b/android/src/main/res/drawable-xxhdpi/googlepay_button_no_shadow_background_image_focused.9.png new file mode 100755 index 000000000..9b71cf6cf Binary files /dev/null and b/android/src/main/res/drawable-xxhdpi/googlepay_button_no_shadow_background_image_focused.9.png differ diff --git a/android/src/main/res/drawable-xxhdpi/googlepay_button_no_shadow_background_image_pressed.9.png b/android/src/main/res/drawable-xxhdpi/googlepay_button_no_shadow_background_image_pressed.9.png new file mode 100755 index 000000000..454df9b85 Binary files /dev/null and b/android/src/main/res/drawable-xxhdpi/googlepay_button_no_shadow_background_image_pressed.9.png differ diff --git a/android/src/main/res/drawable-xxxhdpi/googlepay_button_background_image.9.png b/android/src/main/res/drawable-xxxhdpi/googlepay_button_background_image.9.png new file mode 100755 index 000000000..7c781080c Binary files /dev/null and b/android/src/main/res/drawable-xxxhdpi/googlepay_button_background_image.9.png differ diff --git a/android/src/main/res/drawable-xxxhdpi/googlepay_button_background_image_focused.9.png b/android/src/main/res/drawable-xxxhdpi/googlepay_button_background_image_focused.9.png new file mode 100755 index 000000000..b9223ea3a Binary files /dev/null and b/android/src/main/res/drawable-xxxhdpi/googlepay_button_background_image_focused.9.png differ diff --git a/android/src/main/res/drawable-xxxhdpi/googlepay_button_background_image_pressed.9.png b/android/src/main/res/drawable-xxxhdpi/googlepay_button_background_image_pressed.9.png new file mode 100755 index 000000000..894fdcfbc Binary files /dev/null and b/android/src/main/res/drawable-xxxhdpi/googlepay_button_background_image_pressed.9.png differ diff --git a/android/src/main/res/drawable-xxxhdpi/googlepay_button_no_shadow_background_image.9.png b/android/src/main/res/drawable-xxxhdpi/googlepay_button_no_shadow_background_image.9.png new file mode 100755 index 000000000..41dfb8372 Binary files /dev/null and b/android/src/main/res/drawable-xxxhdpi/googlepay_button_no_shadow_background_image.9.png differ diff --git a/android/src/main/res/drawable-xxxhdpi/googlepay_button_no_shadow_background_image_focused.9.png b/android/src/main/res/drawable-xxxhdpi/googlepay_button_no_shadow_background_image_focused.9.png new file mode 100755 index 000000000..7889152ae Binary files /dev/null and b/android/src/main/res/drawable-xxxhdpi/googlepay_button_no_shadow_background_image_focused.9.png differ diff --git a/android/src/main/res/drawable-xxxhdpi/googlepay_button_no_shadow_background_image_pressed.9.png b/android/src/main/res/drawable-xxxhdpi/googlepay_button_no_shadow_background_image_pressed.9.png new file mode 100755 index 000000000..c461f63ef Binary files /dev/null and b/android/src/main/res/drawable-xxxhdpi/googlepay_button_no_shadow_background_image_pressed.9.png differ diff --git a/android/src/main/res/drawable-zh/pay_with_googlepay_button_content.xml b/android/src/main/res/drawable-zh/pay_with_googlepay_button_content.xml new file mode 100755 index 000000000..d7807a854 --- /dev/null +++ b/android/src/main/res/drawable-zh/pay_with_googlepay_button_content.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/android/src/main/res/drawable/googlepay_button_background.xml b/android/src/main/res/drawable/googlepay_button_background.xml new file mode 100755 index 000000000..8f138dc54 --- /dev/null +++ b/android/src/main/res/drawable/googlepay_button_background.xml @@ -0,0 +1,18 @@ + + + + + + + + diff --git a/android/src/main/res/drawable/googlepay_button_content.xml b/android/src/main/res/drawable/googlepay_button_content.xml new file mode 100755 index 000000000..57596ba5f --- /dev/null +++ b/android/src/main/res/drawable/googlepay_button_content.xml @@ -0,0 +1,48 @@ + + + + + + + + + diff --git a/android/src/main/res/drawable/googlepay_button_no_shadow_background.xml b/android/src/main/res/drawable/googlepay_button_no_shadow_background.xml new file mode 100755 index 000000000..d6eab82b3 --- /dev/null +++ b/android/src/main/res/drawable/googlepay_button_no_shadow_background.xml @@ -0,0 +1,18 @@ + + + + + + + + diff --git a/android/src/main/res/drawable/googlepay_button_overlay.xml b/android/src/main/res/drawable/googlepay_button_overlay.xml new file mode 100755 index 000000000..6e46c4480 --- /dev/null +++ b/android/src/main/res/drawable/googlepay_button_overlay.xml @@ -0,0 +1,11 @@ + + + + + + + + + + diff --git a/android/src/main/res/drawable/pay_with_googlepay_button_content.xml b/android/src/main/res/drawable/pay_with_googlepay_button_content.xml new file mode 100755 index 000000000..d1789ed98 --- /dev/null +++ b/android/src/main/res/drawable/pay_with_googlepay_button_content.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/android/src/main/res/layout-night/googlepay_button.xml b/android/src/main/res/layout-night/googlepay_button.xml new file mode 100755 index 000000000..41f09f7b5 --- /dev/null +++ b/android/src/main/res/layout-night/googlepay_button.xml @@ -0,0 +1,31 @@ + + + + + + + diff --git a/android/src/main/res/layout-night/pay_with_googlepay_button.xml b/android/src/main/res/layout-night/pay_with_googlepay_button.xml new file mode 100755 index 000000000..9ac6e8aeb --- /dev/null +++ b/android/src/main/res/layout-night/pay_with_googlepay_button.xml @@ -0,0 +1,31 @@ + + + + + + + \ No newline at end of file diff --git a/android/src/main/res/layout/googlepay_button.xml b/android/src/main/res/layout/googlepay_button.xml new file mode 100755 index 000000000..94cab75a3 --- /dev/null +++ b/android/src/main/res/layout/googlepay_button.xml @@ -0,0 +1,31 @@ + + + + + + + diff --git a/android/src/main/res/layout/googlepay_button_no_shadow.xml b/android/src/main/res/layout/googlepay_button_no_shadow.xml new file mode 100755 index 000000000..41f09f7b5 --- /dev/null +++ b/android/src/main/res/layout/googlepay_button_no_shadow.xml @@ -0,0 +1,31 @@ + + + + + + + diff --git a/android/src/main/res/layout/pay_with_googlepay_button.xml b/android/src/main/res/layout/pay_with_googlepay_button.xml new file mode 100755 index 000000000..9ac6e8aeb --- /dev/null +++ b/android/src/main/res/layout/pay_with_googlepay_button.xml @@ -0,0 +1,31 @@ + + + + + + + \ No newline at end of file diff --git a/android/src/main/res/layout/pay_with_googlepay_button_no_shadow.xml b/android/src/main/res/layout/pay_with_googlepay_button_no_shadow.xml new file mode 100755 index 000000000..e1f0a7359 --- /dev/null +++ b/android/src/main/res/layout/pay_with_googlepay_button_no_shadow.xml @@ -0,0 +1,31 @@ + + + + + + + \ No newline at end of file diff --git a/android/src/main/res/values-night/googlepay_strings.xml b/android/src/main/res/values-night/googlepay_strings.xml new file mode 100755 index 000000000..81d01c2b7 --- /dev/null +++ b/android/src/main/res/values-night/googlepay_strings.xml @@ -0,0 +1,12 @@ + + + Google Pay + Buy with Google Pay + Donate With Google Pay + Pay With Google Pay + Subscribe With Google Pay + Book With Google Pay + Checkout With Google Pay + Order With Google Pay + View In Google Pay + \ No newline at end of file diff --git a/android/src/main/res/values/googlepay_strings.xml b/android/src/main/res/values/googlepay_strings.xml new file mode 100755 index 000000000..81d01c2b7 --- /dev/null +++ b/android/src/main/res/values/googlepay_strings.xml @@ -0,0 +1,12 @@ + + + Google Pay + Buy with Google Pay + Donate With Google Pay + Pay With Google Pay + Subscribe With Google Pay + Book With Google Pay + Checkout With Google Pay + Order With Google Pay + View In Google Pay + \ No newline at end of file diff --git a/docs/GooglePay.md b/docs/GooglePay.md new file mode 100644 index 000000000..b58cb3ec0 --- /dev/null +++ b/docs/GooglePay.md @@ -0,0 +1,176 @@ +# Google Pay + +## Learn how to accept payments using Google Pay. + +Google Pay allows customers to make payments in your app or website using any credit or debit card saved to their Google Account, including those from Google Play, YouTube, Chrome, or an Android device. Use the Google Pay API to request any credit or debit card stored in your customer’s Google account. + +Google Pay is fully compatible with Stripe’s products and features (e.g., [subscriptions](https://stripe.com/docs/billing)), allowing you to use it in place of a traditional payment form whenever possible. Use it to accept payments for physical goods, donations, subscriptions, and more. + +## Setup Stripe + +### Server side + +// + +### Client side + +The [React Native SDK](https://github.com/stripe/stripe-react-native) is open source and fully documented. Internally, it makes use of native iOS and Android SDKs. +Install the SDK by running: + +```sh +yarn add react-native-stripe-sdk +``` + +For iOS you will have to run `pod install` inside `ios` directory in order to install needed native dependencies. Android won't require any additional steps. + +When your app starts, configure the SDK with your Stripe [publishable key](https://stripe.com/dashboard.stripe.com/account/apikeys) so it can make requests to the Stripe API: + +```tsx +import { StripeProvider } from '@stripe/stripe-react-native'; + +function App() { + return ( + + // Your app code here + + ); +} +``` + +## Initialize Google Pay + +Next, initialize a Google Pay by calling `initGooglePay` method. Call this on initial render of your checkout screen for best performance. + +`initGooglePay` accepts several configuration options that can be customized for your needs. +See [SDK Reference](https://stripe.dev/stripe-react-native/api-reference/index.html) for more details. + +```tsx +import { useGooglePay } from 'stripe-react-native'; + +function CheckoutScreen() { + const { initGooglePay } = useGooglePay(); + const [initialized, setInitialized] = useState(false) + + useEffect(() => { + async function initialize() { + const { error } = await initGooglePay({ + testEnv: true, + merchantName: 'Widget Store' + countryCode: 'US', + billingAddressConfig: { + format: 'FULL', + isPhoneNumberRequired: true, + isRequired: false, + }, + existingPaymentMethodRequired: false, + isEmailRequired: true, + }); + + if (error) { + Alert.alert(error.code, error.message); + return; + } + setInitialized(true); + } + initialize(); + }, [initGooglePay]); +} +``` + +After initializing GooglePay, the `initGooglePay` promise is resolved, it's successful if there is no error. This information can be used to update your UI to indicate to your customer that Google Pay is ready to be used. + +```tsx +import { useGooglePay } from 'stripe-react-native'; + +function CheckoutScreen() { + const [initialized, setInitialized] = useState(false); + + // continued from above + + return ( + +