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

KeyValue
typetransactions
idUUID
Attributes
transaction-typecredit or debit
amountInteger
precision*Integer
currencyString
memoString
statusString
payment-methodPaymentMethod
metadataMetadata
created-atTimestamp
updated-atTimestamp
Relationships
accountAccountRelationship
profileProfileRelationship

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

KeyValue
typetransactions
Required
Attributes
transaction-typecredit or debit
Required
amountInteger
Required
precisionInteger
Required
currencyString
Required
memoString
Required
payment-methodPaymentMethod
metadataMetadata
Relationships
profileProfileRelationship
Required
accountAccountRelationship

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

KeyValue
typetransactions
Required
idUUID
Required
Attributes
metadataMetadata

UpdateTransactionRequest Example

{
  "data": {
    "type": "transactions",
    "id": "4c72784e-fb2a-4858-8067-95b6e36d54c0",
    "attributes": {
      "metadata": {
        "key": "new value"
      }
    }
  }
}

PaymentMethod

KeyValue
typecash or bank_transfer or bank_redirect
Required
optionsPaymentMethodOptions

PaymentMethod Example

{
  "type": "cash",
  "options": {
    "identifier": "1234567890",
    "completion_redirect_url": "https://example.com/payment-complete",
    "error_redirect_url": "https://example.com/payment-error"
  }
}

PaymentMethodOptions

KeyValueRequired
identifierString
completion_redirect_urlString
error_redirect_urlString

PaymentMethodOptions Example

{
  "identifier": "1234567890",
  "completion_redirect_url": "https://example.com/payment-complete",
  "error_redirect_url": "https://example.com/payment-error"
}

GET/v1/transactions

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

Request

GET
/v1/transactions
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"
  }
}

POST/v1/transactions

Create a Transaction

This endpoint creates a new Transaction.

This endpoint accepts a CreateTransactionRequest object and returns a TransactionResponse object.

Request

POST
/v1/transactions
  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}"
          }
        }
      }
    }
  }
}

GET/v1/transactions/:id

Show a Transaction

This endpoint retrieves a transaction by its ID.

This endpoint returns a TransactionResponse object.

Request

GET
/v1/transactions/:id
    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}"
          }
        }
      }
    }
  }
}

PUT/v1/transactions/: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

PUT
/v1/transactions/4c72784e-fb2a-4858-8067-95b6e36d54c0
  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}"
          }
        }
      }
    }
  }
}

Was this page helpful?