Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Payment via PayPal always fails. #405

Closed
glennposadas opened this issue Jun 11, 2018 · 8 comments
Closed

Payment via PayPal always fails. #405

glennposadas opened this issue Jun 11, 2018 · 8 comments

Comments

@glennposadas
Copy link

glennposadas commented Jun 11, 2018

General information

  • SDK/Library version: v4
  • Environment: sandbox
  • iOS Version and Device: iPhone 7plus iOS 11.x
  • Integration type and version: Cocoapods 1.4.0

Issue description

As the title says, my payment (in iOS) always fails. While apparently, the payment in my colleague's work (Android) succeeds.

I followed thoroughly the sample codes and guidelines from here: https://developers.braintreepayments.com/guides/paypal/client-side/ios/v4

In iOS, after all the process (Client Token from our Server --> BT SDK --> PayPal browser --> App --> send nonce to our server), the error I get from our server is always:

PayPal pending payments are not supported

My backend guy does not know the reason behind this too, he only showed and gave me this log:

{
   "errors": {},
   "params": {
       "transaction": {
           "type": "sale",
           "amount": "1",
           "merchantAccountId": "USD",
           "paymentMethodNonce": "80823f63-5ea9-0b8b-67da-0710bd7d9ff1",
           "orderId": "333",
           "descriptor": {
               "name": "company name*myurl.com"
           },
           "options": {
               "submitForSettlement": "true",
               "paypal": {
                   "customField": "custom",
                   "description": "description"
               }
           }
       }
   },
   "message": "Unknown or expired payment_method_nonce.",
   "creditCardVerification": null,
   "transaction": null,
   "subscription": null,
   "merchantAccount": null,
   "verification": null
}

BTW, here's what I do in setting up my SDK:

private func processPayPalClientToken(_ clientToken: String) {
        SVProgressHUD.show(withStatus: "Please wait...")
        
        self.braintreeClient = BTAPIClient(authorization: clientToken)

        let payPalDriver = BTPayPalDriver(apiClient: self.braintreeClient)
        payPalDriver.viewControllerPresentingDelegate = self
        payPalDriver.appSwitchDelegate = self
        
        let request = BTPayPalRequest(amount: self.bookingViewModel.getTotalAmount())
        payPalDriver.requestOneTimePayment(request) { (nonce, error) in
            SVProgressHUD.dismiss(completion: {
                if let error = error {
                    self.showAlert(title: "title...", message: "Error: \(error.localizedDescription).", okayButtonTitle: "OK") { _ in }
                    return
                }
                
                guard let nonce = nonce else { return }
                
                self.processNonceToServer(nonce)
            })

        }
    }
@demerino
Copy link
Member

@glennposadas You probably want to just send the nonce string to your server. Not the nonce object. See the reference for BTPaymentMethodNonce: https://braintree.github.io/braintree_ios/Classes/BTPaymentMethodNonce.html#/c:objc(cs)BTPaymentMethodNonce(py)nonce

Try something like

self.processNonceToServer(nonce.nonce)

Let us know if you're still having problems.

@glennposadas
Copy link
Author

Hi @demerino thank you for the reply, what took you guys to notice this open ticket posted 7 days ago? :( Anyways, inside that processNonceToServer, I get the nonce.nonce (the String)... Someone in your team posted an answer here on my SO post: https://stackoverflow.com/questions/50793996/payment-via-braintree-paypal-always-fails-ios

Didn't help though. I believe not using BraintreeDropIn causes this issue. I will confirm this within an hour. I have two projects that do not use BraintreeDropIn and. these two projects. have similar issues. And then here comes the third project, I used BraintreeDropIn there and I didn't have this issue.

Oh btw, in my second project, I used to use BraintreeDropIn there and it used to work, but my team demanded that we should not use BraintreeDropIn, only then this issue came in. Now I have the time to revert everything back to BraintreeDropIn. Let me see if the issue will go away using that BraintreeDropIn.

@Epreuve
Copy link

Epreuve commented Jun 19, 2018

@glennposadas It looks like you're using two different accounts. The authorization you're using to setup your iOS client is from account A, but you're attempting to use that nonce to create a transaction with account B. A nonce can only be used with the account it was created with.

Can you double check that you and your back end team are using the same API credentials for both front and back end? Fixing this mismatch should solve the issue.

@glennposadas
Copy link
Author

Hey @Epreuve thanks for the reply! I am pretty sure the clientToken my iOS client is for the PayPal sandbox account I am paying for. But again, it is weird that the Android client gets successful payment transaction everytime. My Android dev colleague mentioned to me as well that I can't just use BraintreeDropIn cause we're using Express Checkout and not Direct Payment, I'm not sure if that's correct. So I am supposed to work on this issue that has been here for a week. It happens in two iOS applications that I have right now.

@Epreuve
Copy link

Epreuve commented Jun 20, 2018

@glennposadas I just double checked the logs, and the client token generated was from a different account than the one that attempted to use the nonce to create a transaction.

The issue is likely the credentials being used to generate the client token at your endpoint, are from a different account than those being used by the code on the server that's attempting to make the transaction. Using the same credentials in both environments should solve the problem.

If you're hardcoding a token or using a tokenization key for testing, you'll need to make sure that it's from the same account who's credentials are being used to create transactions.

If you'd like specifics around the accounts we're seeing tied to the nonce in your issue, feel free to reach out to our support team. They can send more specifics directly, than we would like to share on an open medium like Github.

@glennposadas
Copy link
Author

Thank you so much for the help, @Epreuve . We've discovered something.

  1. We can pay successfully using this CREDIT UNION payment method.
  2. BUT we can't pay using PAYPAL BALANCE.
  3. The errors like

PayPal pending payments are not supported

happens in PayPal Balance option.

-- Question is, what do we need to do with the PayPal to make the PayPal balance option working?

@glennposadas
Copy link
Author

I guess we can now close this, but uhhh the PayPal Balance issue still needs to be resolved. Thanks for the help!

@Epreuve
Copy link

Epreuve commented Jun 20, 2018

@glennposadas That error might be related to this thread.

Could you take a look and try the steps outlined to see if it resolves the PayPal pending payments are not supported. error you're seeing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants