Skip to content

Commit

Permalink
refactor: added request body in createPaymentIntent
Browse files Browse the repository at this point in the history
  • Loading branch information
Sanskar2001 committed Sep 18, 2024
1 parent b1b38a1 commit 3ec5858
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
11 changes: 7 additions & 4 deletions cypress-tests/cypress/e2e/card-flow-e2e-test.cy.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as testIds from "../../../src/Utilities/TestUtils.bs";
import { getClientURL } from "../support/utils";

import { createPaymentBody } from "../support/utils";
import { changeObjectKeyValue } from "../support/utils";

describe("Card payment flow test", () => {

Expand All @@ -9,11 +10,13 @@ describe("Card payment flow test", () => {
let getIframeBody : () => Cypress.Chainable<JQuery<HTMLBodyElement>>;
let iframeSelector =
"#orca-payment-element-iframeRef-orca-elements-payment-element-payment-element";
beforeEach(() => {
getIframeBody = () => cy.iframe(iframeSelector);

// changeObjectKeyValue(createPaymentBody,"profile_id","YOUR_PROFILE_ID")

cy.createPaymentIntent(secretKey).then(()=>{

beforeEach(() => {
getIframeBody = () => cy.iframe(iframeSelector);
cy.createPaymentIntent(secretKey,createPaymentBody).then(()=>{
cy.getGlobalState("clientSecret").then((clientSecret)=>{

cy.visit(getClientURL(clientSecret,publishableKey));
Expand Down
2 changes: 1 addition & 1 deletion cypress-tests/cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ Cypress.Commands.add(
);


Cypress.Commands.add("createPaymentIntent", (secretKey:string) => {
Cypress.Commands.add("createPaymentIntent", (secretKey:string,createPaymentBody:any) => {
return cy
.request({
method: "POST",
Expand Down
2 changes: 1 addition & 1 deletion cypress-tests/cypress/support/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ declare global {
testDynamicFields(
customerData: CustomerData, testIdsToRemoveArr: string[], isThreeDSEnabled: boolean
): Chainable<JQuery<HTMLElement>>
createPaymentIntent(secretKey:string): Chainable<Response<any>>
createPaymentIntent(secretKey:string,createPaymentBody:Record<string, any> ): Chainable<Response<any>>
getGlobalState(key: string): Chainable<Response<any>>
}
}
Expand Down
5 changes: 5 additions & 0 deletions cypress-tests/cypress/support/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ export const createPaymentBody ={
country_code: "+91",
},
},

}

export const changeObjectKeyValue=(object:Record<string, any> ,key:string,value:string)=>{
object[key]=value
}

export const confirmBody = {
Expand Down

0 comments on commit 3ec5858

Please sign in to comment.