From f606cc287beef8c4bb5fc8c919e2216d97ce02f5 Mon Sep 17 00:00:00 2001 From: Alireza Zamani Date: Thu, 12 Oct 2023 10:12:28 +0330 Subject: [PATCH] docs: document the new exceptions --- apps/site/astro.config.mjs | 54 ++++++++++--------- .../src/content/docs/fa/usage/exceptions.md | 26 +++++++++ .../site/src/content/docs/usage/exceptions.md | 26 +++++++++ 3 files changed, 82 insertions(+), 24 deletions(-) create mode 100644 apps/site/src/content/docs/fa/usage/exceptions.md create mode 100644 apps/site/src/content/docs/usage/exceptions.md diff --git a/apps/site/astro.config.mjs b/apps/site/astro.config.mjs index 3c2142b..6a0e807 100644 --- a/apps/site/astro.config.mjs +++ b/apps/site/astro.config.mjs @@ -78,30 +78,36 @@ export default defineConfig({ translations: { fa: "نحوه استفاده", }, - autogenerate: { directory: "usage" }, - // items: [ - // { - // label: "Request Payment", - // link: "/usage/request-payment", - // translations: { - // fa: "درخواست پرداخت", - // }, - // }, - // { - // label: "Send User to the IPG", - // link: "/usage/send-user-to-ipg", - // translations: { - // fa: "انتقال کاربر به درگاه", - // }, - // }, - // { - // label: "Verify Payment", - // link: "/usage/verify-payment", - // translations: { - // fa: "تایید پرداخت", - // }, - // } - // ] + items: [ + { + label: "Request Payment", + link: "/usage/request-payment", + translations: { + fa: "درخواست پرداخت", + }, + }, + { + label: "Send User to the IPG", + link: "/usage/send-user-to-ipg", + translations: { + fa: "انتقال کاربر به درگاه", + }, + }, + { + label: "Verify Payment", + link: "/usage/exceptions", + translations: { + fa: "تایید پرداخت", + }, + }, + { + label: "Catching Exceptions", + link: "/usage/exceptions", + translations: { + fa: "کرفتن خطا‌ها", + }, + } + ] }, { label: "Advanced", diff --git a/apps/site/src/content/docs/fa/usage/exceptions.md b/apps/site/src/content/docs/fa/usage/exceptions.md new file mode 100644 index 0000000..a97ecf9 --- /dev/null +++ b/apps/site/src/content/docs/fa/usage/exceptions.md @@ -0,0 +1,26 @@ +--- +title: خطا‌ها +description: توضیح خطا‌هایی که کتابخانه می اندازد +--- + +ممکن است در طول بخش‌های مختلف پرداخت خطا‌هایی انداخته شود. شما می‌توانید از این خطا‌ها استفاده کنید تا به کاربر بازخورد بدهید. + +## `BadConfigError` + +این خطا در دو صورت انداخته می‌شود: +- در صورتی که تنظیماتی که به کتابخانه داده‌اید درست نباشد و توسط Zod شناسایی شود (قبل از این‌که به درگاه پرداخت برسد) +- در صورتی که درگاه پرداخت با خطا پاسخ دهد و بگوید که تنظیمات شما اشتباه است + +این خطا یه صورت معمول به این معناست که شما، به‌عنوان توسعه‌دهنده، کاری را اشتباه کرده‌اید یا تنظیمات اشتباه دارید. + +## `UserError` + +این خطا وقتی انداخته می‌شود که کاربر کاری غیر از انجام پرداخت به صورت عادی کرده است. برای مثال ممکن است پرداخت را لغو کرده باشند. + +## `GatewayFailureError` + +نشان دهنده خطای ناشی از خرابی درگاه پرداخت یا یک دلیل غیرقابل تشخیص است. + +## `MonopayError` + +همه‌ی خطا‌های ذکر شده از این خطا ارث‌بری می‌کنند. بعضی اوقات شما می‌خواهید تمام خطا‌های مربوط به پرداخت را بگیرید. اگر می‌خواهید این‌کار را بکنید باید به دنبال این خطا باشید diff --git a/apps/site/src/content/docs/usage/exceptions.md b/apps/site/src/content/docs/usage/exceptions.md new file mode 100644 index 0000000..2e71863 --- /dev/null +++ b/apps/site/src/content/docs/usage/exceptions.md @@ -0,0 +1,26 @@ +--- +title: Exceptions +description: Explaining the exceptions the package throws +--- + +Exceptions may be thrown during different parts of transaction. To provide your users information when things go wrong, you should catch these exceptions. + +## `BadConfigError` + +This error is thrown in two cases: +- If your provided configuration doesn't match the Zod schema for the driver (before even hitting the IPG API) +- If the payment gateway responds with an error status indicating your config is invalid + +This error usually means you, the developer, are doing something wrong or have misconfigured a driver. + +## `UserError` + +This error is thrown when the end-user does something other than going through the provided steps to pay. For example it be that they cancelled the payment. + +## `GatewayFailureError` + +Denotes an error either caused by a failure from gateway or an unrecognizable reason. + +## `MonopayError` + +All the above errors extend this error. Sometimes you want to catch all payment-related errors. If you want to do that, you should look for this error. \ No newline at end of file