top of page

Classic: Plan management

POST /transact.php · Plan management

Classic protocol

This family uses POST /transact.php under the documented sandbox base https://sandbox.nmi.com/api. Send application/x-www-form-urlencoded fields with the private security_key on your server. Do not substitute a REST JSON body or REST Authorization header. Each named variant below has its own action selector and required fields. For maintenance of a Classic integration. Source examples are fixtures, not live credentials; replace their security_key before any authorized test. This reference sends no requests.

Choose the operation variant

Variant Selector fields Required fields AddPlanWithNDayChargeRequest AddPlanWithMonthlyChargeRequest EditPlanWithNDayChargeRequest EditPlanWithMonthlyChargeRequest

Request language templates

Original transport templates derived from this endpoint’s documented method, server, authentication and media type. Replace path/query/credential placeholders with authorized sandbox values. These examples print the raw status and response; they do not infer business success or retry a request. Save properly URL-encoded name=value pairs for your selected operation as request.form, including its private security_key when required. JSON example objects below describe these form fields; they are not the wire encoding. Node requires a runtime with fetch; PHP requires cURL. Generated source-based examples have not been executed against provider accounts. curl --request POST \ --url 'https://sandbox.nmi.com/api/transact.php' \ --header 'Content-Type: application/x-www-form-urlencoded' \ --data-binary '@request.form' import { readFile } from 'node:fs/promises'; const body = await readFile('request.form', 'utf8'); const response = await fetch("https://sandbox.nmi.com/api/transact.php", { method: 'POST', headers: { "Content-Type": "application/x-www-form-urlencoded" }, body }); console.log(response.status, await response.text()); from urllib.request import Request, urlopen from urllib.error import HTTPError from pathlib import Path request = Request('https://sandbox.nmi.com/api/transact.php', method='POST', headers={'Content-Type': 'application/x-www-form-urlencoded'}, data=Path('request.form').read_bytes()) try: with urlopen(request, timeout=30) as response: print(response.status, response.read().decode()) except HTTPError as error: print(error.code, error.read().decode()) require 'net/http' require 'uri' uri = URI("https://sandbox.nmi.com/api/transact.php") request = Net::HTTP::Post.new(uri) request["Content-Type"] = "application/x-www-form-urlencoded" request.body = File.binread('request.form') response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https', read_timeout: 30) { |http| http.request(request) } puts response.code puts response.body <?php $curl = curl_init('https://sandbox.nmi.com/api/transact.php'); curl_setopt_array($curl, [ CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 30, CURLOPT_HTTPHEADER => ['Content-Type: application/x-www-form-urlencoded'], CURLOPT_POSTFIELDS => file_get_contents('request.form') ]); $response = curl_exec($curl); if ($response === false) { throw new RuntimeException(curl_error($curl)); } echo curl_getinfo($curl, CURLINFO_HTTP_CODE), PHP_EOL, $response; curl_close($curl);

Request fields

