Skip to content

Commit

Permalink
PP-11578 Add pact test for declined Google Pay payment (#3765)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
stephencdaly authored Nov 13, 2023
1 parent b8b93a7 commit 2a88d1c
Showing 1 changed file with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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))))
})
})
})
})

0 comments on commit 2a88d1c

Please sign in to comment.