Skip to main content

Booking To Purchase

API Convert Booking To Purchase tutorial#

This guide shows how to convert a Booking Order into a Purchase Order continuing from the last step of our Booking flow guide.

Let's get started with the examples

Step-by-step examples#

This guide shows how to implement a complete booking flow step by step.

Prerequisites!

You will need a valid OAuth access_token to be able to make each call! Please refer to our Authentication Guide to obtain one.

  • You also need a booking order that has been confirmed, see our Booking flow guide to see how to create it.

Convert the Booking to a Purchase order#

Once the booking is committed, it will last according to the event characteristics. When you are ready to transform a booking into a purchase order, before making the payment in the next step, it is necessary call to purchaseBooking endpoint to convert the booking into a purchase, so the previously created order state changes from booking to purchase. Notice that "items" parameter indicates which items will be in the purchase.

  • order-code: the identifier of the booking you wish to convert into a purchase order
  • items: a list of the items you wish to include in the order.
curl --location -g --request POST 'http://gateway-pre.oneboxtickets.net/onebox-rest2/rest/order/purchaseBooking' \--header 'Content-Type: application/x-www-form-urlencoded' \--header 'Authorization: Bearer {{access_token}}' \--data-urlencode 'orderCode={{order-code}}' \--data-urlencode 'items=33730'--data-urlencode 'items=33731'--data-urlencode 'items=x'

Confirm the Created Order#

After you have the certainty that your customer has fulfilled the payment, you can finally close the order. The key elements are the order code and a list of payments (please notice that the list of payments are enclosed in an XML structure).

  • order-code: the identifier of the order you wish to confirm
  • payment-type: the type of payment this amount belongs to. Could be CASH, CREDIT_CARD or others, please check our glossary for more types.
  • paid-amount: the amount of this payment. There can be several payments, but the addition of all the amounts must match the order total amount.
curl --location --request POST 'http://gateway-pre.oneboxtickets.net/onebox-rest2/rest/order/commitOrder' \--header 'Accept: application/json' \--header 'Content-Type: application/x-www-form-urlencoded' \--header 'Authorization: Bearer {{access_token}}' \--data-urlencode 'orderCode={{order-code}}' \--data-urlencode 'payments=<payments xmlns="http://www.oneboxtm.es/ns/input-data/purchase/order"><payment xmlns="http://www.oneboxtm.es/ns/input-data/purchase/order" type="{{payment-type}}" value="{{paid-amount}}"/></payments>'

If you don't consume all the items in the booking you can create multiple purchase orders from one booking, as long as the items that you select for each order are not bought in a previous one.