Create Customer that should receive the GiftCertificate using the CRM api
It is important that the ID in the URL is a new and UNIQUE ID as this is used to both create and update the customer.
Only the Name and Email is required.
curl --location --request PUT 'https://crm.flexybox.com/api/v2/customers/[CUSTOMERID]' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer XXXXXXXXXXXX' \
--data-raw '{
"FullName": "FirstName LastName",
"BirthDate": null,
"Gender": null,
"DepartmentId": null,
"EmailAddress": "[email protected]",
"PhoneNumber": null,
"StreetAddress": null,
"PostalDistrict": null,
"PostalCode": null,
"CountryCode": "DK"
}'
Create SalesOrder
Get all GiftCertificate types, as you need to select the type to create
curl --location --request GET 'https://pos.flexybox.com/api/v1/odata/giftcertificatetypes' \
--header 'Authorization: Bearer XXXXXXXXXXXX'
Create a sales order.
Set the Id of the sales order to a Unique Guid.
Set the GiftCertificateTypeId to a correct GiftCertificateTypeId from the previous api call.
CustomerId from the creation of the Customer - this customer will recieve the Receipt with the GiftCertificates attached.
DepartmentId of the Department where you wish to create the GiftCertificate - all departments can be listed using - GET https://api.flexybox.com/api/v2/departments
curl --location --request PUT 'https://pos.flexybox.com/api/v1/salesorders' \
--header 'Authorization: Bearer XXXXXXXXXXXX' \
--header 'Content-Type: application/json' \
--data-raw '{
"GiftDetails": null,
"Id": "[SALESORDERID]",
"GiftCertificates": {
"GiftCertificates": [
{
"GiftCertificateTypeId": "[GIFTCERTIFICATETYPEID]",
"Quantity": 1,
"Price": 100,
"Checksum": null
}
]
},
"CustomerId": "[CUSTOMERID]",
"DepartmentId": "[DEPARTMENTID]",
"AcceptUri": null,
"CancelUri": null,
"RequireSubscription": false,
"Currency": "DKK",
"DebitMethod": "OnlinePayment"
}'
Commit sales order
It is important that the Id of the External payment is unique for each order as dublicate posts with the same Id will be ignored.
curl --location --request POST 'https://pos.flexybox.com/api/v1/salesorders/[SALESORDERID]/commit' \
--header 'Authorization: Bearer XXXXXXXXXXXX' \
--header 'Content-Type: application/json' \
--data-raw '{
"Payments": [
{
"AccountFlowId": null,
"OnlinePaymentKey": null,
"ExternalPayment": {
"Id": "[UNIQUE PAYMENT ID]",
"Type": "Mastercard",
"Amount": 100
}
}
]
}'