getAccountById
احصل على حساب دفع بواسطة معرّفه.
الوصف
يجلب حساب دفع حسب معرّفه. يُعيد IAccountsEntity.
.getAccountById(
,
);
مخطط المعلمات
المخطط
id(required): number
معرّف حساب الدفع.
مثال: 12345
langCode: string
رمز اللغة. الافتراضي: لغة العميل.
مثال: the client's language
أمثلة
مثال بسيط
const response = await Payments.getAccountById(1);
إعدادات الحساب لـ Stripe
يعتمد الحقل settings في الحساب المُعاد على نوع الحساب. بالنسبة لحساب Stripe قد يبدو هكذا:
const account = await Payments.getAccountById(3);
if ('statusCode' in account) throw new Error(account.message);
console.log(account.settings);
// {
// "status": "connected",
// "stripeAccountId": "acct_...",
// "stripeOnboardingComplete": true,
// "stripePublishableKey": "pk_test_51OO...Y7MS3",
// "successUrl": "https://example.com/success",
// "cancelUrl": "https://example.com/cancel",
// "sessionTimeout": 15
// }
إعدادات الحساب لـ YooKassa
const account = await Payments.getAccountById(4); // a YooKassa account
if ('statusCode' in account) throw new Error(account.message);
console.log(account.settings);
// {
// "status": "connected",
// "shopId": "1234567",
// "successUrl": "https://example.com/success",
// "cancelUrl": "https://example.com/cancel",
// "sessionTimeout": 15
// }
حقول المزود هذه ليست جزءًا من النوع IPaymentAccountSettings، الذي لا يعلن إلا status. بيانات اعتماد المزود أسرار على جانب الخادم: لا تعتمد على أي حقول مفاتيح في هذه الاستجابة ولا تكشفها، لأنها قد تُزال.
مثال على الاستجابة
{
"id": 1,
"identifier": "cash",
"isVisible": true,
"localizeInfos": {
"title": "Cash"
},
"type": "custom",
"isUsed": true,
"testMode": true,
"settings": {
"status": "connected"
},
"testSettings": {
"status": "connected"
},
"updatedDate": "2025-02-25T08:55:43.957Z"
}
مخطط الاستجابة
المخطط: IAccountsEntity
id: number
معرّف الكائن.
مثال: 12345
localizeInfos: ILocalizeInfo
الاسم والوصف المترجمان لحساب الدفع.
identifier: string
علامة حساب الدفع.
مثال: "payment_12345"
type: 'stripe' | 'yookassa' | 'midtrans' | 'xendit' | 'custom'
نوع مزود الدفع.
مثال: 'stripe'
isVisible: boolean
هل حساب الدفع ظاهر.
مثال: true
isUsed: boolean
هل حساب الدفع قيد الاستخدام.
مثال: false
testMode: boolean
هل حساب الدفع في وضع الاختبار.
مثال: true
settings: IPaymentAccountSettings
إعدادات حساب الدفع.
مثال:
{ "status": "connected" }
settings.status: string
حالة الاتصال بحساب الدفع المباشر (غير الاختباري).
مثال: "connected"
testSettings: object
إعدادات وضع الاختبار لحساب الدفع.
updatedDate: string
تاريخ آخر تعديل للكائن.
مثال: "2025-02-26T10:13:16.839Z"
version: number
عدّاد مراجعة حساب الدفع، يزداد مع كل تغيير.
مثال: 3