Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[change] Select toast level based on payment status #727

Merged
merged 1 commit into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion client/utils/get-payment-status.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ export const getPaymentStatus = async (orgSlug, paymentId, tokenInfo) => {
});
if (response.status === 200) {
if (response.data.message) {
toast.error(response.data.message);
if (response.data.status === "failed") {
toast.error(response.data.message);
} else {
toast.info(response.data.message);
}
}
return response.data.status;
}
Expand Down
4 changes: 4 additions & 0 deletions client/utils/utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -783,12 +783,14 @@ describe("getPaymentStatusRedirectUrl tests", () => {
});
it("should return success URL if payment status is success", async () => {
const {orgSlug, paymentId, tokenInfo, setUserData, userData} = getArgs();
const infoToast = jest.spyOn(dependency.toast, "info");
axios.mockImplementationOnce(() =>
Promise.resolve({
status: 200,
statusText: "OK",
data: {
status: "success",
message: "Payment succeeded",
},
}),
);
Expand All @@ -806,6 +808,8 @@ describe("getPaymentStatusRedirectUrl tests", () => {
mustLogin: true,
payment_url: null,
});
expect(infoToast).toHaveBeenCalledTimes(1);
expect(infoToast).toHaveBeenCalledWith("Payment succeeded");
});
it("should return failure URL if payment status is failed", async () => {
const {orgSlug, paymentId, tokenInfo, setUserData, userData} = getArgs();
Expand Down
Loading