From 2a88d1cd0bc83f0d6697eddca7f7664946c1ecac Mon Sep 17 00:00:00 2001 From: Stephen Daly Date: Mon, 13 Nov 2023 11:39:24 +0000 Subject: [PATCH] PP-11578 Add pact test for declined Google Pay payment (#3765) Add Pact test that checks a 400 response code is returned with a request body containing "error_identifier"="AUTHORISATION_REJECTED" for a declined Google Pay payment --- ...box-google-pay-authentication.pact.test.js | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/test/unit/clients/connector-client-sandbox-google-pay-authentication.pact.test.js b/test/unit/clients/connector-client-sandbox-google-pay-authentication.pact.test.js index 922fca78f..ea05cbf15 100644 --- a/test/unit/clients/connector-client-sandbox-google-pay-authentication.pact.test.js +++ b/test/unit/clients/connector-client-sandbox-google-pay-authentication.pact.test.js @@ -62,5 +62,35 @@ describe('Connector Client - Google Pay authorisation API - Sandbox payment', fu }).catch((err) => done(new Error('should not be hit: ' + JSON.stringify(err)))) }) }) + + describe('authorisation declined', function () { + const googlePayAuthRequest = fixtures.worldpayOrSandboxGoogleAuthRequestDetails() + const authorisationDeclinedResponse = fixtures.webPaymentDeclinedResponse() + before(() => { + const builder = new PactInteractionBuilder(GOOGLE_AUTH_PATH) + .withRequestBody(googlePayAuthRequest) + .withMethod('POST') + .withState('a sandbox account exists with a charge with id testChargeId and description DECLINED that is in state ENTERING_CARD_DETAILS.') + .withUponReceiving('a valid sandbox google pay auth request which should be declined') + .withResponseBody(pactify(authorisationDeclinedResponse)) + .withStatusCode(400) + .build() + return provider.addInteraction(builder) + }) + + afterEach(() => provider.verify()) + + it('should return authorisation declined with error identifier in response payloads', function (done) { + const payload = googlePayAuthRequest + connectorClient({ baseUrl: BASEURL }).chargeAuthWithWallet({ + chargeId: TEST_CHARGE_ID, + wallet: 'google', + payload: payload + }).then(res => { + expect(res.body.error_identifier).to.be.equal('AUTHORISATION_REJECTED') + done() + }).catch((err) => done(new Error('should not be hit: ' + JSON.stringify(err)))) + }) + }) }) })