إنشاء نية الدفع
بعد إنشاء "نية الدفع"، قم بإرفاق طريقة دفع وتأكيد النية لإتمام المعاملة.
يعد استخدام confirm=true أثناء الإنشاء معادلاً لإنشاء نية الدفع وتأكيدها في نفس الاستدعاء. ويتيح تطبيق confirm=true استخدام أي معلمات في واجهة برمجة التطبيقات confirm.
POST https://api.stripe.com/v1/payment_intents
ملاحظة
يجب إرسال طلب confirm عبر HTTPS.
أمثلة
مثال على cURL:
cURL
curl -X POST https://api.stripe.com/v1/payment_intents \
-u <YOUR_SECRET_KEY>: \
-d "amount=212¤cy=usd&payment_method=pm_card_visa&confirm=true"
الردود
تُرجع الاستجابات رموزًا قياسية.
200: OK
Response
{
"id": "pi_3Rsx4dDtWMrPDtgt0mUrePJ9",
"object": "payment_intent",
"amount": 212,
"amount_capturable": 0,
"amount_details": {
"tip": {}
},
"amount_received": 0,
"application": null,
"application_fee_amount": null,
"automatic_payment_methods": {
"allow_redirects": "always",
"enabled": true
},
"canceled_at": null,
"cancellation_reason": null,
"capture_method": "automatic_async",
"client_secret": "pi_3Rsx4dDtWMrPDtgt0mUrePJ9_secret_7sqfufxuIYiBhbw52Vi51Z47o",
"confirmation_method": "automatic",
"created": 1754447247,
"currency": "usd",
"customer": null,
"description": null,
"last_payment_error": null,
"latest_charge": null,
"livemode": false,
"metadata": {},
"next_action": null,
"on_behalf_of": null,
"payment_method": null,
"payment_method_configuration_details": {
"id": "pmc_1RsGk1DtWMrPDtgtcaQ0d3Sg",
"parent": null
},
"payment_method_options": {
"amazon_pay": {
"express_checkout_element_session_id": null
},
"card": {
"installments": null,
"mandate_options": null,
"network": null,
"request_three_d_secure": "automatic"
},
"cashapp": {},
"klarna": {
"preferred_locale": null
},
"link": {
"persistent_token": null
}
},
"payment_method_types": [
"card",
"klarna",
"link",
"cashapp",
"amazon_pay"
],
"processing": null,
"receipt_email": null,
"review": null,
"setup_future_usage": null,
"shipping": null,
"source": null,
"statement_descriptor": null,
"statement_descriptor_suffix": null,
"status": "requires_payment_method",
"transfer_data": null,
"transfer_group": null
}
استجابات الأخطاء
400: Bad Request
Response
{
"error": {
"code": "parameter_invalid_integer",
"doc_url": "https://stripe.com/docs/error-codes/parameter-invalid-integer",
"message": "Invalid integer: <integer>",
"param": "amount",
"request_log_url": "https://dashboard.stripe.com/test/logs/req_UQf6XBwBl9yk66?t=1734829676",
"type": "invalid_request_error"
}
}
401: Unauthorized
Response
{
"error": {
"type": "invalid_request_error",
"message": "Invalid API Key provided: sk_test_********************1234"
}
}
المعلمات
معلمات النص الأساسي
| المعلمة | النوع | الوصف |
|---|---|---|
amount | عدد صحيح | (مطلوب) المبلغ الإجمالي المطلوب تحصيله. أدخل عددًا صحيحًا موجبًا منسقًا وفقًا لأصغر وحدة من العملة (مثل 100 سنت مقابل 1.00 دولار). |
currency | سلسلة نصية | (مطلوب) رمز العملة ISO المكون من ثلاثة أحرف، بأحرف صغيرة. يجب أن تكون العملة مدعومة. |
confirm | قيمة منطقية | اضبط القيمة على "true" لمحاولة تأكيد نية الدفع هذه على الفور. |
customer | سلسلة نصية | معرّف العميل الذي تنتمي إليه نية الدفع هذه، إن وجدت. |
description | سلسلة نصية | سلسلة نصية عشوائية مرفقة بالكائن. |
payment_method | سلسلة نصية | معرف طريقة الدفع المراد إرفاقها بـ PaymentIntent. |
payment_method_types[] | مصفوفة سلاسل نصية | قائمة أنواع طرق الدفع التي يمكن أن يستخدمها نية الدفع (PaymentIntent) هذه. |
shipping | كائن | معلومات الشحن الخاصة بـ PaymentIntent. |
statement_descriptor | سلسلة نصية | سلسلة أحرف عشوائية تظهر في كشف حساب بطاقة الائتمان الخاصة بعميلك. |
statement_descriptor_suffix | سلسلة نصية | توفر تفاصيل إضافية تظهر في كشف حساب بطاقة الائتمان الخاصة بعميلك. |
expand[] | مصفوفة سلاسل نصية | يحدد كائنات الاستجابة المتداخلة لإثرائها وإرجاعها بشكل مضمن. |