react-native-paypal
react-native-paypal copied to clipboard
Not closing the webview after payment is successful
can you show me your code please @eskiesirius
make sure you have this code in your AppDelegate.m
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
{
return [[RNPaypal sharedInstance] application:application openURL:url options:options];
}
Face same issue while implementing this. After doing some search on linked braintree sdk. I found the issue is with Chrome as per the issue mention here. Putting this comment so due to this issue people won't avoid using this.
@eskiesirius check to make sure you have the code I've written above. If you're still having issues check out the example app in the newest version of the app. If you are still seeing issues lmk and I will reopen
Had another report of this bug with some more details here so I'm going to reopen https://github.com/smarkets/react-native-paypal/issues/49#issuecomment-714467616
Hey all, just an idea... and new to this whole NativeModule stuff: but could a solution be to use NativeEvents (see example: https://reactnative.dev/docs/native-modules-android#sending-events-to-javascript) rather than promises?
That way we get the nonce back (which has no problem being created as far as I can see) - we then wouldn't care about the tabs that open / don't close in the background. The known issue would then become a bunch of tabs potentially but relatively harmless?
Seems less terrible than no nonce at all.
For example in RNPaypalModule.java
,
private void sendEvent(String eventName,
@Nullable WritableMap params) {
_reactContext
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
.emit(eventName, params);
}
...
WritableMap cancelResult = Arguments.createMap();
cancelResult.putString("message", "User cancelled one time payment");
sendEvent("user_cancellation", cancelResult);
...
sendEvent("success_nonce_created", result);
@edc123 @nzankich hi Bros , i'm facing issue with android device. I 've tested many times but it still didn't work. The problem is the requestOneTimePayment or requestBillingAgreement only run 1 time and after that it does nothing. I try it in try catch but not catching anything. Any workaround guys ...
@edc123 generally it's a good idea to use promises rather than a listener in a case where an event is only going to be triggered once. I would rather fix this the right way rather than adding a hack but worse case it's something we could do
@edc123 @DangKhoi1997 have you tried reproducing this with the example app? I'm curious if there's a setup step missing
Also the device/version of android would help too
Hey @nzankich - I'd be happy to give that a go, but would need time as I have recently switched to a replacement laptop. This was both on a Pixel 4 with Android 11, an old Moto X with Lollipop, and also tested using Android devices on browserstack.
This issue is supposed to be resolved in the recent v4 beta versions of the Braintree SDKs