Skip to content

Maytes Checkout Button ​

One button on your existing checkout. Your customer pays their share of the order on Maytes, and invites their mates to pay theirs.

Building with an AI agent? Give it these docs and our agent skill

Try it ​

How it works ​

  1. Customer clicks Split with MaytesYour page
  2. Your server creates the checkoutYour server
  3. Customer pays their shareMaytes
  4. Your webhook captures the paymentYour server

Choose how Maytes appears ​

The Split with Maytes button can stand on its own or sit inside your Stripe checkout. Every placement creates the checkout on your server the same way.

PlacementUse it whenGuide
On its ownMaytes is a pay button of its own on your pageAdd the button, below
In Stripe's express rowYour checkout shows Apple Pay, Google Pay and Link, and Maytes goes in a full-width row under themMaytes in your Stripe express row
In Stripe's Payment ElementMaytes is a payment method in your Stripe form, with the Maytes button in place of your Pay buttonMaytes in your Stripe Payment Element

Add the button ​

1. Import the button library ​

html
<script
  src="https://js.maytes.co/v1/checkout-button.js"
  crossorigin="anonymous"
></script>
ts
// npm install @maytes/checkout-button
import { Maytes } from '@maytes/checkout-button';

2. Add the button to your page ​

Configure and render the button. Pick your stack:

html
<div id="maytes-button"></div>

<script>
  const maytes = window.Maytes({
    environment: 'sandbox',
    createCheckout: () => createMaytesCheckout('cart_8fd21'),
  });
  // Gets <div id="maytes-button"></div> from your HTML.
  const slot = document.getElementById('maytes-button');
  maytes.renderButton(slot, { block: true });
</script>
ts
const maytes = Maytes({
  environment: 'sandbox',
  createCheckout: () => createMaytesCheckout('cart_8fd21'),
});

// Gets <div id="maytes-button"></div> from your HTML.
const slot = document.getElementById('maytes-button')!;
maytes.renderButton(slot, { block: true });
// When the page goes away: maytes.destroy();
tsx
// npm install @maytes/checkout-button
import {
  MaytesProvider,
  MaytesButton,
} from '@maytes/checkout-button/react';

export function SplitWithMaytes({ cartId }: { cartId: string }) {
  return (
    <MaytesProvider
      environment="sandbox"
      createCheckout={() => createMaytesCheckout(cartId)}
    >
      <MaytesButton block />
    </MaytesProvider>
  );
}
tsx
'use client'; // createCheckout is a function, so this runs in the browser
import {
  MaytesProvider,
  MaytesButton,
} from '@maytes/checkout-button/react';

export function SplitWithMaytes({ cartId }: { cartId: string }) {
  return (
    <MaytesProvider
      environment="sandbox"
      createCheckout={() => createMaytesCheckout(cartId)}
    >
      <MaytesButton block />
    </MaytesProvider>
  );
}
vue
<script setup lang="ts">
import { onBeforeUnmount, onMounted, ref } from 'vue';
import { Maytes, type MaytesSDK } from '@maytes/checkout-button';

const props = defineProps<{ cartId: string }>();
const slot = ref<HTMLDivElement>();
let maytes: MaytesSDK | undefined;

onMounted(() => {
  maytes = Maytes({
    environment: 'sandbox',
    createCheckout: () => createMaytesCheckout(props.cartId),
  });
  maytes.renderButton(slot.value!, { block: true });
});
onBeforeUnmount(() => maytes?.destroy());
</script>

<template><div ref="slot" /></template>
ts
import {
  AfterViewInit,
  Component,
  ElementRef,
  Input,
  OnDestroy,
  ViewChild,
} from '@angular/core';
import { Maytes, type MaytesSDK } from '@maytes/checkout-button';

@Component({
  selector: 'split-with-maytes',
  standalone: true,
  template: '<div #slot></div>',
})
export class SplitWithMaytesComponent
  implements AfterViewInit, OnDestroy
{
  @Input() cartId = '';
  @ViewChild('slot') slot!: ElementRef<HTMLDivElement>;
  private maytes?: MaytesSDK;

  ngAfterViewInit() {
    this.maytes = Maytes({
      environment: 'sandbox',
      createCheckout: () => createMaytesCheckout(this.cartId),
    });
    this.maytes.renderButton(this.slot.nativeElement, { block: true });
  }

  ngOnDestroy() {
    this.maytes?.destroy();
  }
}
svelte
<script lang="ts">
  import { onMount } from 'svelte';
  import { Maytes } from '@maytes/checkout-button';

  let { cartId }: { cartId: string } = $props();
  let slot: HTMLDivElement;

  // onMount runs only in the browser, so SvelteKit's SSR is safe.
  onMount(() => {
    const maytes = Maytes({
      environment: 'sandbox',
      createCheckout: () => createMaytesCheckout(cartId),
    });
    maytes.renderButton(slot, { block: true });
    return () => maytes.destroy();
  });
</script>

<div bind:this={slot}></div>

3. Connect the button to your backend ​

The createCheckout option above tells the button what to run when a customer clicks it. Define that callback on your page. It calls your server and must return { checkoutId, checkoutUrl }:

js
async function createMaytesCheckout(cartId) {
  // Your own backend: authenticate the customer and verify access to this cart.
  const res = await fetch('/api/maytes/create-checkout', {
    method: 'POST',
    headers: { 'content-type': 'application/json' },
    body: JSON.stringify({ cartId }),
  });
  if (!res.ok) throw new Error('Could not create the Maytes checkout');
  const { checkout_uuid, checkout_url } = await res.json();
  return { checkoutId: checkout_uuid, checkoutUrl: checkout_url };
}

/api/maytes/create-checkout is a route on your server; name it anything. Your route calls Maytes with credentials that must never reach the browser. Follow Create a checkout to implement it.

Button options ​

renderButton(slot, options) and <MaytesButton> take these options. All are optional.

OptionDefaultWhat it does
blockfalseStretches the button to the full width of its container.
mode'popup''popup' opens Maytes in a window over your page; 'redirect' opens it in the same tab. Phones always use the same tab.
label'Split with'The text before the Maytes logo.
radiuspillCorner radius in pixels, 0 up to half the height.
heightnatural heightHeight in pixels, 40 to 55. Keeps the label on one line. Use { radius: 6, height: 48 } to match Apple Pay and Google Pay.
redirectOverlayfalseShows the Maytes loading screen while a same-tab checkout is created.

In React, pass them as props: <MaytesButton block mode="redirect" />. Events, openCheckout() and CSS custom properties are in the API reference.

The React components (@maytes/checkout-button/react) need version 1.2 or later. They work with React 18 and 19, StrictMode and server rendering, and from your own Pay button through useMaytes(): see the React guide.

Full setup guides for every stack, plus the button's options and events, are in the SDK README.

Capture on the webhook ​

Your page never learns the payment result. When Maytes sends checkout.authorized, capture within 2 minutes, then show the order on your return_url page.

Go live ​

environmentOpensUse with
sandboxThe sandbox checkoutSandbox API credentials
productionThe live checkoutProduction credentials
  1. Set the button to environment: 'production'.
  2. Point your server at your production credentials.
  3. Subscribe your production webhook, and capture on it.

The button's environment must match your server's. Return the checkout_url Maytes gives you; never build one.

Other ways to send customers to Maytes ​

Instead of the buttonUse when
Redirect to checkout_urlYou don't want JavaScript on the page

Something wrong with the button? Open an issue on the SDK repository, or email support@maytes.co.