---
title: "This will create a new Transaction"
method: POST
path: "/transaction/payInvoice"
tags: ["transactions"]
---

# This will create a new Transaction

`POST /transaction/payInvoice`

This will attribute a payment to an Invoice. Please note that this request requires valid parameters for all associated members of the Transaction or the request will fail. If you have doubled-checked all parameters and the request is still failing, check that the payload JSON format is correct by using <a href="http://jsonlint.com/">JSONLint</a>. If credit card and billing information already exist for this contact, you may omit <b>billing_address</b> and <b>payer</b> from the request.

## Request body

- Transaction
  - `contact_id` integer, required — Create new Transaction for this Object instance (Contact ID).
  - `chargeNow` 'chargeNow' | 'chargeLog', required — Charge Transaction now or or just log a Transaction.
  - `trans_date` integer — Timestamp (in milliseconds since midnight 1/1/1970) of the Transaction.
  - `invoice_template` integer, required — Invoice ID to use for this Transaction.
  - `gateway_id` integer, required — Gateway ID to use for this Transaction.
  - `cc_id` integer — Credit Card ID to use for this Transaction. This can be used instead of Payer.
  - `offer` Offer, required
    - `cc_id` integer — Credit Card ID
    - `products` Product[], required
      - `quantity` integer, required — How many of this product are being purchased?
      - `total` number, required — What is the total amount of this sale?
      - `shipping` boolean — Does this product have an associated shipping cost?
      - `tax` boolean — Is this product taxable?
      - `price` Price[], required
        - `price` number, required
        - `payment_count` integer, required
        - `unit` 'day' | 'week' | 'month' | 'quarter' | 'year', required
        - `id` integer, required
      - `trial` object
        - `unit` 'day' | 'week' | 'month' | 'quarter' | 'year' — Units describing length of trial period.
        - `payment_count` integer — Length of trial period (also set trial_period_units).
        - `price` number — Price during trial period.
      - `type` 'single' | 'subscription' | 'one_time' | 'payment_plan'
      - `owner` integer — Product owner (Staff ID).
      - `level1` number — Partner Level 1 commission percentage.
      - `level2` number — Partner Level 2 commission percentage.
      - `offer_to_affiliates` boolean — Is this offered to Partners (affiliates)?
      - `setup_fee` number — One-time setup fee.
      - `setup_fee_when` 'immediately' | 'after_trial' | 'on_date' — When should setup fee be applied?
      - `setup_fee_date` string — Date to charge setup fee (when setup_fee_when is "on_date").
      - `delay_start` integer — Days to delay start.
      - `subscription_fee` number
      - `subscription_count` integer
      - `subscription_unit` 'day' | 'week' | 'month' | 'quarter' | 'year'
      - `taxable` boolean — Is this item taxable?
      - `id` integer — This must be an existing Product ID.
    - `taxes` Tax[]
      - `id` integer, required — ID of the Tax to apply. This must be an existing Tax type.
      - `rate` number
      - `name` string
      - `taxShipping` boolean
      - `taxTotal` number
      - `form_id` integer
    - `shipping` Shipping[] — Shipping amount.
      - `id` integer, required — ID of the Shipping Method to apply. This must be an existing Shipping Method.
      - `name` string
      - `price` number
      - `form_id` integer
    - `delay` integer — Days to delay start of offer.
    - `subTotal` number — Subtotal.
    - `grandTotal` number — Total amount of sale.
    - `hasTaxes` boolean — Are there applicable taxes?
    - `hasShipping` boolean — Are there shipping charges?
    - `shipping_charge_reoccurring_orders` boolean — Add shipping charge to reoccurring orders?
    - `send_recurring_invoice` boolean — If the transaction is a subscription, should an invoice be sent with every recurring order?
    - `ccExpirationDate` string — Credit card expiration date.
  - `billing_address` Address
    - `address` string, required
    - `address2` string
    - `city` string, required
    - `state` string, required
    - `zip` string, required
    - `country` string, required
  - `payer` Payer
    - `ccnumber` string, required
    - `code` string, required — CVV code.
    - `expire_month` integer — Expiration month (1-12).
    - `expire_year` integer — Expiration year (four-digit year, e.g. 2018).

## Response `200`

Successfully created transaction

- Response
  - `code` integer, required
  - `data` object, required
  - `account_id` integer, required

## Other responses

- `400` — Error processing transaction
- `403` — No permissions

---

[API](https://skmtc.net/ontraport/apis/ontraport-api.md) · [All operations](https://skmtc.net/ontraport/apis/ontraport-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/ontraport/ontraport-api/revisions/edcd035d71f5/schema)
