Transactions
Transactions are the core of OpenTransact. They represent a transaction with the entity attached to them via a Profile that is going to be or has already been processed at a Payment Processor. This can be a Credit Card gateway, Bank, EFT transfer network, or other financial institution or payment network.
Data Types
TransactionResponse
Key | Value |
---|---|
type | transactions |
id | UUID |
Attributes | |
transaction-type | credit or debit |
amount | Integer |
precision* | Integer |
currency | String |
memo | String |
status | String |
payment-method | PaymentMethod |
metadata | Metadata |
created-at | Timestamp |
updated-at | Timestamp |
Relationships | |
account | AccountRelationship |
profile | ProfileRelationship |
status
values are: pending
, processing
, processed
, or processing_failed
TransactionResponse Example
{
"data": {
"type": "transactions",
"id": "4c72784e-fb2a-4858-8067-95b6e36d54c0",
"attributes": {
"transaction-type": "credit",
"amount": 100,
"precision": 2,
"currency": "USD",
"memo": "Thank you for your purchase",
"status": "pending",
"metadata": {
"key": "value"
},
"created-at": "2022-06-21T23:34:04Z",
"updated-at": "2022-06-21T23:34:04Z",
"relationships": {
"account": {
"data": {
"type": "accounts",
"id": "4c72784e-fb2a-4858-8067-95b6e36d54c0"
}
},
"profile": {
"data": {
"type": "profiles",
"id": "4c72784e-fb2a-4858-8067-95b6e36d54c0"
}
}
}
}
}
}
CreateTransactionRequest
Key | Value | |
---|---|---|
type | transactions | Required |
Attributes | ||
transaction-type | credit or debit | Required |
amount | Integer | Required |
precision | Integer | Required |
currency | String | Required |
memo | String | Required |
payment-method | PaymentMethod | |
metadata | Metadata | |
Relationships | ||
profile | ProfileRelationship | Required |
account | AccountRelationship |
0
(zero).payment-method
or account
must be provided, but not both.CreateTransactionRequest Example
{
"data": {
"type": "transactions",
"attributes": {
"transaction-type": "credit",
"amount": 100,
"precision": 2,
"currency": "USD",
"memo": "Thank you for your purchase",
"metadata": {
"key": "value"
},
"relationships": {
"profile": {
"data": {
"type": "profiles",
"id": "4c72784e-fb2a-4858-8067-95b6e36d54c0"
}
}
}
}
}
}
UpdateTransactionRequest
UpdateTransactionRequest Example
{
"data": {
"type": "transactions",
"id": "4c72784e-fb2a-4858-8067-95b6e36d54c0",
"attributes": {
"metadata": {
"key": "new value"
}
}
}
}
PaymentMethod
Key | Value | |
---|---|---|
type | cash or bank_transfer or bank_redirect | Required |
options | PaymentMethodOptions |
PaymentMethod Example
{
"type": "cash",
"options": {
"identifier": "1234567890",
"completion_redirect_url": "https://example.com/payment-complete",
"error_redirect_url": "https://example.com/payment-error"
}
}
PaymentMethodOptions
PaymentMethodOptions Example
{
"identifier": "1234567890",
"completion_redirect_url": "https://example.com/payment-complete",
"error_redirect_url": "https://example.com/payment-error"
}
List Transactions
This endpoint retrieves a paginated list of Transactions. By default, a maximum of thirty transactions are shown per page.
This endpoint returns an array of TransactionResponse objects.
Filters
- Name
created_between
- Type
- object
- Description
- See documentation for filtering by timestamps.
- Name
updated_between
- Type
- object
- Description
- See documentation for filtering by timestamps.
- Name
metadata
- Type
- object
- Description
- See documentation for filtering by metadata.
- Name
page
- Type
- object
- Description
- See documentation for pagination.
Request
curl --request GET \
--url 'https://api.opentransact.com/v1/transactions' \
--header 'Authorization: Basic {API_KEY}'
Response
{
"data": [
{
"id": "4c72784e-fb2a-4858-8067-95b6e36d54c0",
"type": "transactions",
"attributes": {
"transaction-type": "credit",
"amount": 100,
"precision": 2,
"currency": "USD",
"memo": "Thank you for your purchase",
"status": "pending",
"metadata": {
"key": "value"
},
"relationships": {
"account": {
"data": {
"type": "accounts",
"id": "4c72784e-fb2a-4858-8067-95b6e36d54c0"
}
},
"profile": {
"data": {
"type": "profiles",
"id": "4c72784e-fb2a-4858-8067-95b6e36d54c0"
}
}
}
}
},
... // more transactions
],
"meta": {
"page-count": 2,
"count": 38,
"current-page": 1,
},
"links": {
"self": "https://api.opentransact.com/v1/transactions?page%5Bnumber%5D=1&page%5Bsize%5D=30",
"first": "https://api.opentransact.com/v1/transactions?page%5Bnumber%5D=1&page%5Bsize%5D=30",
"last": "https://api.opentransact.com/v1/transactions?page%5Bnumber%5D=2&page%5Bsize%5D=30",
"next": "https://api.opentransact.com/v1/transactions?page%5Bnumber%5D=2&page%5Bsize%5D=30"
}
}
Create a Transaction
This endpoint creates a new Transaction.
This endpoint accepts a CreateTransactionRequest object and returns a TransactionResponse object.
Request
curl --request POST \
--url https://api.opentransact.com/v1/transactions \
--header 'Authorization: Basic {API_KEY}' \
--header 'Content-Type: application/vnd.api+json' \
--data '{
"data": {
"type": "transactions",
"attributes": {
"transaction-type": "debit",
"amount": 12,
"precision": 2,
"currency": "USD",
"memo": "Test Withdrawal",
"metadata": {
}
},
"relationships": {
"account": {
"data": {
"id": "{ACCOUNT_ID}",
"type": "accounts"
}
},
"profile": {
"data": {
"id": "{PROFILE_ID}",
"type": "profiles"
}
}
}
}
}'
Response
{
"data": {
"id": "4c72784e-fb2a-4858-8067-95b6e36d54c0",
"type": "transactions",
"attributes": {
"transaction-type": "debit",
"amount": 12,
"precision": 2,
"currency": "USD",
"memo": "Test Withdrawal",
"status": "pending",
"metadata": {
},
"relationships": {
"account": {
"data": {
"type": "accounts",
"id": "{ACCOUNT_ID}"
}
},
"profile": {
"data": {
"type": "profiles",
"id": "{PROFILE_ID}"
}
}
}
}
}
}
Show a Transaction
This endpoint retrieves a transaction by its ID.
This endpoint returns a TransactionResponse object.
Request
curl --request GET \
--url https://api.opentransact.com/v1/transactions/{TRANSACTION_ID} \
--header 'Authorization: Basic {API_KEY}' \
--header 'Content-Type: application/vnd.api+json'
Response
{
"data": {
"id": "4c72784e-fb2a-4858-8067-95b6e36d54c0",
"type": "transactions",
"attributes": {
"transaction-type": "debit",
"amount": 12,
"precision": 2,
"currency": "USD",
"memo": "Test Withdrawal",
"status": "pending",
"metadata": {
},
"relationships": {
"account": {
"data": {
"type": "accounts",
"id": "{ACCOUNT_ID}"
}
},
"profile": {
"data": {
"type": "profiles",
"id": "{PROFILE_ID}"
}
}
}
}
}
}
Update a Transaction
This endpoint allows you to perform an update on a Transaction.
This endpoint accepts an UpdateTransactionRequest object and returns a TransactionResponse object.
Request
curl --request PUT \
--url https://api.opentransact.com/v1/transactions/{TRANSACTION_ID} \
--header 'Authorization: Basic {API_KEY}' \
--header 'Content-Type: application/vnd.api+json' \
--data '{
"data": {
"id": "{TRANSACTION_ID}",
"type": "transactions",
"attributes": {
"metadata": {
"key": "new value"
}
}
}
}'
Response
{
"data": {
"id": "4c72784e-fb2a-4858-8067-95b6e36d54c0",
"type": "transactions",
"attributes": {
"transaction-type": "debit",
"amount": 12,
"precision": 2,
"currency": "USD",
"memo": "Test Withdrawal",
"status": "pending",
"metadata": {
"key": "new value"
},
"relationships": {
"account": {
"data": {
"type": "accounts",
"id": "{ACCOUNT_ID}"
}
},
"profile": {
"data": {
"type": "profiles",
"id": "{PROFILE_ID}"
}
}
}
}
}
}