Reputation: 31
We are integrating with PayPal checkout using the Braintree integration - as such we have sandbox accounts with Braintree and PayPal and have also enabled negative testing in the PayPal developer account linked to our PayPal merchant account. All the payments we put through, whether they be via a PayPal buyer account or the PayPal Guest Checkout process successfully and we get the expected processing confirmation via Braintree.
We now want to explore negative testing of this interface (e.g. a card decline) but can not establish how to trigger a negative response - the amounts that send failure responses from the Braintree solution don't work (e.g. 2001), nor do those documented in PayPal (e.g. 131.13).
The failure modes we want to explore are a refusal by the PayPal payment window to return a nonce, or to return a nonce that will be deemed invalid, and then for the serverside transaction to fail based on a valid nonce but some processing or validation error.
Initially our development combined both direct Credit Card payments and via PayPal – the direct credit card payment process responded to the negative test scenarios as suggested by Braintree (e.g. from https://developers.braintreepayments.com/reference/general/testing/java we used card 4111 1111 1111 1111 and then from https://developers.braintreepayments.com/reference/general/processor-responses/authorization-responses could use values such as 2001).
For PayPal we have linked the Braintree Sandbox and PayPal Sandbox accounts as described in https://developers.braintreepayments.com/guides/paypal/testing-go-live/java#linked-paypal-testing and consequently see all our successful transactions reflected in both our PayPal sandbox console and the Braintree. However I can’t trigger a negative response – examples tried include:
• trying to pay with merchant account (The statement in https://developers.braintreepayments.com/guides/paypal/testing-go-live/java#linked-paypal-testing “Do not use your PayPal business account as the PayPal customer account when paying for test transactions in the linked PayPal flow or in production. Doing so will result in declines” doesn’t work as advertised, PayPal won’t allow me to login with the business account to take a payment), using test
• using codes described in https://developer.paypal.com/docs/classic/lifecycle/sandbox/sb-error-conditions/, irrespective of whether I use my PayPal buyer account, or the guest checkout process, sending $106.10 does not trigger the Authorisation error – but perhaps because the Braintree integration invokes the ‘payment’ method in the PayPal checkout library and maybe this method is not equivalent to the method the documentation references.
Can anyone enlighten us on how to force a failure response and where the failure responses pertinent to this solution are documented. We are presuming we can do this solely by using specific amounts / card numbers etc. to tap into a library of stubbed responses rather than deploying code that triggers a behaviour.
Thank you
Upvotes: 3
Views: 1541
Reputation: 30379
Braintree uses PayPal REST APIs. The method used for negative testing with REST APIs is documented here: https://developer.paypal.com/docs/api/request-headers/#enable-negative-testing
Since there does not seem to be any way to tell Braintree to send those mock headers to PayPal, there is no way to use this negative testing mechanism on the PayPal side.
The workaround I've used is to simply not depend on the actual webservice/network response to do the negative testing. Instead, receive a success response but -- before processing the response -- alter it to be a failure, and then process it. Esentially, add a small framework to your HTTPS or SDK caller to inject your own failures when they first ingest the response. This way you can test all your later code paths for handling such a failed response, which is all negative testing needs to accomplish.
Upvotes: 0