# Create a Apple Pay sale Building with an AI agent? Start at https://docs.payme.io/agents.md - Sandbox: `POST https://sandbox.payme.io/api/generate-sale` - Production: `POST https://live.payme.io/api/generate-sale` ## Credentials - Request body field `seller_payme_id` (required): The seller's PayMe ID (MPL). Creates a sale for Apple Pay. Send the buyer to `sale_url`, where PayMe's page shows Apple Pay, or pass `payme_sale_id` as `saleGuid` to `instance.appleSale()` to show Apple Pay on your own page: see [Accept Apple Pay](/accepting-payments/payment-methods/apple-pay). The seller needs the Apple Pay service: a seller installs it from the dashboard app store (חנות אפליקציות), and a partner enables it with [vas-enable](/payments/apple-pay/post-vas-enable-apple-pay). Without it, the call fails with error `720`. Apple Pay pays in a single payment: more than one `installments` fails with error `351`. **Auth:** `seller_payme_id` in the body. Call it from your server, never from the browser. Base URL: `https://sandbox.payme.io/api` in the sandbox, `https://live.payme.io/api` in production. This page lists the fields a wallet sale needs. `generate-sale` takes more optional fields, such as `transaction_id`, `sale_callback_url` and `sale_return_url`: see [generate-sale](/payments/hosted-payment-page/post-generate-sale). ## Parameters This endpoint takes no path, query or header parameters. ## Request body Content type: `application/json` | Field | Type | Required | Description | | --- | --- | --- | --- | | `seller_payme_id` | string | yes | The seller's PayMe ID (MPL). | | `sale_price` | integer | yes | Amount in minor units: `1000` = 10.00. | | `currency` | string | yes | ISO 4217 currency code, e.g. `ILS`. | | `product_name` | string | yes | What the payment is for. | | `sale_payment_method` | string | yes | `apple-pay`. | | `sale_type` | string | no | Default `sale`. See [Sale Types](/payments/codes-statuses/sale-types). | | `language` | string | no | Language of the payment page and the error messages: `he` (default) or `en`. | ### Request example ```json { "seller_payme_id": "MPLDEMO-MPLDEMO-MPLDEMO-1234567", "sale_price": 1000, "currency": "ILS", "product_name": "Order 1234", "sale_payment_method": "apple-pay", "language": "en" } ``` ## Code samples ### curl ```bash curl -X POST 'https://sandbox.payme.io/api/generate-sale' \ -H 'Content-Type: application/json' \ --data-raw '{ "seller_payme_id": "MPLDEMO-MPLDEMO-MPLDEMO-1234567", "sale_price": 1000, "currency": "ILS", "product_name": "Order 1234", "sale_payment_method": "apple-pay", "language": "en" }' ``` ### Node.js ```javascript const response = await fetch("https://sandbox.payme.io/api/generate-sale", { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ "seller_payme_id": "MPLDEMO-MPLDEMO-MPLDEMO-1234567", "sale_price": 1000, "currency": "ILS", "product_name": "Order 1234", "sale_payment_method": "apple-pay", "language": "en" }), }); console.log(await response.text()); ``` ### Python ```python import requests response = requests.post( "https://sandbox.payme.io/api/generate-sale", json={ "seller_payme_id": "MPLDEMO-MPLDEMO-MPLDEMO-1234567", "sale_price": 1000, "currency": "ILS", "product_name": "Order 1234", "sale_payment_method": "apple-pay", "language": "en", }, ) print(response.text) ``` ### PHP ```php 'POST', CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => [ 'Content-Type: application/json', ], CURLOPT_POSTFIELDS => $body, ]); $response = curl_exec($ch); curl_close($ch); echo $response; ``` ## Responses ### 200 — The sale was created. (success) | Field | Type | Description | | --- | --- | --- | | `status_code` | number | `0` on success. | | `sale_url` | string | PayMe's payment page for this sale. It shows Apple Pay. | | `payme_sale_id` | string | The sale's ID. Pass it to `instance.appleSale()` as `saleGuid`. | | `payme_sale_code` | number | A short numeric sale code, for display only. | | `price` | number | The amount, in minor units. | | `transaction_id` | string | Your own order ID, if you sent `transaction_id`; otherwise empty. | | `currency` | string | The sale's currency. | | `sale_payment_method` | string | `apple-pay`. | ```json { "status_code": 0, "sale_url": "https://sandbox.payme.io/sale/generate/SALE1655-3843870J-NTPYLJNW-SOWRLK9X", "payme_sale_id": "SALE1655-3843870J-NTPYLJNW-SOWRLK9X", "payme_sale_code": 1032526, "price": 1000, "transaction_id": "", "currency": "ILS", "sale_payment_method": "apple-pay" } ``` ### 400 — The request is invalid. For example, error `351` when `installments` is more than 1. (error) | Field | Type | Description | | --- | --- | --- | | `status_code` | number | `1` for a failed request. | | `status_error_code` | number | PayMe's error code. See [Errors](/payments/getting-started/errors). | | `status_error_details` | string | The error message, in the request's `language`. | | `status_additional_info` | string | More detail when there is any, for example the field or the site that failed; otherwise `null`. | ```json { "status_code": 1, "status_error_details": "Please verify installments amount", "status_additional_info": "installments are not allowed for apple-pay", "status_error_code": 351 } ``` ### 500 — The request failed. For example, error `720` "The service was not activated" when the seller has no active Apple Pay service. (error) | Field | Type | Description | | --- | --- | --- | | `status_code` | number | `1` for a failed request. | | `status_error_code` | number | PayMe's error code. See [Errors](/payments/getting-started/errors). | | `status_error_details` | string | The error message, in the request's `language`. | | `status_additional_info` | string | More detail when there is any, for example the field or the site that failed; otherwise `null`. | ```json { "status_code": 1, "status_error_details": "The service was not activated", "status_additional_info": "apple-pay", "status_error_code": 720 } ```