Method "makeOrder"
Method for placing an order to generate and deliver an e-gift card. Order will be processed asynchronously.
Usually an e-gift card is issued within 5 second, but sometimes delays are possible. callback_url can be used for status tracking (send callback url to dev@giftery.es for setup). Upon processing the requests for e-gift card the POST request will be send to the specified URL.
| Parameters | |
|---|---|
| product_id | Required. Product ID (see method getProducts). |
| face | Required. Denomination of the e-gift card (see method getProducts, parameter faces). |
| uuid | This is a unique ID for prevent order duplicates (valid UUID string or any string (up to 36 chars).) If follow requests params (with same uuid) not equal params from first request 1207 error will be returned. |
| email_to | Recipient email. Omit if email delivery via Giftery platform not needed (see delivery_type below). String, no more than 255 characters. |
| from | Sender name (is used in client notification templates). String, no more than 255 characters. |
| to | Recipient name (is used in client notification templates). String, no more than 255 characters. |
| to_phone | мobile number for sms-delivery or just sms-notify if email_to was passed. |
| date_send | Delayed delivery date in ISO8601 YYYY-MM-DDThh:mm:ss±hh:mm format. B2B clients registered before February 1, 2023 are allowed to use additional format YYYY-MM-DD hh:mm:ss for sake of backward compatibility (in this case, time zone is implicitly set to UTC+3). The date must be in the future from the moment of making request. Old format will be removed someday. |
| text | Greeting text (is used in client notification templates). String, no more than 512 characters. |
| code | Service order code. Orders are grouped by this code in statistics dashboard in the Giftery partner cabinet. Default order code: "API". Only uppercase English letters and digits are allowed (must match regular expression ^[A-Z0-9_]+$). String, no more than 100 characters. |
| comment | Service comment. Can be used by the partner for any purposes. Displayed in the statistics dashboard in the Giftery partner cabinet. String, no more than 512 characters. |
| external_id | This field may contain your own order ID or any other information which looks like ID for you. String, no more than 255 characters. |
| delivery_type | email by default.Use link if you need to obtain certificate links via getLinks. |
| ttl | Most orders are processed within a few seconds, but in rare cases, this time can go up to several hours. This option allows you to limit the processing time of an order. Order will be automatically canceled if not processed in time. You can pass ttl (in seconds) as number between 60 (one minute) and 86400 one day. |
| locale | Value "en_US" for using English email templates. |
| Response | |
|---|---|
| id | ID of the request |
Example 1
cmd: makeOrder, data:
{
"product_id": 343,
"face": 1750,
"email_to": "ivan@giftery.es",
"from": "Giftery"
}Response:
{
"status": "ok",
"data": {
"id": 34516344
}
}Example 2
cmd: makeOrder, data:
{
"product_id": 343,
"face": 2000,
"email_to": "ivan@giftery.es",
"from": "Giftery",
"to": "Ivan",
"text": "Congratulations, you won",
"code": "KONKURS",
"comment": "winner №345"
}Response:
{
"status": "ok",
"data": {
"id": 34516345
}
}Test mode
Bear in mind, you can send no more than 15 emails a day (timezone UTC+03:00) in order to avoid spamming. When you reach this limit, you will still be able to call makeOrder but without sending emails.
Callback
If a notification URL for created orders has been configured for you, data will be sent to it using the POST method. In response, we expect an HTTP status code 200 and a message body containing OK (in Latin characters, uppercase, with no additional characters). If both of these conditions are met, we consider the callback to be successfully accepted by the remote system.If these two conditions are not met, the callback will be retried at intervals of 1, 2, 5, 15, 30, 60, and 120 minutes. If the conditions remain unmet by the final attempt, the retries will cease, and the callback will be marked as failed by the remote system.
Example 3
{
"status": "ok",
"data": {
"id": 34516345,
"order_id": 156765,
"uuid": "f64b3cc2-aac5-11e8-98d0-529269fb1459",
"product_id": 343,
"face": 2000,
"sum": 2000,
"code": "KONKURS",
"comment": "winner №345",
"gift_page_url": "https://my.giftery.app/gift/new/1156765qA1iO9vV2n"
}
}Field gift_page_url is returned after successful order processing (status = ok) and contains the URL of the gift page for receiving the certificate.
Example 4
{
"status": "error",
"error": {
"code": 5000,
"text": "Insufficient funds."
}
}