Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/stripe_android/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version '1.0-SNAPSHOT'

buildscript {
ext.kotlin_version = '1.8.0'
ext.stripe_version = '21.19.+'
ext.stripe_version = '21.26.+'

repositories {
google()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,13 @@ public WritableNativeMap(Map<String, Object> map) {
public WritableNativeMap() {
super(new HashMap<>());
}

public void merge(ReadableMap source) {
if (source == null) {
return;
}
for (String key : source.keySet()) {
put(key, source.get(key));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public RCTDeviceEventEmitter(MethodChannel channel) {
this.channel = channel;
}

public void emit(String eventName, ReadableMap params) {
public void emit(String eventName, Object params) {
uiThreadHandler.post(() -> channel.invokeMethod(eventName, params));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class CollectBankAccountLauncherFragment : StripeFragment() {
if (stripeSdkModule != null) {
FinancialConnections.setEventListener { event ->
val params = mapFromFinancialConnectionsEvent(event)
stripeSdkModule.emitOnFinancialConnectionsEvent(params)
stripeSdkModule.eventEmitter.emitOnFinancialConnectionsEvent(params)
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
// This is a temporary compat layer for event emitters on new arch.
// Versions before RN 0.80 crash sometimes when setting the event emitter callback.
// Remove this layer once we drop support for RN < 0.80.
package com.reactnativestripesdk

import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.bridge.ReadableMap
import com.facebook.react.modules.core.DeviceEventManagerModule

class EventEmitterCompat(
private val reactApplicationContext: ReactApplicationContext,
) {
private fun invoke(
eventName: String,
params: ReadableMap? = null,
) {
reactApplicationContext
.getJSModule(
DeviceEventManagerModule.RCTDeviceEventEmitter::class.java,
).emit(eventName, params)
}

fun emitOnConfirmHandlerCallback(value: ReadableMap?) {
invoke("onConfirmHandlerCallback", value)
}

fun emitOnFinancialConnectionsEvent(value: ReadableMap?) {
invoke("onFinancialConnectionsEvent", value)
}

fun emitOnOrderTrackingCallback() {
invoke("onOrderTrackingCallback")
}

fun emitOnCustomerAdapterFetchPaymentMethodsCallback() {
invoke("onCustomerAdapterFetchPaymentMethodsCallback")
}

fun emitOnCustomerAdapterAttachPaymentMethodCallback(value: ReadableMap?) {
invoke("onCustomerAdapterAttachPaymentMethodCallback", value)
}

fun emitOnCustomerAdapterDetachPaymentMethodCallback(value: ReadableMap?) {
invoke("onCustomerAdapterDetachPaymentMethodCallback", value)
}

fun emitOnCustomerAdapterSetSelectedPaymentOptionCallback(value: ReadableMap?) {
invoke("onCustomerAdapterSetSelectedPaymentOptionCallback", value)
}

fun emitOnCustomerAdapterFetchSelectedPaymentOptionCallback() {
invoke("onCustomerAdapterFetchSelectedPaymentOptionCallback")
}

fun emitOnCustomerAdapterSetupIntentClientSecretForCustomerAttachCallback() {
invoke("onCustomerAdapterSetupIntentClientSecretForCustomerAttachCallback")
}

fun emitEmbeddedPaymentElementDidUpdateHeight(value: ReadableMap?) {
invoke("embeddedPaymentElementDidUpdateHeight", value)
}

fun emitEmbeddedPaymentElementWillPresent() {
invoke("embeddedPaymentElementWillPresent")
}

fun emitEmbeddedPaymentElementDidUpdatePaymentOption(value: ReadableMap?) {
invoke("embeddedPaymentElementDidUpdatePaymentOption", value)
}

fun emitEmbeddedPaymentElementFormSheetConfirmComplete(value: ReadableMap?) {
invoke("embeddedPaymentElementFormSheetConfirmComplete", value)
}

fun emitEmbeddedPaymentElementRowSelectionImmediateAction() {
invoke("embeddedPaymentElementRowSelectionImmediateAction")
}

fun emitEmbeddedPaymentElementLoadingFailed(value: ReadableMap?) {
invoke("embeddedPaymentElementLoadingFailed", value)
}

fun emitOnCustomPaymentMethodConfirmHandlerCallback(value: ReadableMap?) {
invoke("onCustomPaymentMethodConfirmHandlerCallback", value)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class FinancialConnectionsSheetFragment : StripeFragment() {
val stripeSdkModule: StripeSdkModule? = context.getNativeModule(StripeSdkModule::class.java)
FinancialConnections.setEventListener { event ->
val params = mapFromFinancialConnectionsEvent(event)
stripeSdkModule?.emitOnFinancialConnectionsEvent(params)
stripeSdkModule?.eventEmitter?.emitOnFinancialConnectionsEvent(params)
}

when (mode) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public NativeStripeSdkModuleSpec(ReactApplicationContext reactContext) {
return NAME;
}

private void invoke(String eventName, ReadableMap params) {
private void invoke(String eventName, Object params) {
getReactApplicationContext()
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
.emit(eventName, params);
Expand Down Expand Up @@ -316,4 +316,16 @@ protected final void emitOnCustomPaymentMethodConfirmHandlerCallback(ReadableMap
@ReactMethod
@DoNotStrip
public abstract void clearEmbeddedPaymentOption(double viewTag, Promise promise);

@ReactMethod
@DoNotStrip
public abstract void setFinancialConnectionsForceNativeFlow(boolean enabled, Promise promise);

@ReactMethod
@DoNotStrip
public abstract void addListener(String eventType);

@ReactMethod
@DoNotStrip
public abstract void removeListeners(double count);
}
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ class PaymentLauncherFragment : StripeFragment() {
StripeIntent.NextActionType.DisplayKonbiniDetails,
StripeIntent.NextActionType.VerifyWithMicrodeposits,
StripeIntent.NextActionType.DisplayMultibancoDetails,
StripeIntent.NextActionType.DisplayPayNowDetails,
-> true
StripeIntent.NextActionType.RedirectToUrl,
StripeIntent.NextActionType.UseStripeSdk,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class PaymentMethodCreateParamsFactory(
PaymentMethod.Type.Ideal -> createIDEALParams()
PaymentMethod.Type.Alipay -> createAlipayParams()
PaymentMethod.Type.Bancontact -> createBancontactParams()
PaymentMethod.Type.Billie -> createBillieParams()
PaymentMethod.Type.SepaDebit -> createSepaParams()
PaymentMethod.Type.Oxxo -> createOXXOParams()
PaymentMethod.Type.Giropay -> createGiropayParams()
Expand Down Expand Up @@ -90,6 +91,13 @@ class PaymentMethodCreateParamsFactory(
throw PaymentMethodCreateParamsException("You must provide billing details")
}

@Throws(PaymentMethodCreateParamsException::class)
private fun createBillieParams(): PaymentMethodCreateParams =
PaymentMethodCreateParams.createBillie(
billingDetails = billingDetailsParams,
metadata = metadataParams,
)

@Throws(PaymentMethodCreateParamsException::class)
private fun createSepaParams(): PaymentMethodCreateParams {
billingDetailsParams?.let {
Expand Down Expand Up @@ -200,21 +208,11 @@ class PaymentMethodCreateParamsFactory(
}

@Throws(PaymentMethodCreateParamsException::class)
private fun createKlarnaParams(): PaymentMethodCreateParams {
if (billingDetailsParams == null ||
billingDetailsParams.address?.country.isNullOrBlank() ||
billingDetailsParams.email.isNullOrBlank()
) {
throw PaymentMethodCreateParamsException(
"Klarna requires that you provide the following billing details: email, country",
)
}

return PaymentMethodCreateParams.createKlarna(
private fun createKlarnaParams(): PaymentMethodCreateParams =
PaymentMethodCreateParams.createKlarna(
billingDetails = billingDetailsParams,
metadata = metadataParams,
)
}

@Throws(PaymentMethodCreateParamsException::class)
private fun createPayPalParams(): PaymentMethodCreateParams = PaymentMethodCreateParams.createPayPal(metadata = metadataParams)
Expand Down Expand Up @@ -256,6 +254,7 @@ class PaymentMethodCreateParamsFactory(
PaymentMethod.Type.Ideal,
PaymentMethod.Type.Alipay,
PaymentMethod.Type.Bancontact,
PaymentMethod.Type.Billie,
PaymentMethod.Type.SepaDebit,
PaymentMethod.Type.Oxxo,
PaymentMethod.Type.Giropay,
Expand Down
Loading
Loading