How to test paypal payment using braintree sandbox

3.2k views Asked by At

I am using braintree in my app for payment(Credit card & Paypal). I am using custom UI. When click on pay by Paypal button, i am using the following code.

    braintreeClient = BTAPIClient(authorization: tokenizationKey)!
    let payPalDriver = BTPayPalDriver(APIClient: braintreeClient)
    payPalDriver.viewControllerPresentingDelegate = self
    //payPalDriver.appSwitchDelegate = self // Optional

    // Specify the transaction amount here. "2.32" is used in this example.
    let request = BTPayPalRequest(amount: "2.32")
    request.currencyCode = "USD" // Optional; see BTPayPalRequest.h for more options

    payPalDriver.requestOneTimePayment(request) { (tokenizedPayPalAccount, error) in
        if let tokenizedPayPalAccount = tokenizedPayPalAccount {
            print("Got a nonce: \(tokenizedPayPalAccount.nonce)")

            // Access additional information

            // See BTPostalAddress.h for details

        } else if error != nil {
            // Handle error here...
        } else {
            // Buyer canceled payment approval
        }
    }

It opens this link https://checkout.paypal.com/one-touch-login-sandbox/index.html?action=setup_billing_agreement&ba_token=BA-HERMES-SANDBOX-TOKEN&cancel_url=com.pronto.btreeInteg.payments%3A%2F%2Fonetouch%2Fv1%2Fcancel&controller=client_api%2Fpaypal_hermes&experience_profile%5Baddress_override%5D=false&experience_profile%5Bno_shipping%5D=1&merchant_id=qkd2xjhc84nhd5b3&return_url=com.pronto.btreeInteg.payments%3A%2F%2Fonetouch%2Fv1%2Fsuccess&version=1 . It gives me dummy nonce. i want check with my Paypal a/c by login. Right now i am using Braintree sandbox a/c.

1

There are 1 answers

0
Shea On

Full disclosure: I work at Braintree.

What you have described is the expected behavior for sandbox accounts. See the Braintree docs:

PayPal transactions initiated with sandbox API keys cannot be used for full end-to-end testing. The goal of sandbox testing is to ensure your client and server side configurations are correct and that you are receiving appropriate responses for your requests. If you wish to do end-to-end testing, you will need to do that in your production account.

However, if you have further questions about testing PayPal with your sandbox account, please contact Braintree support to see how your needs can be met.