Performs a checkout on reserved tickets.
The checkout()
function returns a Promise that resolves to a
CheckoutResponse
when the ticket reservation
has been checked out.
To checkout tickets, you must first call the reserve()
function
to reserve the tickets.
Use the returned order
to process payment for the tickets by passing the order
's
paymentId
to the startPayment()
function. Note that
since the order
has a paymentId
, you do not need to first call createPayment()
to create a payment.
Before using the startPayment() function, you will need to set up your site to accept payments. To learn more, see About Accepting Payments. When setting up your site to accept payments, be sure to select the payment methods you want to offer and set your payment currency.
Notes:
function checkout(
eventId: string,
reservationId: string,
checkoutInfo: CheckoutInfo,
): Promise<CheckoutResponse>;
ID of the event that the ticket reservations are for.
ID of the ticket reservations.
Information related to the checkout.
import wixEventsFrontend from 'wix-events-frontend';
import wixPayFrontend from 'wix-pay-frontend';
// ...
const eventId = // Get the event ID
// ...
let reservationId = // Returned from the reserve() function
// ...
let formValues = // get form values
let coupon = // get coupon
wixEventsFrontend.tickets.checkout(eventId, reservationId, {formValues, coupon})
.then((response) => {
let order = response.order;
wixPayFrontend.startPayment(order.paymentId);
let expirationTime = response.expirationTime;
let firstReservation = response.reservations[0];
});
/* response:
*
* {
* "order": {
* "orderNumber": "FMQR-VSN7-E1",
* "reservationId": "7f6a522f-f34c-4a03-8d9a-05e88506c012",
* "eventId": "9a513b88-a223-4144-b0dc-938fd7cc5b4a",
* "contactId": "",
* "memberId": "",
* "firstName": "John",
* "lastName": "Doe",
* "email": "john@doe.com",
* "checkoutForm": {
* "inputValues": [
* {
* "inputName": "firstName",
* "value": "John",
* "values": [],
* },
*
* ...
*
* {
* inputName: "custom",
* value: "",
* values: ["Gluten free", "Vegetarian"],
* }
* ]
* },
* "confirmed": false,
* "status": "INITIATED",
* "ticketsPdf": "https://apps.wix.com/events/doc/tickets/v2/Tickets.pdf?request=JWS...",
* "tickets": [],
* "archived": false,
* "anonymized": false,
* "fullName": "John Doe",
* "invoice": {
* "items": [
* {
* "id": "de8e3fd8-b257-40a7-933b-77c627d884e4",
* "quantity": 2,
* "name": "VIP ticket",
* "price": {
* "amount": "6.00",
* "currency": "USD"
* },
* "total": {
* "amount": "12.00",
* "currency": "USD"
* },
* "discount":{
* "amount":{
* "amount":"2.0",
* "currency":"USD"
* },
* "afterDiscount":{
* "amount":"10.00",
* "currency":"USD"
* },
* "code":"CouponCode",
* "name":"Coupon Name",
* "couponId":"3b2e333c-5376-4b36-8543-00bae6dd8f59",
* "discounts":[
* {
* "amount":{
* "amount":"2.0",
* "currency":"USD"
* },
* "coupon":{
* "name":"Coupon Name",
* "code":"CouponCode",
* "couponId":"3b2e333c-5376-4b36-8543-00bae6dd8f59"
* }
* }
* ]
* },
* "fees": [
* {
* "name": "WIX_FEE",
* "type": "FEE_ADDED",
* "rate": "2.5",
* "amount": {
* "amount": "0",
* "currency": "USD"
* }
* }
* ]
* },
* {
* "id": "9207637c-3d49-43af-b91e-32e496620c60",
* "quantity": 1,
* "name": "Regular ticket",
* "price": {
* "amount": "3.50",
* "currency": "USD"
* },
* "total": {
* "amount": "3.50",
* "currency": "USD"
* },
* "discount":{
* "amount":{
* "amount":"1.0",
* "currency":"USD"
* },
* "afterDiscount":{
* "amount":"2.50",
* "currency":"USD"
* },
* "code":"CouponCode",
* "name":"Coupon Name",
* "couponId":"3b2e333c-5376-4b36-8543-00bae6dd8f59",
* "discounts":[
* {
* "amount":{
* "amount":"1.0",
* "currency":"USD"
* },
* "coupon":{
* "name":"Coupon Name",
* "code":"CouponCode",
* "couponId":"3b2e333c-5376-4b36-8543-00bae6dd8f59"
* }
* }
* ]
* },
* "fees": [
* {
* "name": "WIX_FEE",
* "type": "FEE_ADDED",
* "rate": "2.5",
* "amount": {
* "amount": "0",
* "currency": "USD"
* }
* }
* ]
* }
* ],
* "total":{
* "amount":"15.50",
* "currency":"BIF"
* },
* "discount":{
* "amount":{
* "amount":"3.0",
* "currency":"BIF"
* },
* "afterDiscount":{
* "amount":"12.50",
* "currency":"BIF"
* },
* "code":"CouponCode",
* "name":"Coupon Name",
* "couponId":"3b2e333c-5376-4b36-8543-00bae6dd8f59",
* "discounts":[
* {
* "amount":{
* "amount":"3.0",
* "currency":"BIF"
* },
* "coupon":{
* "name":"Coupon Name",
* "code":"CouponCode",
* "couponId":"3b2e333c-5376-4b36-8543-00bae6dd8f59"
* }
* }
* ]
* },
* "subTotal":{
* "amount":"15.50",
* "currency":"BIF"
* },
* "grandTotal":{
* "amount":"12.50",
* "currency":"BIF"
* },
* "fees":[],
* "revenue":{
* "amount":"12.50",
* "currency":"BIF"
* }
* },
* "fullyCheckedIn": false,
* "transactionId": "",
* "paymentId": "b0fb4d1c-858b-45cb-991d-2fd79bfb60d3",
* "createdDate": "2020-04-22T13:25:32.018Z",
* "paymentMethod": "",
* "ticketQuantity": 3,
* "price": {
* "amount": "15.50",
* "currency": "USD"
* }
* },
* "reservations": [
* {
* "quantity": 1,
* "ticket": {
* "id": "de8e3fd8-b257-40a7-933b-77c627d884e4",
* "price": {
* "amount": "6.00",
* "currency": "USD"
* },
* "free": false,
* "name": "VIP ticket",
* "description": "Super special ticket",
* "limitPerCheckout": 0,
* "orderIndex": 0,
* "policy": "No refunds",
* "eventId": "9a513b88-a223-4144-b0dc-938fd7cc5b4a"
* }
* },
* {
* "quantity": 2,
* "ticket": {
* "id" :"9207637c-3d49-43af-b91e-32e496620c60",
* "price": {
* "amount": "3.50",
* "currency": "USD"
* },
* "free": false,
* "name": "Regular ticket",
* "description": "Just a regular ticket",
* "limitPerCheckout": 0,
* "orderIndex": 0,
* "policy": "",
* "eventId": "9a513b88-a223-4144-b0dc-938fd7cc5b4a"
* }
* }
* ],
* "expirationTime": "2020-04-22T13:44:46.395Z"
* }
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.