-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d45f064
commit 85b147e
Showing
5 changed files
with
356 additions
and
2 deletions.
There are no files selected for viewing
104 changes: 104 additions & 0 deletions
104
cypress-tests/cypress/e2e/PayoutTest/00003-CardTest.cy.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,104 @@ | ||
import createPayoutBody from "../../fixtures/create-payout-confirm-body.json"; | ||
import State from "../../utils/State"; | ||
import * as utils from "../PayoutUtils/utils"; | ||
|
||
let globalState; | ||
|
||
describe("Card - Auto Fulfill", () => { | ||
let should_continue = true; // variable that will be used to skip tests if a previous test fails | ||
|
||
beforeEach(function () { | ||
if(!should_continue) { | ||
this.skip(); | ||
} | ||
}); | ||
|
||
before("seed global state", () => { | ||
|
||
cy.task('getGlobalState').then((state) => { | ||
globalState = new State(state); | ||
console.log("seeding globalState -> " + JSON.stringify(globalState)); | ||
cy.task('cli_log', "SEEDING GLOBAL STATE -> " + JSON.stringify(globalState)); | ||
}) | ||
|
||
}) | ||
|
||
afterEach("flush global state", () => { | ||
console.log("flushing globalState -> " + JSON.stringify(globalState)); | ||
cy.task('setGlobalState', globalState.data); | ||
cy.task('cli_log', " FLUSHING GLOBAL STATE -> " + JSON.stringify(globalState)); | ||
}) | ||
|
||
context("Payout Card with Auto Fulfill", () => { | ||
|
||
it("confirm-payout-call-with-auto-fulfill-test", () => { | ||
let data = utils.getConnectorDetails(globalState.get("connectorId"))["card_pm"]["Fulfill"]; | ||
let req_data = data["Request"]; | ||
let res_data = data["Response"]; | ||
cy.createConfirmPayoutTest(createPayoutBody, req_data, res_data, true, true, globalState); | ||
if(should_continue) should_continue = utils.should_continue_further(res_data); | ||
}); | ||
|
||
it("retrieve-payout-call-test", () => { | ||
cy.retrievePayoutCallTest(globalState); | ||
}); | ||
|
||
}); | ||
|
||
context("Payout Card with Manual Fulfill - Create Confirm", () => { | ||
|
||
it("confirm-payout-call-with-manual-fulfill-test", () => { | ||
let data = utils.getConnectorDetails(globalState.get("connectorId"))["card_pm"]["Confirm"]; | ||
let req_data = data["Request"]; | ||
let res_data = data["Response"]; | ||
cy.createConfirmPayoutTest(createPayoutBody, req_data, res_data, true, false, globalState); | ||
if(should_continue) should_continue = utils.should_continue_further(res_data); | ||
}); | ||
|
||
it("fulfill-payout-call-test", () => { | ||
let data = utils.getConnectorDetails(globalState.get("connectorId"))["card_pm"]["Fulfill"]; | ||
let req_data = data["Request"]; | ||
let res_data = data["Response"]; | ||
cy.fulfillPayoutCallTest({}, req_data, res_data, globalState); | ||
if(should_continue) should_continue = utils.should_continue_further(res_data); | ||
}); | ||
|
||
it("retrieve-payout-call-test", () => { | ||
cy.retrievePayoutCallTest(globalState); | ||
}); | ||
|
||
}); | ||
|
||
context("Payout Card with Manual Fulfill - Create Intent + Confirm", () => { | ||
|
||
it("create-payout-call", () => { | ||
let data = utils.getConnectorDetails(globalState.get("connectorId"))["card_pm"]["Create"]; | ||
let req_data = data["Request"]; | ||
let res_data = data["Response"]; | ||
cy.createConfirmPayoutTest(createPayoutBody, req_data, res_data, false, false, globalState); | ||
if(should_continue) should_continue = utils.should_continue_further(res_data); | ||
}); | ||
|
||
it("confirm-payout-call", () => { | ||
let data = utils.getConnectorDetails(globalState.get("connectorId"))["card_pm"]["Confirm"]; | ||
let req_data = data["Request"]; | ||
let res_data = data["Response"]; | ||
cy.updatePayoutCallTest({}, req_data, res_data, false, globalState); | ||
if(should_continue) should_continue = utils.should_continue_further(res_data); | ||
}); | ||
|
||
it("fulfill-payout-call-test", () => { | ||
let data = utils.getConnectorDetails(globalState.get("connectorId"))["card_pm"]["Fulfill"]; | ||
let req_data = data["Request"]; | ||
let res_data = data["Response"]; | ||
cy.fulfillPayoutCallTest({}, req_data, res_data, globalState); | ||
if(should_continue) should_continue = utils.should_continue_further(res_data); | ||
}); | ||
|
||
it("retrieve-payout-call-test", () => { | ||
cy.retrievePayoutCallTest(globalState); | ||
}); | ||
|
||
}); | ||
|
||
}); |
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,60 @@ | ||
|
||
const card_data = { | ||
"card_number": "4111111111111111", | ||
"expiry_month": "3", | ||
"expiry_year": "2030", | ||
"card_holder_name": "John Smith" | ||
}; | ||
|
||
export const connectorDetails = { | ||
card_pm:{ | ||
"Create": { | ||
"Request": { | ||
"payout_method_data": { | ||
"card": card_data, | ||
}, | ||
"currency": "EUR", | ||
"payout_type": "card", | ||
}, | ||
"Response": { | ||
"status": 200, | ||
"body": { | ||
"status": "requires_creation", | ||
"payout_type": "card" | ||
} | ||
} | ||
}, | ||
"Confirm": { | ||
"Request": { | ||
"payout_method_data": { | ||
"card": card_data, | ||
}, | ||
"currency": "EUR", | ||
"payout_type": "card", | ||
}, | ||
"Response": { | ||
"status": 200, | ||
"body": { | ||
"status": "requires_fulfillment", | ||
"payout_type": "card" | ||
} | ||
} | ||
}, | ||
"Fulfill": { | ||
"Request": { | ||
"payout_method_data": { | ||
"card": card_data, | ||
}, | ||
"currency": "EUR", | ||
"payout_type": "card", | ||
}, | ||
"Response": { | ||
"status": 200, | ||
"body": { | ||
"status": "success", | ||
"payout_type": "card" | ||
} | ||
} | ||
} | ||
} | ||
}; |
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,30 @@ | ||
import { connectorDetails as adyenConnectorDetails } from "./Adyen.js"; | ||
|
||
const connectorDetails = { | ||
"adyen": adyenConnectorDetails, | ||
} | ||
|
||
|
||
export const getConnectorDetails = (connectorId) => { | ||
let x = getValueByKey(connectorDetails, connectorId); | ||
return x; | ||
} | ||
|
||
function getValueByKey(jsonObject, key) { | ||
const data = typeof jsonObject === 'string' ? JSON.parse(jsonObject) : jsonObject; | ||
|
||
if (data && typeof data === 'object' && key in data) { | ||
return data[key]; | ||
} else { | ||
return null; | ||
} | ||
} | ||
|
||
export const should_continue_further = (res_data) => { | ||
if(res_data.body.error !== undefined || res_data.body.error_code !== undefined || res_data.body.error_message !== undefined){ | ||
return false; | ||
} | ||
else { | ||
return true; | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
cypress-tests/cypress/fixtures/create-payout-confirm-body.json
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,36 @@ | ||
{ | ||
"amount": 1, | ||
"currency": "EUR", | ||
"customer_id": "payout_customer", | ||
"email": "[email protected]", | ||
"name": "John Doe", | ||
"phone": "999999999", | ||
"phone_country_code": "+65", | ||
"description": "Its my first payout request", | ||
"payout_type": "card", | ||
"payout_method_data": {}, | ||
"billing": { | ||
"address": { | ||
"line1": "1467", | ||
"line2": "Harrison Street", | ||
"line3": "Harrison Street", | ||
"city": "San Fransico", | ||
"state": "NY", | ||
"zip": "94122", | ||
"country": "US", | ||
"first_name": "John", | ||
"last_name": "Doe" | ||
}, | ||
"phone": { | ||
"number": "8056594427", | ||
"country_code": "+91" | ||
} | ||
}, | ||
"entity_type": "Individual", | ||
"recurring": false, | ||
"metadata": { | ||
"ref": "123" | ||
}, | ||
"auto_fulfill": true, | ||
"confirm": true | ||
} |
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