Taracque / cordova-plugin-braintree

:credit_card: A Cordova plugin for the Braintree mobile payment processing SDK.
MIT License
27 stars 42 forks source link

Payment method paypal is not working for android #13

Open Amarjit1234 opened 7 years ago

Amarjit1234 commented 7 years ago

When i select payment method PayPal that is not working for android where payment method credit or debit card is working.

Taracque commented 7 years ago

Do you have PayPal enabled in you Braintree account?

Deeeej commented 6 years ago

I actuallly have the same issue but on iOS. The user is presented with 3 options in the pop-up, PayPal, Credit or Debit Card or Apple Pay. Pressing on 'Credit of Debit Card' or 'Apple Pay' takes them to the next screen in the payment flow, but clicking on 'PayPal' does nothing. Paypal is enabled in the Braintree Account. Does anyone know any other circumstances where the PayPal option does not work/do anything when you press on it? I have tried using both a tokenization key and a unique client token, neither seem to have an effect.

Any help greatly appreciated.

albertopq commented 6 years ago

Same issue here, in both iOS and Android. Any idea?

Deeeej commented 6 years ago

I managed to get to the bottom of this error. The solution is bizarre, some sort of magic configuration string. PayPal is trying to launch a browser window to start the PayPal payment flow. Firstly, I did not know this, I thought it would be handled in-app, but essentially by clicking on the PayPal option it takes you to paypal.com via a browser window.

In order to get this working you need to put the following line in your config.xml, where you replace 'nameofapplication' with the name of your application, Bundle ID, I believe.

I have no idea why it requires a .payment extension.

 <config-file target="*-Info.plist" parent="CFBundleURLTypes">
      <array>
        <dict>
          <key>CFBundleTypeRole</key>
          <string>Editor</string>
          <key>CFBundleURLSchemes</key>
          <array>
            <string>nameofapplication.payments</string>
          </array>
        </dict>
      </array>
    </config-file> 

There is a recent pull request for the file 'add_embedded_ios_frameworks.js' which checks if the version of cordova is 7 or higher, and if it is, it exits executing that file. This is essentially a bug because the bottom of the file adds the above config to the config.xml, and this won't happen if you are on cordova 7 or higher.

I hope this helps someone who becomes a future version of me a few weeks ago.

albertopq commented 6 years ago

Thanks @Deeeej , that seems right as I came with the same solution in iOS. Apparently yo need to add a new URL type in XCode for allowing the app navigating to Paypal's.

https://developers.braintreepayments.com/guides/paypal/client-side/ios/v4

Hope this helps as well!

albertopq commented 6 years ago

@Amarjit1234 Just found this:

important

Your app's URL scheme must begin with your app's package ID and end with .braintree. For example, if the Package ID is com.your-company.your-app, then your URL scheme should be com.your-company.your-app.braintree. ${applicationId} is automatically applied with your app's package when using Gradle.

Note: The scheme you define must use all lowercase letters. If your package contains underscores, the underscores should be removed when specifying the scheme in your Android Manifest.

In my case, this The scheme you define must use all lowercase letters was causing the issue in Android. So, make sure yor APP_ID is all lowercase.

Hope this helps.