Creating an Order via API

To create an order using SpectroCoin's API, you must first ensure that your API keys are properly configured. This is a prerequisite for making any requests and can be set up by following this guide on generating API keys. Additionally, a valid access token is required for authorization, to get one refer to this guide on getting an access token.

The POST /public/merchants/orders/create is a main endpoint which is used for order creation. To get less confused, when user runs this request, firstly a pre-order is being created, which URL is being specified in response redirectUrl. Once user is being redirected and choose the currency and network he will pay, then the order is being created.

An important distinction to note is that orders are designed for a single payer and a single transaction. The payment amount is static and cannot be altered once set. This differs from pre-orders and public payment links, which may allow for greater flexibility in terms of payer and amount.

Example order creation request

{
    "orderId": "sc-0364",
    "description": "example order sc-0364",
    "receiveAmount": 10,
    "receiveCurrencyCode": "USD",
    "projectId": "f58a9032-94c8-1b36-ta32-3d6c2ad81255",
    "callbackUrl": "https://example-web-page.com/callback",
    "successUrl": "https://example-web-page.com/success",
    "failureUrl": "https://example-web-page.com/failure"
}
  • orderId is the unique identifier for the transaction. If not specified, it will be automatically generated, but it is recommended to come up with a way of generating ids that can be tracked.
  • description provides details about the order. It will be displayed during the payment.
  • receiveAmount and receiveCurrencyCode define how much and in which currency the merchant will receive a payment. When integrating, the merchant has the option to specify either the receiveAmount and receiveCurrencyCode, or the payAmount and payCurrencyCode.
  • projectId links the order to a specific project in your SpectroCoin account. It can be retrieved from merchant project dashboard.
  • callbackUrl is a valid URL to which the callback is sent when a associated new order is created or the status of the order changes.
  • successUrl and failureUrl specify the URLs to which the user will be redirected based on the order outcome.

For a complete list of parameters, error codes, and code examples in different programming languages, as well as the ability to test the endpoint, please refer to the API reference page.

Example response

{
    "preOrderId": "88f76273-a10f-451f-818d-8dd16260dd6c",
    "orderId": "sc-0364",
    "validUntil": null,
    "payCurrencyCode": null,
    "payNetworkCode": null,
    "receiveCurrencyCode": "USD",
    "payAmount": null,
    "receiveAmount": "10",
    "depositAddress": null,
    "memo": null,
    "redirectUrl": "https://spectrocoin.com/en/payment/preorder/8af73173-100f-4d1f-5482-8dd36260dd6c"
} 

Upon successful order creation, the user should be redirected to the redirectUrl to complete the payment process. This URL will guide the user through the payment on SpectroCoin’s platform. The payment process is secure, and no further changes can be made to the payment details once the redirection has occurred.

Callbacks for order status

SpectroCoin provides callback notifications when the order status changes (when the order is paid, expired or failed). The callbackUrl specified in the order creation request will receive updates when these status changes occur. You can read more about how to handle callbacks in our callback documentation here.