=== Maytes for WooCommerce ===
Contributors: maytes
Tags: woocommerce, payments, split payments, group payments, checkout
Requires at least: 6.5
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Let customers split the cost of an order with their mates. Adds the Split with Maytes button to your WooCommerce checkout.

== Description ==

**Split with Maytes** lets a customer pay their share of an order and invite their mates to pay theirs. The order is paid once everyone has paid, and you receive the full amount through Maytes.

The plugin adds three things to your store:

* **The Split with Maytes button**, in a full-width row of its own under the express checkout buttons (Apple Pay, Google Pay, Link), at the same size. It works on the classic checkout and on the Checkout block.
* **A checkout route** on your site that turns the cart into a pending WooCommerce order and a Maytes checkout.
* **A webhook route** on your site that captures the payment and marks the order paid, so your usual order emails go out.

Your theme, your Stripe setup and your card checkout stay exactly as they are.

= What you need =

* A Maytes merchant account, with sandbox and production credentials from the Maytes merchant portal.
* WooCommerce, with AUD as the store currency.
* A public HTTPS site, so Maytes can deliver webhooks.

The full setup guide is at [developers.maytes.co/woocommerce](https://developers.maytes.co/woocommerce).

== Installation ==

1. Install and activate the plugin.
2. Add your Maytes settings to `wp-config.php`, above the line `/* That's all, stop editing! */`. Start with sandbox values:

    define( 'MAYTES_ENV', 'sandbox' ); // 'production' when live
    define( 'MAYTES_API_ENDPOINT', 'https://sandbox-api.maytes.co' ); // live: https://api.maytes.co
    define( 'MAYTES_CLIENT_ID', '…' );
    define( 'MAYTES_CLIENT_SECRET', '…' );
    define( 'MAYTES_WEBHOOK_SECRET', '…' );

3. In the Maytes merchant portal, subscribe `https://your-store.example/wp-json/maytes/v1/webhook` to the `checkout.authorized` and `checkout.voided` events. Copy the signing secret it shows into `MAYTES_WEBHOOK_SECRET`.
4. Pay with a sandbox test card, then switch every setting to production.

The settings stay on your server: the plugin never stores them in the database or sends them to the browser.

== Frequently Asked Questions ==

= Do I need a Maytes account? =

Yes. The plugin connects your store to Maytes, which runs the split payment. Your credentials are in the Maytes merchant portal.

= Does it work with the Checkout block? =

Yes. On the Checkout block, Split with Maytes is an express payment method in a full-width row under the other express buttons. On the classic checkout, it sits directly under the WooCommerce Stripe Gateway's express buttons.

= Does it change my Stripe setup? =

No. Maytes payments stay outside Stripe. They don't appear in your Stripe dashboard, and the money arrives through Maytes settlements.

= Why does the button ask for my customer's details first? =

Maytes doesn't return the customer's name, email or address, and your order emails need them. If a required field is empty, the customer sees the checkout's usual error and fills it in first.

= Where are refunds made? =

In the Maytes merchant portal, not from the WooCommerce order screen.

= Which currencies are supported? =

AUD. The button stays hidden for other currencies.

= Can I stop a payment before the money is taken? =

Yes. Return `false` from the `maytes_woo_can_fulfil` filter, for example when a booking has just filled up. The customer's funds are released, nothing is captured, and the order is marked Failed.

== External services ==

This plugin connects your store to Maytes, the service that runs Split with Maytes. It's needed to take Split with Maytes payments.

* **Maytes checkout button script**, loaded from `https://js.maytes.co` on checkout pages where the button shows. It draws the button and opens the Maytes checkout. As with any script, the customer's browser sends standard request information, such as its IP address and user agent.
* **Maytes API** (`https://api.maytes.co`, or `https://sandbox-api.maytes.co` while testing), called from your server only:
    * when a customer clicks Split with Maytes, to create the checkout. It sends the order ID, the total, the currency, the name, quantity and price of each line, and the return and cancel URLs on your store;
    * when Maytes reports a payment, to capture or release it. It sends the checkout ID, the order ID, the total and the currency.
    Your OAuth client ID and secret are sent to `/oauth/token` to get an access token. The customer's name, email address and postal address are never sent.
* **Maytes checkout**, the page the button opens, where the customer and their mates pay. The customer's payment details are entered there, with Maytes.

Maytes [terms and conditions](https://maytes.co/terms/) and [privacy policy](https://maytes.co/privacy/).

== Changelog ==

= 1.0.0 =
* First release: Split with Maytes on the classic checkout and the Checkout block, with capture on the webhook.

== Upgrade Notice ==

= 1.0.0 =
First release.
