# Pay a subscription Building with an AI agent? Start at https://docs.payme.io/agents.md - Sandbox: `POST https://sandbox.payme.io/api/pay-subscription` - Production: `POST https://live.payme.io/api/pay-subscription` ## Credentials - Request body field `seller_payme_id` (optional): Not needed and not read by this call: `sub_payme_id` identifies the seller. ## Overview Attaches a card to a subscription and activates it. Use it when you collect the card in your own form instead of sending the buyer to `sub_url`, or to replace the card on a subscription in status `4` (Failed) or `7` (Failed, retry pending). - The call checks the card with a validation transaction and saves it as the subscription's buyer token. It doesn't charge an iteration: the status becomes `2` (Active), and the background job charges at `sub_next_date`. For a status-`7` subscription, that is the next retry date. - Only a subscription in status `1`, `4` or `7` can be paid. Any other status returns error `305`; an active subscription is never charged again by this call. - If the card check fails, the subscription moves to status `4` and PayMe sends `sub-failure`. Call this endpoint again with another card. - For a template (`sub_type` `10`), each successful call creates a new subscription for that buyer and returns it. - A lock stops two calls on the same subscription from running at once. There is no card swap for an active subscription. ## Authentication No API key is needed: `sub_payme_id` identifies the seller, so you can make this call from the buyer's browser, like `pay-sale`. `seller_payme_id` and `payme_client_key` aren't read here. ## Errors Errors return `status_code` `1` with HTTP 500 unless the table says otherwise. | HTTP | Code | When | |---|---|---| | 500 | `1` | A required field is missing. `status_additional_info` names it. | | 500 | `305` | The subscription isn't in status `1`, `4` or `7`. `status_additional_info` is the current status. | | 500 | `371` | No subscription has this `sub_payme_id`. | | 500 | Card error code | The card number, expiry or CVV is invalid, or the card check was declined: the response carries the card error code. | ## Parameters This endpoint takes no path, query or header parameters. ## Request body Content type: `application/json` | Field | Type | Required | Description | | --- | --- | --- | --- | | `sub_payme_id` | string | yes | The subscription (`sub_payme_id` from [Create a subscription](/payments/subscriptions/post-generate-subscription)). | | `seller_payme_id` | string | no | Not needed and not read by this call: `sub_payme_id` identifies the seller. | | `credit_card_number` | string | yes | Card number. | | `credit_card_exp` | string | yes | Card expiry, `MMYY`. | | `credit_card_cvv` | string | yes | Card CVV. | | `buyer_name` | string | yes | Card holder's full name. | | `buyer_email` | string | yes | Card holder's email. It replaces the subscription's buyer email. | | `buyer_phone` | string | no | Card holder's phone number. | | `buyer_social_id` | string | no | Card holder's national ID. | | `buyer_business_name` | string | no | The buyer's business name. Send it together with `buyer_business_code`. | | `buyer_business_code` | string | no | The buyer's business registration number. | | `payment` | object | no | The newer request shape: a `payment` object with `payment.method` and that method's fields. When you send it, the `credit_card_*`, `buyer_name` and `buyer_email` fields aren't required. | | `payment.method` | string | yes | Payment method, for example `credit-card`. | ### Request example ```json { "sub_payme_id": "SUB16885-68336QPL-UQSSS1CC-SYKXI53N", "credit_card_number": "5326105300985846", "credit_card_exp": "1230", "credit_card_cvv": "658", "buyer_name": "Israel Israeli", "buyer_email": "buyer@example.com" } ``` ## Code samples ### curl ```bash curl -X POST 'https://sandbox.payme.io/api/pay-subscription' \ -H 'Content-Type: application/json' \ --data-raw '{ "sub_payme_id": "SUB16885-68336QPL-UQSSS1CC-SYKXI53N", "credit_card_number": "5326105300985846", "credit_card_exp": "1230", "credit_card_cvv": "658", "buyer_name": "Israel Israeli", "buyer_email": "buyer@example.com" }' ``` ### Node.js ```javascript const response = await fetch("https://sandbox.payme.io/api/pay-subscription", { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ "sub_payme_id": "SUB16885-68336QPL-UQSSS1CC-SYKXI53N", "credit_card_number": "5326105300985846", "credit_card_exp": "1230", "credit_card_cvv": "658", "buyer_name": "Israel Israeli", "buyer_email": "buyer@example.com" }), }); console.log(await response.text()); ``` ### Python ```python import requests response = requests.post( "https://sandbox.payme.io/api/pay-subscription", json={ "sub_payme_id": "SUB16885-68336QPL-UQSSS1CC-SYKXI53N", "credit_card_number": "5326105300985846", "credit_card_exp": "1230", "credit_card_cvv": "658", "buyer_name": "Israel Israeli", "buyer_email": "buyer@example.com", }, ) 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 card was attached and the subscription is active. (success) | Field | Type | Description | | --- | --- | --- | | `status_code` | integer | `0` on success. | | `payme_status` | string | `success`. | | `status_error_code` | integer | `0` on success. | | `seller_payme_id` | string | The seller's MPL. | | `seller_id` | string | The partner's own reference for the seller, if the partner set one. Otherwise `null`. | | `sub_payme_id` | string | PayMe's subscription ID (`SUB…`). Use it in every other subscription call. | | `sub_payme_code` | integer | PayMe's numeric subscription ID. | | `subscription_id` | string | Your own reference, as sent when the subscription was created. `null` if you didn't send one. | | `sub_created` | string | When the subscription was created, `YYYY-MM-DD HH:MM:SS`. | | `sub_start_date` | string | Date of the first charge, `YYYY-MM-DD HH:MM:SS`. | | `sub_prev_date` | string | When the last successful charge ran. `null` until the first charge. | | `sub_next_date` | string | When the next charge is due. Ignore it on a canceled or completed subscription. | | `sub_status` | integer | Current status. See [Subscription statuses](/payments/codes-statuses/subscription-statuses). | | `sub_iteration_type` | integer | Billing interval. See [Subscription iteration types](/payments/codes-statuses/subscription-iteration-types). | | `sub_currency` | string | ISO 4217 currency code, e.g. `ILS`. | | `sub_price` | integer | Price of one iteration, in minor units (`5000` = 50.00). | | `sub_description` | string | What the buyer is paying for. | | `sub_iterations` | integer | Total number of iterations. `-1` means unlimited. | | `sub_iterations_completed` | integer | Iterations charged successfully. | | `sub_iterations_skipped` | integer | Iterations skipped while the subscription was paused. They are never charged. | | `sub_iterations_left` | integer | `sub_iterations` minus completed and skipped iterations. `-1` when unlimited. | | `sub_paid` | boolean | `true` once a card (buyer token) is attached to the subscription. It does not mean the current iteration was charged. | | `sub_error_text` | string | The last failure, pause or cancel reason. `null` if there is none. Reasons that PayMe writes are in Hebrew. | | `sub_payment_date` | string | Returned only when a card is attached: when the card was attached. | | `buyer_card_mask` | string | Returned only when a card is attached: the masked card number. | | `buyer_card_exp` | string | Returned only when a card is attached: card expiry, `MMYY`. | | `buyer_name` | string | Returned only when a card is attached: the card holder's name. | | `buyer_email` | string | Returned only when a card is attached: the card holder's email. | | `buyer_phone` | string | Returned only when a card is attached: the card holder's phone, or `null`. | | `buyer_social_id` | string | Returned only when a card is attached: the card holder's national ID, or `null`. | | `redirect_url` | string | `sub_return_url` with `payme_status`, `payme_signature`, `sub_payme_id`, `subscription_id`, `transaction_id`, `price`, `currency` and `is_foreign_card` added. `null` if the subscription has no return URL. | ```json { "status_code": 0, "payme_status": "success", "status_error_code": 0, "seller_payme_id": "MPLDEMO-MPLDEMO-MPLDEMO-1234567", "seller_id": null, "sub_payme_id": "SUB16885-68336QPL-UQSSS1CC-SYKXI53N", "sub_payme_code": 477004, "subscription_id": "order-1001", "sub_created": "2026-11-09 10:15:00", "sub_start_date": "2026-12-01 00:00:00", "sub_prev_date": null, "sub_next_date": "2026-12-01 00:00:00", "sub_status": 2, "sub_iteration_type": 3, "sub_currency": "ILS", "sub_price": 5000, "sub_description": "Monthly plan", "sub_iterations": 12, "sub_iterations_completed": 0, "sub_iterations_skipped": 0, "sub_iterations_left": 12, "sub_paid": true, "sub_error_text": null, "sub_payment_date": "2026-11-09 10:20:00", "buyer_card_mask": "532610******5846", "buyer_card_exp": "1230", "buyer_name": "Israel Israeli", "buyer_email": "buyer@example.com", "buyer_phone": null, "buyer_social_id": null, "redirect_url": "https://www.example.com/payment/success?payme_status=success&payme_signature=…&sub_payme_id=SUB16885-68336QPL-UQSSS1CC-SYKXI53N" } ``` ### 500 — The request was refused or the card check failed. See the error table. (error) | Field | Type | Description | | --- | --- | --- | | `status_code` | integer | `1` on failure. | | `status_error_details` | string | What went wrong, in the language you asked for (Hebrew by default). | | `status_additional_info` | string | The field or value concerned. Can be `null`. | | `status_error_code` | integer | PayMe error code. See the error table above and [Errors](/payments/getting-started/errors). | | `session` | string | PayMe session ID. Quote it when you contact support. | ```json { "status_code": 1, "status_error_details": "Required parameter is missing", "status_additional_info": "sub_payme_id", "status_error_code": 1, "session": "FhT3aXe7" } ```