Choose one schema variant. Descriptions retain conditional requirements that are not always included in required arrays. Do not merge all variants into one request. Field Type Required Description Constraints [oneOf 1].[allOf 1].security_key string yes API Security Key assigned to a merchant account. New keys can be generated from the merchant control panel in Settings > Security Keys [oneOf 1].[allOf 1].recurring string yes Add a recurring plan that subscriptions can be added to in the future. enum: ["add_plan"] [oneOf 1].[allOf 1].plan_name string yes The display name of the plan. [oneOf 1].[allOf 1].start_date string no The first day that the customer will be charged. Format: `YYYYMMDD` format: "date" [oneOf 1].[allOf 2].[allOf 1].plan_id string no Create a subscription tied to a Plan ID if the sale/auth transaction is successful. [oneOf 1].[allOf 2].[allOf 2].plan_payments integer no The number of payments before the recurring plan is complete. Note: Use '0' for until canceled [oneOf 1].[allOf 2].[allOf 2].plan_amount number no The plan amount to be charged each billing cycle. Format: `x.xx` [oneOf 1].[allOf 3].day_frequency integer no How often, in days, to charge the customer. Cannot be set with 'month_frequency' or 'day_of_month'. [oneOf 2].[allOf 1].security_key string yes API Security Key assigned to a merchant account. New keys can be generated from the merchant control panel in Settings > Security Keys [oneOf 2].[allOf 1].recurring string yes Add a recurring plan that subscriptions can be added to in the future. enum: ["add_plan"] [oneOf 2].[allOf 1].plan_name string yes The display name of the plan. [oneOf 2].[allOf 1].start_date string no The first day that the customer will be charged. Format: `YYYYMMDD` format: "date" [oneOf 2].[allOf 2].[allOf 1].plan_id string no Create a subscription tied to a Plan ID if the sale/auth transaction is successful. [oneOf 2].[allOf 2].[allOf 2].plan_payments integer no The number of payments before the recurring plan is complete. Note: Use '0' for until canceled [oneOf 2].[allOf 2].[allOf 2].plan_amount number no The plan amount to be charged each billing cycle. Format: `x.xx` [oneOf 2].[allOf 3].month_frequency integer no How often, in months, to charge the customer. Cannot be set with 'day_frequency'. Must be set with 'day_of_month'. minimum: 1; maximum: 24 [oneOf 2].[allOf 3].day_of_month integer no The day that the customer will be charged. Cannot be set with 'day_frequency'. Must be set with 'month_frequency'. For months without 29, 30, or 31 days, the charge will be on the last day. minimum: 1; maximum: 31 [oneOf 3].[allOf 1].security_key string yes API Security Key assigned to a merchant account. New keys can be generated from the merchant control panel in Settings > Security Keys [oneOf 3].[allOf 1].recurring string yes Edit an existing recurring plan. Value: 'edit_plan' - Be careful when editing an existing plan, as all customers signed up for this plan will have their billing changed based on your edits. enum: ["edit_plan"] [oneOf 3].[allOf 1].current_plan_id string yes Only relevant for editing an existing plan, the value will be the 'plan_id' that will be edited in this request. [oneOf 3].[allOf 1].plan_name string no The display name of the plan. [oneOf 3].[allOf 2].[allOf 1].plan_id string no Create a subscription tied to a Plan ID if the sale/auth transaction is successful. [oneOf 3].[allOf 2].[allOf 2].plan_payments integer no The number of payments before the recurring plan is complete. Note: Use '0' for until canceled [oneOf 3].[allOf 2].[allOf 2].plan_amount number no The plan amount to be charged each billing cycle. Format: `x.xx` [oneOf 3].[allOf 3].day_frequency integer no How often, in days, to charge the customer. Cannot be set with 'month_frequency' or 'day_of_month'. [oneOf 4].[allOf 1].security_key string yes API Security Key assigned to a merchant account. New keys can be generated from the merchant control panel in Settings > Security Keys [oneOf 4].[allOf 1].recurring string yes Edit an existing recurring plan. Value: 'edit_plan' - Be careful when editing an existing plan, as all customers signed up for this plan will have their billing changed based on your edits. enum: ["edit_plan"] [oneOf 4].[allOf 1].current_plan_id string yes Only relevant for editing an existing plan, the value will be the 'plan_id' that will be edited in this request. [oneOf 4].[allOf 1].plan_name string no The display name of the plan. [oneOf 4].[allOf 2].[allOf 1].plan_id string no Create a subscription tied to a Plan ID if the sale/auth transaction is successful. [oneOf 4].[allOf 2].[allOf 2].plan_payments integer no The number of payments before the recurring plan is complete. Note: Use '0' for until canceled [oneOf 4].[allOf 2].[allOf 2].plan_amount number no The plan amount to be charged each billing cycle. Format: `x.xx` [oneOf 4].[allOf 3].month_frequency integer no How often, in months, to charge the customer. Cannot be set with 'day_frequency'. Must be set with 'day_of_month'. minimum: 1; maximum: 24 [oneOf 4].[allOf 3].day_of_month integer no The day that the customer will be charged. Cannot be set with 'day_frequency'. Must be set with 'month_frequency'. For months without 29, 30, or 31 days, the charge will be on the last day. minimum: 1; maximum: 31 { "content": { "application/x-www-form-urlencoded": { "schema": { "oneOf": [ { "$ref": "#/components/schemas/AddPlanWithNDayChargeRequest" }, { "$ref": "#/components/schemas/AddPlanWithMonthlyChargeRequest" }, { "$ref": "#/components/schemas/EditPlanWithNDayChargeRequest" }, { "$ref": "#/components/schemas/EditPlanWithMonthlyChargeRequest" } ] }, "examples": { "Add Plan Daily Charge Request": { "$ref": "#/components/examples/AddPlanNDayCharge" }, "Add Plan With Monthly Charge Request": { "$ref": "#/components/examples/AddPlanWithMonthlyCharge" }, "Edit Plan Daily Charge Request": { "$ref": "#/components/examples/EditPlanWithNDayCharge" }, "Edit Plan With Monthly Charge Request": { "$ref": "#/components/examples/EditPlanWithMonthlyCharge" } } } } } true

