react-native-paypal icon indicating copy to clipboard operation
react-native-paypal copied to clipboard

Not closing the webview after payment is successful

Open eskiesirius opened this issue 4 years ago • 11 comments

eskiesirius avatar Jul 07 '20 21:07 eskiesirius

can you show me your code please @eskiesirius

mitesh-db avatar Aug 13 '20 07:08 mitesh-db

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];
}

nzankich avatar Aug 19 '20 01:08 nzankich

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.

jitenderbadoni avatar Oct 15 '20 10:10 jitenderbadoni

@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

nzankich avatar Oct 18 '20 03:10 nzankich

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

nzankich avatar Oct 22 '20 16:10 nzankich

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 avatar Dec 08 '20 02:12 edc123

@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 ...

DangKhoi1997 avatar Dec 08 '20 08:12 DangKhoi1997

@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

nzankich avatar Dec 10 '20 07:12 nzankich

@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

nzankich avatar Dec 10 '20 07:12 nzankich

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.

edc123 avatar Dec 21 '20 01:12 edc123

This issue is supposed to be resolved in the recent v4 beta versions of the Braintree SDKs

aganov avatar May 19 '21 14:05 aganov