Create a Transaction

POST https://api.chartmogul.com/v1/import/invoices/{INVOICE_UUID}/transactions

Creates a transaction for a specified invoice.

curl -X POST "https://api.chartmogul.com/v1/import/invoices/inv_565c73b2-85b9-49c9-a25e-2b7df6a677c9/transactions" \
     -u YOUR_API_KEY: \
     -H "Content-Type: application/json" \
     -d '{
            "type": "refund",
            "date": "2022-12-25 18:10:00",
            "result": "successful",
            "external_id": "trans_00241"
         }'
customer = ChartMogul::Customer.all(external_id: "cus_0001").first
transaction = ChartMogul::Transactions::Refund.create!(
  invoice_uuid: "inv_565c73b2-85b9-49c9-a25e-2b7df6a677c9",
  date: Time.utc(2022, 12, 25, 18, 10),
  result: "successful",
  external_id: "trans_00241",
)
ChartMogul.Transaction.create(
  config,
  "inv_565c73b2-85b9-49c9-a25e-2b7df6a677c9",
  {
    type: "refund",
    date: "2022-12-25 18:10:00",
    result: "successful",
    external_id: "trans_00241",
  }
);
ChartMogul\Transactions\Refund::create([
  "invoice_uuid" => "inv_565c73b2-85b9-49c9-a25e-2b7df6a677c9",
  "date" => "2022-12-25 18:10:00",
  "result" => "successful",
  "external_id" => "trans_00241"
]);
api.CreateTransaction(&cm.Transaction{
  Type:   "refund",
  Date:   "2022-12-25 18:10:00",
  Result: "successful",
  ExternalID: "trans_00241",
}, "inv_565c73b2-85b9-49c9-a25e-2b7df6a677c9")
chartmogul.Transaction.create(
  config,
  uuid="inv_565c73b2-85b9-49c9-a25e-2b7df6a677c9",
  data={"type": "refund", "date": "2022-12-25 18:10:00", "result": "successful", "external_id": "trans_00241"},
)
{
  "uuid": "tr_325e460a-1bec-41bb-986e-665e38a1e4cd",
  "external_id": "trans_00241",
  "type": "refund",
  "date": "2022-12-25T18:10:00.000Z",
  "result": "successful",
  "amount_in_cents": null,
  "transaction_fees_in_cents": null,
  "transaction_fees_currency": null,
  "disabled": false,
  "disabled_at": null,
  "disabled_by": null,
  "user_created": true
}
#<ChartMogul::Transactions::Refund:0x007fb499222a40 
  @uuid="tr_325e460a-1bec-41bb-986e-665e38a1e4cd",
  @external_id="trans_00241",
  @type="refund",
  @date=2022-12-25 18:10:00 UTC,
  @result="successful"
>
{
  uuid: "tr_325e460a-1bec-41bb-986e-665e38a1e4cd",
  external_id: "trans_00241",
  type: "refund",
  date: "2022-12-25T18:10:00.000Z",
  result: "successful"
}
ChartMogul\Transactions\Refund::__set_state(array(
  "type" => "refund",
  "uuid" => "tr_325e460a-1bec-41bb-986e-665e38a1e4cd",
  "date" => "2022-12-25T18:10:00.000Z",
  "result" => "successful",
  "external_id" => "trans_00241"
));
(*chartmogul.Transaction)(0xc04201a600)({
  UUID: (string) (len=39) "tr_325e460a-1bec-41bb-986e-665e38a1e4cd",
  Date: (string) (len=24) "2022-12-25T18:10:00.000Z",
  ExternalID: (string) (len=11) "trans_00241",
  Result: (string) (len=10) "successful",
  Type: (string) (len=6) "refund",
  Errors: (chartmogul.Errors) chartmogul: map[]
})
<Transaction{
  date=datetime.datetime(2022, 12, 25, 18, 10),
  external_id="trans_00241",
  result="successful",
  type="refund",
  uuid="tr_325e460a-1bec-41bb-986e-665e38a1e4cd"
}>

Path parameters

invoice_uuid string required
The ChartMogul UUID of the Invoice.

Query parameters

handle_as_user_edit boolean optional default: false
Valid only for automatic sources (Stripe, Chargebee, Recurly, Braintree); ignored for others.
true — The transaction is stored as a user edit and persists through resyncs and reimports.
false — The transaction is treated as system-generated and may be overwritten or removed during resyncs and reimports.

Body parameters

external_id string optional
A unique identifier specified by you for the transaction. Typically an identifier from your internal system. Accepts alphanumeric characters.
Required when creating a transaction as a user edit using handle_as_user_edit in automatic sources like Stripe, Chargebee, Recurly and Braintree.
type string required
Either payment or refund.
date string required
The timestamp of when the transaction was attempted. Must be an ISO 8601-formatted time. The timezone defaults to UTC unless otherwise specified. The time defaults to 00:00:00 unless specified otherwise.
result string required
Either successful or failed depending on the result of this attempted transaction.
amount_in_cents int32 optional
The partial amount in cents (or pence for GBP, etc.) paid/refunded for this invoice. Defaults to the full amount. The sum of the partial payments/refunds should not exceed the invoiced amount.
transaction_fees_in_cents int32 optional default: 0
The amount of transaction fees in cents (or pence for GBP, etc.). Defaults to zero.
transaction_fees_currency string optional
The three-letter currency code for transaction_fees_in_cents, e.g. USD, EUR, GBP. Refer to the full list of supported currencies.

Response

The response object contains the following data:

uuid
The UUID of the transaction object generated by ChartMogul.
external_id
The unique external identifier for this transaction, as specified by you.
type
One of payment or refund, as specified by you.
date
The timestamp of when the transaction was attempted, as specified by you.
result
The result of the transaction attempt. One of successful or failed, as specified by you.
amount_in_cents
The amount partially paid/refunded for this transaction.
transaction_fees_in_cents
The final total transaction fees paid to a billing provider and/or payment processor for this line item. Expressed in cents (or pence for GBP, etc.).
transaction_fees_currency
The three-letter currency code for transaction_fees_in_cents. Refer to the full list of supported currencies.
disabled
A boolean stating whether or not the transaction was disabled.
disabled_by
The email address of the user who disabled the transaction (null for non-disabled records).
disabled_at
The date and time when the transaction was disabled (null for non-disabled records).
user_created
A boolean stating whether or not the transaction was created by the user for sources like Stripe, Chargebee, Recurly and Braintree (the latest version of the integration).