Response contract

The Classic methodology describes ampersand-delimited name/value responses. Where this schema advertises JSON media, that declaration is retained below as a source inconsistency; do not assume REST response parsing. For payments, response 1/2/3 distinguishes approval, decline and error. A transport success alone does not prove a payment was approved. { "200": { "description": "Plan operation completed successfully", "content": { "application/x-www-form-urlencoded": { "schema": { "$ref": "#/components/schemas/Response" }, "examples": { "Plan Created": { "$ref": "#/components/examples/PlanCreated" }, "Plan Updated": { "$ref": "#/components/examples/PlanUpdated" }, "Declined Request": { "$ref": "#/components/examples/DeclinedResponse" } } } } } } true

Referenced schema definitions

All schemas and source example objects are preserved here, including descriptions, enums and references. Sample data may be historical. These JSON objects describe form parameters; they are not instructions to send JSON to Classic. { "schemas": { "SecurityKey": { "type": "string", "description": "API Security Key assigned to a merchant account. New keys can be generated from the merchant control panel in Settings > Security Keys" }, "RecurringFields": { "type": "object", "properties": { "plan_payments": { "type": "integer", "description": "The number of payments before the recurring plan is complete.\n\nNote: Use '0' for until canceled" }, "plan_amount": { "type": "number", "description": "The plan amount to be charged each billing cycle.\n\nFormat: `x.xx`" } } }, "RecurringFieldsWithPlanId": { "allOf": [ { "type": "object", "properties": { "plan_id": { "type": "string", "description": "Create a subscription tied to a Plan ID if the sale/auth transaction is successful." } } }, { "$ref": "#/components/schemas/RecurringFields" } ] }, "RecurringDailyFields": { "type": "object", "properties": { "day_frequency": { "type": "integer", "description": "How often, in days, to charge the customer. Cannot be set with 'month_frequency' or 'day_of_month'." } } }, "AddPlanWithNDayChargeRequest": { "title": "Add Daily Plan", "allOf": [ { "required": [ "recurring", "plan_payments", "plan_amount", "plan_name", "plan_id", "day_frequency", "security_key" ], "type": "object", "properties": { "security_key": { "$ref": "#/components/schemas/SecurityKey" }, "recurring": { "type": "string", "enum": [ "add_plan" ], "description": "Add a recurring plan that subscriptions can be added to in the future." }, "plan_name": { "type": "string", "description": "The display name of the plan." }, "start_date": { "type": "string", "format": "date", "description": "The first day that the customer will be charged.\n\nFormat: `YYYYMMDD`\n\n", "x-group-key": "Recurring" } } }, { "$ref": "#/components/schemas/RecurringFieldsWithPlanId" }, { "$ref": "#/components/schemas/RecurringDailyFields" } ] }, "RecurringMonthlyFields": { "type": "object", "properties": { "month_frequency": { "type": "integer", "minimum": 1, "maximum": 24, "description": "How often, in months, to charge the customer. Cannot be set with 'day_frequency'. Must be set with 'day_of_month'." }, "day_of_month": { "type": "integer", "minimum": 1, "maximum": 31, "description": "The day that the customer will be charged. Cannot be set with 'day_frequency'. Must be set with 'month_frequency'. For months without 29, 30, or 31 days, the charge will be on the last day." } } }, "AddPlanWithMonthlyChargeRequest": { "title": "Add Monthly Plan", "allOf": [ { "required": [ "recurring", "plan_payments", "plan_amount", "plan_name", "plan_id", "month_frequency", "day_of_month", "security_key" ], "type": "object", "properties": { "security_key": { "$ref": "#/components/schemas/SecurityKey" }, "recurring": { "type": "string", "enum": [ "add_plan" ], "description": "Add a recurring plan that subscriptions can be added to in the future." }, "plan_name": { "type": "string", "description": "The display name of the plan." }, "start_date": { "type": "string", "format": "date", "description": "The first day that the customer will be charged.\n\nFormat: `YYYYMMDD`", "x-group-key": "Recurring" } } }, { "$ref": "#/components/schemas/RecurringFieldsWithPlanId" }, { "$ref": "#/components/schemas/RecurringMonthlyFields" } ] }, "EditPlanWithNDayChargeRequest": { "title": "Edit Daily Plan", "allOf": [ { "required": [ "recurring", "current_plan_id", "day_frequency", "security_key" ], "type": "object", "properties": { "security_key": { "$ref": "#/components/schemas/SecurityKey" }, "recurring": { "type": "string", "enum": [ "edit_plan" ], "description": "Edit an existing recurring plan.\n\nValue: 'edit_plan' - Be careful when editing an existing plan, as all customers signed up for this plan will have their billing changed based on your edits." }, "current_plan_id": { "type": "string", "description": "Only relevant for editing an existing plan, the value will be the 'plan_id' that will be edited in this request." }, "plan_name": { "type": "string", "description": "The display name of the plan." } } }, { "$ref": "#/components/schemas/RecurringFieldsWithPlanId" }, { "$ref": "#/components/schemas/RecurringDailyFields" } ] }, "EditPlanWithMonthlyChargeRequest": { "title": "Edit Monthly Plan", "allOf": [ { "required": [ "recurring", "current_plan_id", "month_frequency", "day_of_month", "security_key" ], "type": "object", "properties": { "security_key": { "$ref": "#/components/schemas/SecurityKey" }, "recurring": { "type": "string", "enum": [ "edit_plan" ], "description": "Edit an existing recurring plan.\n\nValue: 'edit_plan' - Be careful when editing an existing plan, as all customers signed up for this plan will have their billing changed based on your edits." }, "current_plan_id": { "type": "string", "description": "Only relevant for editing an existing plan, the value will be the 'plan_id' that will be edited in this request." }, "plan_name": { "type": "string", "description": "The display name of the plan." } } }, { "$ref": "#/components/schemas/RecurringFieldsWithPlanId" }, { "$ref": "#/components/schemas/RecurringMonthlyFields" } ] }, "Response": { "type": "object", "title": "Response", "properties": { "response": { "type": "string", "enum": [ "1", "2", "3" ], "description": "Status code for the operation. (1) - success, (2) - failed, (3) system error" }, "responsetext": { "type": "string", "description": "Textual description of the operation's result." }, "authcode": { "type": "string", "description": "Authorization code for the operation." }, "amount_authorized": { "type": "string", "description": "(Conditional) This will optionally come back when requesting partial payment. Authorization amount." }, "transactionid": { "type": "string", "description": "(Conditional - Payment) Payment gateway transaction id." }, "invoice_id": { "type": "string", "description": "(Conditional - Invoice) Identifier for the invoice." }, "avsresponse": { "type": "string", "description": "Address Verification Service response code." }, "cvvresponse": { "type": "string", "description": "Card Verification Value response." }, "orderid": { "type": "string", "description": "Identifier for an order related to this invoice." }, "type": { "type": "string", "enum": [ "sale", "auth", "validate", "credit", "offline", "capture", "void", "refund", "complete_partial_payment", "add_invoice", "update_invoice", "send_invoice", "close_invoice", "add_plan", "edit_plan", "add_subscription", "" ], "description": "Type of operation that this response is for." }, "partial_payment_id": { "type": "string", "description": "(Conditional) This will optionally come back when requesting partial payment. A numeric identifier which is used when submitting subsequent transactions." }, "partial_payment_balance": { "type": "string", "description": "(Conditional) This will optionally come back when requesting partial payment. The payment's remaining balance." }, "platform_id": { "type": "string", "description": "Platform ID associated with the transaction." }, "response_code": { "type": "string", "description": "Another status or result code for the operation. See [Response Code Table](#section/Appendixes/Payment-API-Response-Codes)" }, "subscription_id": { "type": "string", "description": "(Conditional - Subscription) The subscription ID that was created" }, "emv_auth_response_data": { "type": "string", "description": "(Conditional) This will optionally come back when any chip card data is provided on the authorization. This data needs to be sent back to the SDK after an authorization." }, "payment_terms": { "type": "string", "description": "(Conditional - Invoice) The terms of payment for the invoice." }, "customer_vault_id": { "type": "string", "description": "(Conditional - Customer Vault) The original customer_vault_id passed in the transaction request or the resulting customer_vault_id created on an approved transaction.\n\nNote: Only returned when the \"Customer Vault\" service is active." }, "kount_score": { "type": "string", "description": "The Kount \"Omniscore\" indicating the level of risk on a given transaction. The higher the score, the lower the risk.\n\nNote: Only returned when the \"Kount\" service is active." } } } }, "examples": { "AddPlanNDayCharge": { "summary": "Add Plan With Daily Charge", "description": "Add a recurring plan that subscriptions can be added to in the future.", "value": { "recurring": "add_plan", "plan_payments": 0, "plan_amount": 230.22, "plan_name": "Plan 1 Name", "plan_id": "223", "day_frequency": 31, "security_key": "6457Thfj624V5r7WUwc5v6a68Zsd6YEm" } }, "AddPlanWithMonthlyCharge": { "summary": "Add Plan With Monthly Charge", "description": "Add a recurring plan that subscriptions can be added to in the future.", "value": { "recurring": "add_plan", "plan_payments": 2, "plan_amount": 323.33, "plan_name": "Plan 2 Name", "plan_id": "223", "month_frequency": 2, "day_of_month": 4, "security_key": "6457Thfj624V5r7WUwc5v6a68Zsd6YEm" } }, "EditPlanWithNDayCharge": { "summary": "Edit an existing recurring plan With Daily Charge", "description": "Edit an existing recurring plan.", "value": { "recurring": "edit_plan", "current_plan_id": "21", "plan_payments": 2, "plan_amount": 323.33, "plan_name": "Plan 2 Name", "plan_id": "21", "month_frequency": 2, "day_of_month": 4, "security_key": "6457Thfj624V5r7WUwc5v6a68Zsd6YEm" } }, "EditPlanWithMonthlyCharge": { "summary": "Edit an existing recurring plan With Daily Charge option", "description": "Edit an existing recurring plan.", "value": { "recurring": "edit_plan", "current_plan_id": "21", "plan_payments": 0, "plan_amount": 230.22, "plan_name": "Plan 1 Name", "plan_id": "21", "day_frequency": 31, "security_key": "6457Thfj624V5r7WUwc5v6a68Zsd6YEm" } }, "PlanCreated": { "summary": "Plan Created", "description": "Plan has been created successfully", "value": { "response": "1", "responsetext": "Plan Added", "authcode": "", "transactionid": "", "avsresponse": "", "cvvresponse": "", "orderid": "", "type": "", "response_code": "100" } }, "PlanUpdated": { "summary": "Plan Updated", "description": "Plan has been updated successfully", "value": { "response": "1", "responsetext": "Plan Edit Successful", "authcode": "", "transactionid": "", "avsresponse": "", "cvvresponse": "", "orderid": "", "type": "", "response_code": "100" } }, "DeclinedResponse": { "summary": "Failed to Create Plan", "description": "Failed to create a new plan", "value": { "response": "3", "responsetext": "There is already a plan using the SKU you have specified. REFID:1203610329", "authcode": "", "transactionid": "", "avsresponse": "", "cvvresponse": "", "orderid": "", "type": "", "response_code": "100" } } } } true

