-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PP-11578 Support Google Pay for sandbox (#3762)
* PP-11578 Support Google Pay for sandbox - Show Google Pay option for sandbox accounts, if the `allow_google_pay` flag is set to true for the gateway account - At this time, do not support an environment variable for disabling Google Pay on sandbox. We suspect we will not have the need to disable it globally, as if it stops working on Sandbox it will not affect paying users. - Add pact test for making a request to connector to authorise a sandbox Google Pay payment when connector returns a success response. This commit does not add a Pact test for a declined response - this will come in a later commit as we need a special state for this.
- Loading branch information
1 parent
cb5410c
commit 7418a51
Showing
8 changed files
with
142 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
66 changes: 66 additions & 0 deletions
66
test/unit/clients/connector-client-sandbox-google-pay-authentication.pact.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
'use strict' | ||
|
||
const path = require('path') | ||
const { Pact } = require('@pact-foundation/pact') | ||
const chai = require('chai') | ||
const chaiAsPromised = require('chai-as-promised') | ||
|
||
const connectorClient = require('../../../app/services/clients/connector.client') | ||
const fixtures = require('../../fixtures/wallet-payment.fixtures') | ||
const { PactInteractionBuilder } = require('../../test-helpers/pact/pact-interaction-builder') | ||
const { pactify } = require('../../test-helpers/pact/pact-base')() | ||
|
||
const expect = chai.expect | ||
chai.use(chaiAsPromised) | ||
|
||
const TEST_CHARGE_ID = 'testChargeId' | ||
const GOOGLE_AUTH_PATH = `/v1/frontend/charges/${TEST_CHARGE_ID}/wallets/google` | ||
const PORT = Math.floor(Math.random() * 48127) + 1024 | ||
const BASEURL = `http://127.0.0.1:${PORT}` | ||
|
||
describe('Connector Client - Google Pay authorisation API - Sandbox payment', function () { | ||
const provider = new Pact({ | ||
consumer: 'frontend', | ||
provider: 'connector', | ||
port: PORT, | ||
log: path.resolve(process.cwd(), 'logs', 'mockserver-integration.log'), | ||
dir: path.resolve(process.cwd(), 'pacts'), | ||
spec: 2, | ||
pactfileWriteMode: 'merge' | ||
}) | ||
|
||
before(() => provider.setup()) | ||
after(() => provider.finalize()) | ||
|
||
describe('Authorise Sandbox Google Pay payment', function () { | ||
describe('authorisation success', function () { | ||
const successfulGoogleAuthRequest = fixtures.worldpayOrSandboxGoogleAuthRequestDetails() | ||
const authorisationSuccessResponse = fixtures.webPaymentSuccessResponse() | ||
before(() => { | ||
const builder = new PactInteractionBuilder(GOOGLE_AUTH_PATH) | ||
.withRequestBody(successfulGoogleAuthRequest) | ||
.withMethod('POST') | ||
.withState('a sandbox account exists with a charge with id testChargeId that is in state ENTERING_CARD_DETAILS.') | ||
.withUponReceiving('a valid sandbox google pay auth request which should be authorised') | ||
.withResponseBody(pactify(authorisationSuccessResponse)) | ||
.withStatusCode(200) | ||
.build() | ||
return provider.addInteraction(builder) | ||
}) | ||
|
||
afterEach(() => provider.verify()) | ||
|
||
it('should return authorisation success', function (done) { | ||
const payload = successfulGoogleAuthRequest | ||
connectorClient({ baseUrl: BASEURL }).chargeAuthWithWallet({ | ||
chargeId: TEST_CHARGE_ID, | ||
wallet: 'google', | ||
payload: payload | ||
}).then(res => { | ||
expect(res.body.status).to.be.equal('AUTHORISATION SUCCESS') | ||
done() | ||
}).catch((err) => done(new Error('should not be hit: ' + JSON.stringify(err)))) | ||
}) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters