Skip to content

Commit

Permalink
docs: document the new exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
alitnk committed Oct 12, 2023
1 parent fa9164e commit f606cc2
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 24 deletions.
54 changes: 30 additions & 24 deletions apps/site/astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
26 changes: 26 additions & 0 deletions apps/site/src/content/docs/fa/usage/exceptions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
title: خطا‌ها
description: توضیح خطا‌هایی که کتابخانه می اندازد
---

ممکن است در طول بخش‌های مختلف پرداخت خطا‌هایی انداخته شود. شما می‌توانید از این خطا‌ها استفاده کنید تا به کاربر بازخورد بدهید.

## `BadConfigError`

این خطا در دو صورت انداخته می‌شود:
- در صورتی که تنظیماتی که به کتابخانه داده‌اید درست نباشد و توسط Zod شناسایی شود (قبل از این‌که به درگاه پرداخت برسد)
- در صورتی که درگاه پرداخت با خطا پاسخ دهد و بگوید که تنظیمات شما اشتباه است

این خطا یه صورت معمول به این معناست که شما، به‌عنوان توسعه‌دهنده، کاری را اشتباه کرده‌اید یا تنظیمات اشتباه دارید.

## `UserError`

این خطا وقتی انداخته می‌شود که کاربر کاری غیر از انجام پرداخت به صورت عادی کرده است. برای مثال ممکن است پرداخت را لغو کرده باشند.

## `GatewayFailureError`

نشان دهنده خطای ناشی از خرابی درگاه پرداخت یا یک دلیل غیرقابل تشخیص است.

## `MonopayError`

همه‌ی خطا‌های ذکر شده از این خطا ارث‌بری می‌کنند. بعضی اوقات شما می‌خواهید تمام خطا‌های مربوط به پرداخت را بگیرید. اگر می‌خواهید این‌کار را بکنید باید به دنبال این خطا باشید
26 changes: 26 additions & 0 deletions apps/site/src/content/docs/usage/exceptions.md
Original file line number Diff line number Diff line change
@@ -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.

0 comments on commit f606cc2

Please sign in to comment.