fix(payment): allow Stripe after closing QRIS
Docker Image / Build and Push Docker Image (push) Successful in 2m4s
Docker Image / Build and Push Docker Image (push) Successful in 2m4s
This commit is contained in:
@@ -85,11 +85,14 @@ async function registerIndonesiaPaymentMocks(page: Page) {
|
||||
});
|
||||
await page.route("**/api/payment/create-order", async (route) => {
|
||||
createOrderCount += 1;
|
||||
const body = route.request().postDataJSON() as { planId: string };
|
||||
const body = route.request().postDataJSON() as {
|
||||
planId: string;
|
||||
payChannel: "ezpay" | "stripe";
|
||||
};
|
||||
const plan =
|
||||
idrPlans.plans.find((item) => item.planId === body.planId) ??
|
||||
idrGiftCatalog.plans.find((item) => item.planId === body.planId);
|
||||
const orderId = `order_qris_${body.planId}`;
|
||||
const orderId = `order_${body.payChannel}_${body.planId}`;
|
||||
orderStatuses.set(orderId, "pending");
|
||||
orderPlans.set(orderId, {
|
||||
planId: body.planId,
|
||||
@@ -98,15 +101,21 @@ async function registerIndonesiaPaymentMocks(page: Page) {
|
||||
await route.fulfill({
|
||||
json: apiEnvelope({
|
||||
orderId,
|
||||
payParams: {
|
||||
provider: "ezpay",
|
||||
countryCode: "ID",
|
||||
channelCode: "ID_QRIS_DYNAMIC_QR",
|
||||
channelType: "QR",
|
||||
payData: "00020101021226670016COM.NOBUBANK.WWW",
|
||||
firstChargeAmountCents: plan?.amountCents ?? 0,
|
||||
currency: "IDR",
|
||||
},
|
||||
payParams:
|
||||
body.payChannel === "stripe"
|
||||
? {
|
||||
provider: "stripe",
|
||||
clientSecret: "pi_e2e_secret_mock",
|
||||
}
|
||||
: {
|
||||
provider: "ezpay",
|
||||
countryCode: "ID",
|
||||
channelCode: "ID_QRIS_DYNAMIC_QR",
|
||||
channelType: "QR",
|
||||
payData: "00020101021226670016COM.NOBUBANK.WWW",
|
||||
firstChargeAmountCents: plan?.amountCents ?? 0,
|
||||
currency: "IDR",
|
||||
},
|
||||
}),
|
||||
});
|
||||
});
|
||||
@@ -183,7 +192,7 @@ async function expectQrisOrder(
|
||||
await expect(
|
||||
dialog.getByRole("img", { name: "QRIS payment QR code" }),
|
||||
).toBeVisible();
|
||||
return `order_qris_${planId}`;
|
||||
return `order_ezpay_${planId}`;
|
||||
}
|
||||
|
||||
async function expectCheckoutButtonLayout(page: Page) {
|
||||
@@ -299,6 +308,47 @@ test("closing QRIS restores a resumable checkout without creating a duplicate or
|
||||
).toBeVisible({ timeout: 10_000 });
|
||||
});
|
||||
|
||||
test("closing QRIS allows switching to Stripe and creating a Stripe order", async ({
|
||||
page,
|
||||
}) => {
|
||||
const payment = await registerIndonesiaPaymentMocks(page);
|
||||
await prepareIndonesiaUser(page);
|
||||
await page.goto("/subscription?type=topup&character=elio");
|
||||
|
||||
await expectQrisOrder(
|
||||
page,
|
||||
/Pay and Top Up/i,
|
||||
"dol_1000",
|
||||
/Rp\s*88[.,]900/,
|
||||
);
|
||||
const dialog = page.getByRole("dialog", { name: "Scan to pay with QRIS" });
|
||||
await dialog.getByRole("button", { name: "Close" }).click();
|
||||
await expect(dialog).toBeHidden();
|
||||
|
||||
const stripeButton = page.getByRole("button", {
|
||||
name: "Stripe",
|
||||
exact: true,
|
||||
});
|
||||
await expect(stripeButton).toBeEnabled();
|
||||
await stripeButton.click();
|
||||
await expect(stripeButton).toHaveAttribute("aria-pressed", "true");
|
||||
await expect(
|
||||
page.getByRole("button", { name: "Resume QRIS payment" }),
|
||||
).toHaveCount(0);
|
||||
|
||||
const stripeRequestPromise = page.waitForRequest(
|
||||
"**/api/payment/create-order",
|
||||
);
|
||||
await page.getByRole("button", { name: "Pay and Top Up" }).click();
|
||||
const stripeRequest = await stripeRequestPromise;
|
||||
expect(stripeRequest.postDataJSON()).toMatchObject({
|
||||
planId: "dol_1000",
|
||||
payChannel: "stripe",
|
||||
recipientCharacterId: "elio",
|
||||
});
|
||||
expect(payment.getCreateOrderCount()).toBe(2);
|
||||
});
|
||||
|
||||
test("payment issue submits Other to the feedback API without creating an order", async ({
|
||||
page,
|
||||
}) => {
|
||||
|
||||
Reference in New Issue
Block a user