Published operation notes

Additional operation-specific source notes, including legacy outcome tables where published. Read alongside the family guidance above; source marketing claims are not compliance guarantees. <details> <summary>Methodology</summary> **Steps:** 1. The customer sends their payment information to the merchant's web site. 2. The merchant web site posts the payment data to the Payment Gateway. 3. The Payment Gateway responds immediately with the results of the transactions. 4. The merchant web site displays the appropriate message to the customer. The communication method used to send messages to the Payment Gateway's server is the standard HTTP protocol over an SSL connection. In the Payment API method, the communications with the cardholder (Steps 1 and 4) are developed completely by the merchant and therefore are not defined by the Payment Gateway. Step 1 should simply collect the payment data from the cardholder and Step 4 should display the appropriate transaction receipt or declined message. In Step 2, transaction details should be delivered to the Payment Gateway using the POST method with the appropriate variables defined below posted along with the request. In Step 3, the transaction responses are returned in the body of the HTTP response in a query string name/value format delimited by ampersands. For example: `variable1=value1&variable2=value2&variable3=value3` ### Customer Vault The Customer Vault was designed specifically for businesses of any size to address concerns about handling customer payment information. Visa and MasterCard have instituted the Payment Card Industry (PCI) Data Security to protect cardholder data, wherever it resides, ensuring that members, merchants, and service providers maintain the highest information security standards. These associations have also deemed that merchants will be held liable for any breach of cardholder data. This has become a major concern for merchants who handle credit card or electronic check payments. The Customer Vault is designed for these merchants who desire to avoid the tremendous costs and resources involved in becoming PCI compliant under these circumstances. The Customer Vault does this by allowing merchants to transmit their payment information through a Secure Sockets Layer (SSL) connection for storage in our Level 1 PCI certified data facility. Once the customer record has been securely transmitted to the Customer Vault, the merchant can then initiate transactions remotely without having to access cardholder information directly. This process is accomplished without the merchant storing the customer's payment information in their local database or payment application. </details> <details> <summary>Response Code Table</summary> | Code | Description | |:------|:-------------------------------------------------------------------| | 100 | Transaction was approved. | | 200 | Transaction was declined by processor. | | 201 | Do not honor. | | 202 | Insufficient funds. | | 203 | Over limit. | | 204 | Transaction not allowed. | | 220 | Incorrect payment information. | | 221 | No such card issuer. | | 222 | No card number on file with issuer. | | 223 | Expired card. | | 224 | Invalid expiration date. | | 225 | Invalid card security code. | | 226 | Invalid PIN. | | 240 | Call issuer for further information. | | 250 | Pick up card. | | 251 | Lost card. | | 252 | Stolen card. | | 253 | Fraudulent card. | | 260 | Declined with further instructions available. (See response text) | | 261 | Declined-Stop all recurring payments. | | 262 | Declined-Stop this recurring program. | | 263 | Declined-Update cardholder data available. | | 264 | Declined-Retry in a few days. | | 300 | Transaction was rejected by gateway. | | 400 | Transaction error returned by processor. | | 410 | Invalid merchant configuration. | | 411 | Merchant account is inactive. | | 420 | Communication error. | | 421 | Communication error with issuer. | | 430 | Duplicate transaction at processor. | | 440 | Processor format error. | | 441 | Invalid transaction information. | | 460 | Processor feature not available. | | 461 | Unsupported card type. | </details> true

Reconcile outcomes

Persist the returned transaction or object identifier and inspect the operation result before changing application state. Investigate interrupted financial responses before retrying. Saved methods, invoice delivery, schedules and refunds have different side effects; select the corresponding variant explicitly. Account and processor behavior have not been executed in this audit.

Join the community and get the latest biz news & tips

Thanks for submitting!

© 2025 Betterpay. All Rights Reserved.

bottom of page