Integrating with an existing EC site
Manage the order and the payment as separate states. Save on the server the mapping between the order ID, the orderId you sent at creation, and the returned paymentIntentId.
Reflecting the result in the order
| Payment check result | How the EC side handles it |
|---|---|
| The 6 in-progress statuses | Hold as awaiting payment / processing |
settled | Mark as paid and schedule the goods delivery process exactly once |
canceled / expired / failed | If not yet delivered, run the business process for cancellation and releasing stock |
nonce_conflict | Put on hold, and ask the contact to investigate with the payment ID |
To avoid shipping twice when a Webhook and polling race, make the order update a conditional update and record the goods delivery job in the same database transaction.
Order and stock deadlines
Your stock hold deadline is separate from the STBLpay payment deadline. Do not decide "it will no longer succeed" after a fixed short time. Judge by whether a status lookup or a Webhook shows a terminal status such as expired (see Operation deadline and deposit deadline).
Even after you close your own order, the STBLpay payment may still succeed if it has not reached a terminal state. If you detect a deposit for an order you cannot fulfill, escalate to an operator. To issue a refund, use the Transaction details (取引の詳細) screen in the merchant console (Scope of refunds).
Double clicks and retries
Disable the button in the browser, and have the server use the same orderId when resending the request. Creating a payment with the same orderId does not create a new payment; it returns the existing one.
Re-creating a payment with different conditions
You may need to create a new payment with a new orderId, for example to change the amount. While the existing payment is not terminal, the buyer can still pay it. If you create a new payment in the meantime, the buyer could pay both and end up paying twice. The merchant cannot cancel the existing payment. So before re-creating, check in the following order.
- Check the
statusof the existing payment with a status lookup. - If it is
settled, the payment is done. Do not re-create; proceed with the order using that payment. - If it is
canceled,expired, orfailed, it will definitely not succeed. You can re-create it with a neworderId. - If it is
nonce_conflict, do not re-create; ask the contact to investigate (see The transfer result cannot be determined). - If it is
created,signed, orissue_pending, do not create a new payment. Wait until it reaches a terminal status in the following ways, then go back to step 1. Keep checking the status while you wait, and if it changes (for example, fromcreatedtosigned), start again from step 1.- Wait for the deadline:
createdandsignedbefore the reservation starts expire atcheckoutExpiresAt, andissue_pendingexpires after the deposit deadline plus the confirmation-wait grace period. The status becomesexpiredandpayment.expiredarrives (see Operation deadline and deposit deadline). - Ask the buyer to cancel (
signedandissue_pendingonly): If you cannot wait, ask the buyer to cancel it on STBLpay's My Page (マイページ). Onlysigned, andissue_pendingbefore the deposit is confirmed, can be canceled. Canceling makes the statuscanceled, andpayment.canceledarrives. Once the deposit is confirmed, it cannot be canceled (see Cancellation).
- Wait for the deadline:
- If it is
deposit_confirmed,deploying, orexecuting, it can neither be canceled nor expire. Do not create a new payment. Keep checking the status until it reaches a terminal status, then go back to step 1. If it is a status you do not recognize, do not re-create either; keep checking the status in the same way.
On the return page, authorize the order from your own session. Do not return order details just because the requester knows the payment ID.