детальный разбор логики работы API и структуры ответов
🔑 Key Identifiers (Ключевые идентификаторы)
Для отслеживания транзакций используются три типа ID:
- globalId: АAPI task identifier (Идентификатор задачи в системе).
- paysendId: Payment identifier generated by Paysend (Внутренний ID платежа Paysend).
- invoiceId: Payment identifier provided by Client (Ваш уникальный номер заказа).
🔄 Scenario 1: Pay To Card Regular Flow
Этот сценарий описывает стандартный процесс обработки платежа.
Step 1: Payment initiation
- Action: Client sends
POST /processing/pay.toCard(payment instruction). - Response:
Acceptedcontaining aglobalId.
Step 2: Polling via globalId (task)
- Frequency: Every 5 seconds until the task is finished.
- Method:
GET /processing/status/{globalId}. - Logic (alt):
- If
task.status == Accepted: Continue polling until another status is received. - If
task.status == Success(code 0) ORError(code NOT in 5, 999, 9999): Stop polling as the Final outcome is reached. Set status toCompletedorDeclinedin your system. - If
task.status == Error(code in 5, 999, 9999): The task is finished, but the payment status is not final yet (OnHold / ManualResolve).
- If
Step 3: Polling via paysendId (payment)
Если на предыдущем этапе получен код 5, 999 или 9999, необходимо сменить метод отслеживания.
- Wait: 5 minutes before switching.
- Method:
POST /processing/task.statusGetusingpaysendId. - Frequency: Low frequency (2-3 times per day).
- Terminal Statuses:
Completed,Declined, orRefundedindicate the final outcome.
⚠️ Scenario 2: Pay To Card Failure Flow
Используется, если на запрос инициации платежа не был получен ответ.
- Wait: 5 minutes to allow the transaction to reach the database.
- Polling via invoiceId: Call
POST /processing/task.statusGetusing yourinvoiceId. - Analysis:
- If
Error Code 3006 (Transaction not found): The transaction was not created. You can safely repeat the payment with the sameinvoiceId. - If
status in (OnHold, InProgress): Continue polling (every 1 hour or 2-3 times per day) until the final status is reached. - If
status in (Completed, Declined): Final Payment Status reached.
- If
📊 Response Examples Analysis (Разбор JSON-ответов)
| Response Type | Task Result Status | Task Result Code | Payload Task Result Status | Payload Task Result Code | Comment / Action [cite] |
| Successful | Finished | 2 | Success | 0 | Payment Completed. |
| RFI (OnHold) | Finished | 2 | Error | 5 | "Offline Antifraud check: RFI". Transaction put OnHold. |
| Error | Finished | 2 | Error | 1000 (or other) | "Processing error occurred". Transaction Declined Immediately. |
| Ambiguous | Finished | 2 | Error | 999 or 9999 | "Timeout". Status unknown. Must use task.statusGet. |
Important Data Fields in JSON:
arn/rrn: Retrieval Reference Numbers (только при успехе).rate: Exchange rate applied to the transaction.statusUri: Link to check task status.duplicate protection: If aninvoiceIdis reused for a successful payment, the new one will be placedOnHold.
