ResytechResytech Docs

Invoice Operations

Retrieve and pay outstanding invoices using the ResytechApi client.

Invoices represent outstanding balances on bookings -- for example, when a customer paid a deposit at checkout and owes a remaining balance. The invoice API lets you retrieve invoice details and process payments.

getInvoice

Retrieve invoice details including the amount due, associated cart summary, and booking information.

const result = await api.invoice.getInvoice('invoice-uuid');

if (result.success) {
  console.log('Invoice:', result.invoice.uuid);
  console.log('Due now:', result.invoice.dueNowCents, 'cents');
  console.log('Activity:', result.activity);
  console.log('Date:', result.date);
  console.log('Time:', result.start, '-', result.end);
}

Parameters

ParameterTypeRequiredDescription
invoiceUuidstringYesInvoice UUID

GetInvoiceResponse

FieldTypeDescription
successbooleanWhether the request succeeded
invoiceServerInvoiceInvoice details
cartServerShoppingCartOverviewCart summary with line items, fees, and totals
activitystringActivity name
datestringBooking date
startstringStart time
endstringEnd time
endDatestringEnd date (for multi-day bookings)

ServerInvoice

FieldTypeDescription
uuidstringInvoice unique identifier
dueNowCentsnumberAmount due in cents

The cart field contains the full ServerShoppingCartOverview with all line items, fees, discounts, and payment history. See the Cart & Checkout page for the full type reference.


payInvoice

Pay an outstanding invoice. Like checkout, this requires a Stripe confirmation token and any required agreement acceptances.

const result = await api.invoice.payInvoice('invoice-uuid', {
  stripeConfirmationToken: 'tok_xxx',
  agreements: ['agreement-uuid-1']
});

if (result.success) {
  console.log('Payment confirmed:', result.confirmation);
} else if (result.clientSecret) {
  // Stripe requires additional action (3D Secure, etc.)
  console.log('Additional verification needed');
}

Parameters

ParameterTypeRequiredDescription
invoiceUuidstringYesInvoice UUID
requestPayInvoiceRequestYesPayment details

PayInvoiceRequest

FieldTypeRequiredDescription
stripeConfirmationTokenstringNoStripe confirmation token from Stripe.js
agreementsstring[]NoUUIDs of accepted agreements
handledNextActionstringNoStripe PaymentIntent ID after handling 3D Secure

PayInvoiceResponse

FieldTypeDescription
successbooleanWhether payment succeeded
confirmationstringPayment confirmation number
clientSecretstringStripe client secret (if additional action is required)

Invoice Payment Flow

A typical invoice payment follows this sequence:

  1. Retrieve the invoice to display the amount due and booking details.
  2. Collect payment using Stripe Elements or your payment form.
  3. Submit payment with the Stripe token.
  4. Handle 3D Secure if the response includes a clientSecret instead of a confirmation.
getInvoice(uuid)
    |
    v
Display amount, booking details
    |
    v
Collect Stripe payment token
    |
    v
payInvoice(uuid, { stripeConfirmationToken })
    |
    +---> success + confirmation  --> Done
    |
    +---> clientSecret returned   --> Handle 3D Secure with Stripe.js
                                       |
                                       v
                                  payInvoice(uuid, { handledNextAction: paymentIntentId })
                                       |
                                       v
                                  success + confirmation --> Done

Full Example

const api = new ResytechApi();
await api.initialization.initialize({ identifier: 'invoice-payment' });

// Invoice UUID typically comes from an email link or dashboard
const invoiceUuid = 'inv-abc-123';

// 1. Load invoice details
const invoiceResult = await api.invoice.getInvoice(invoiceUuid);

if (!invoiceResult.success) {
  console.error('Invoice not found:', invoiceResult.message);
  return;
}

const { invoice, cart, activity, date, start, end } = invoiceResult;

// Display to customer
console.log(`Invoice for: ${activity}`);
console.log(`Booking: ${date} ${start} - ${end}`);
console.log(`Amount due: $${(invoice.dueNowCents / 100).toFixed(2)}`);

if (cart) {
  console.log('Line items:');
  cart.lineItems?.forEach(item => {
    console.log(`  ${item.name}: $${item.price}`);
  });
  console.log('Fees:');
  cart.fees?.forEach(fee => {
    console.log(`  ${fee.name}: $${fee.amount}`);
  });
}

// 2. Collect payment via Stripe.js (in your UI)
//    const { token } = await stripe.createToken(cardElement);

// 3. Pay the invoice
const payResult = await api.invoice.payInvoice(invoiceUuid, {
  stripeConfirmationToken: 'tok_from_stripe_js',
  agreements: [] // include any required agreement UUIDs
});

if (payResult.success) {
  console.log('Payment complete! Confirmation:', payResult.confirmation);
} else if (payResult.clientSecret) {
  // 4. Handle 3D Secure
  //    const { paymentIntent } = await stripe.handleNextAction({
  //      clientSecret: payResult.clientSecret
  //    });

  // 5. Retry with handled action
  const retryResult = await api.invoice.payInvoice(invoiceUuid, {
    handledNextAction: 'pi_payment_intent_id'
  });

  if (retryResult.success) {
    console.log('Payment verified! Confirmation:', retryResult.confirmation);
  } else {
    console.error('Payment failed:', retryResult.message);
  }
} else {
  console.error('Payment failed:', payResult.message);
}

On this page