Share
Explore

Twig checkout API documentation v1

Flow diagram

twig checkout.png




Order Flow

The merchant site calls
/order/init
to initiate the
Twig
checkout process.
twig 1.png
2. Then the merchant’s site redirects the user to
Twig
checkout page referring to the URL in response from
/order/init
twigstep3.png
3. The user will confirm (validating their assets) the order and authorize the payment then it will be redirected to merchant’s confirmation URL (or cancel URL, depends on the confirmation success).
confirmauthorize.png
4. The merchant creates the order by capturing it via
POST /payments/capture
and finalizes it.
capture.png
5.
Twig
proceeds with order processing and returns with a success or failure.




API

POST
/order/init


Merchant makes a POST request to /order/init to initiate the
Twig
checkout process and in return receives the order data and checkoutUrl.

Payload

Required:
merchantOrderId -
merchant’s unique id for the order
amount -
order total amount with breakdown (items, tax, shipping)
currencyCode -
currency code
value -
total
amount for the order
breakdown -
total amount breakdown by
items, tax, shipping
items -
total amount for items
tax -
total tax amount
shipping -
total shipping amount
shipping -
shipping details
method
amount -
total amount of shipping
address -
address of the user
firstName
lastName
addressLine1
addressLine2 (optional)
city
state
postalCode
countryCode
lineItems -
items purchased by the user
itemId -
merchant’s unique id for the item
name
description
category
quantity
amount
tax
merchantDateCreated -
merchant’s order creation date
merchantUrl -
URL for redirection
redirectConfirmUrl -
user confirms and authorizes the payment
redirectCancelUrl -
user cancels the order

Optional
billing -
billing address. Contains
address
object from
shipping
field above.

Returns
:

200 OK
checkoutUrl -
URL to redirect to
Twig
checkout
order -
order data
orderId
-
Twig’s
order unique id.
merchantOrderId -
Merchant’s order unique id.
amount -
described above
lineItems -
described above
shipping -
described above
billing -
described above
merchantDateCreated -
Order creation date from merchant
4XX BAD REQUEST -
payload format incorrect
5XX SERVER ERROR -
twig error

Authorization header

API-TOKEN askjdh209ausdjasdasdiasd9as

Body

{
"merchantOrderId": "order_id",
"merchantDateCreated":"2021-04-20T18:32:04.646+00:00",
"amount": {
"currencyCode": "USD",
"value": "240.00",
"breakdown": {
"items": "180.00",
"shipping":"30.00",
"tax": "20.00"
}
},
"lineItems": [
{
"itemId":"123",
"name": "T-Shirt",
"description": "Green XL",
"amount": "90.0",
"tax": "10.00",
"quantity": "1",
"category": "PHYSICAL_GOODS"
},
{
"itemId":"321",
"name": "Shoes",
"description": "Running, Size 10.5",
"amount":"45.00",
"tax": "5.00",
"quantity": "2",
"category": "PHYSICAL_GOODS"
}
],
"shipping": {
"method": "United States Postal Service",
"amount":"20",
"address": {
"firstName": "John",
"lastName": "Doe",
"addressLine1": "123 Townsend St",
"addressLine2": "Floor 6",
"city": "San Francisco",
"state": "CA",
"postalCode": "94107",
"countryCode": "US"
}
},
"billing":{
"address":{
"firstName": "John",
"lastName": "Doe",
"addressLine1": "123 Townsend St",
"addressLine2": "Floor 6",
"city": "San Francisco",
"state": "CA",
"postalCode": "94107",
"countryCode": "US"
}
}
}

POST
/payments/capture


Merchant makes a POST request to
/payments/capture
to notify
Twig
that it can proceed with the payment and finalize the order.

Payload

Required:
orderId
-
Twig’s
order unique id.
merchantOrderId -
Merchant’s order unique id.

Returns
:

200 OK
paymentStatus
4XX BAD REQUEST -
payload format incorrect
5XX SERVER ERROR -
twig error

Authorization header

API-TOKEN askjdh209ausdjasdasdiasd9as

Body

{
"orderId" : "2132kasdad-23askdasd"
"merchantOrderId": "awe-13kdakdk2-adsad",
}

GET
/payments/{orderId}


Retrieves an order payment status.

Payload

Required:
orderId
-
Twig’s
order unique id.

Returns
:

200 OK
paymentStatus
4XX BAD REQUEST -
payload format incorrect
5XX SERVER ERROR -
twig error

Authorization header

API-TOKEN askjdh209ausdjasdasdiasd9as


Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.