...
Create Order as Pending
Auto-generate order ID (6 alphanumeric, e.g. ABC123)
Create Invoice via API
currency
= USDmerchantName
= “FIO Dashboard”price
= Total price of orderorderId
= Order IDnotificationURL
= webhook notification urlredirectURL
= link to Order details where user will be redirected after paymentbuyer
email
= Email address of user
token
= API token provided by Bitpay
Capture response
id
Trigger Modal Invoice
Await Webhook notification.
Payload spec: https://bitpay.com/docs/invoice-webhooks
When received fetch invoice via API to ensure not spoofed
Action based on status
new/completeconfirm
No action
paid
Set order status to Pending
User should stay on Invoice Modal
expired
Update Order as Cancelled and display https://fioprotocol.atlassian.net/wiki/spaces/DAO/pages/500793345/Shopping+and+Checkout#Canceled
invalid
Set order status to Pending
Display https://fioprotocol.atlassian.net/wiki/spaces/DAO/pages/500793345/Shopping+and+Checkout#Pending
confirmedcomplete
Create Payment for amount received
Create Payment for amount of order
Execute on-chain action
On success
Update Order as Success
On complete Purchase Error
Create Payment for amount of order back to User
Create Payment for amount of order Spent On FIO
Send FIO to User’s account
On Error Create Payment for amount of order back to User
Update Order as Purchase Error
On Partial Success
Create Payment for amount of failed items back to User
Create Payment for amount of failed items Spent On FIO
Send FIO to User’s account
On Error Create Payment for amount of failed items back to User
Handling price changes
Preserve FIO pricing and USDC pricing for cart
When payment is received compare total price of cart when saved to what it is at the time when payment notification is received
If price deviation is +/- 25% from saved price do not alter pricing and execute transaction
If price deviation is more than +/- 25% reprice send FIO to User’s account at new rate of exchange
...