# Trustap API

The Trustap API is a REST-based API for managing user data and
transactions for Trustap users.

Note that, like Stripe, all API `price` and `charge` fields expect
amounts to be provided in a currency's smallest unit. See [the Stripe
documentation](https://stripe.com/docs/currencies#zero-decimal) for more
details.

API Keys
--------

Some endpoints such as `/charge` endpoints can be accessed directly
using an API key. API keys are provided as the "username" portion of a
basic auth authentication. For example, the Trustap fee for a
transaction can be determined using the following cURL request with an
API key:

``` bash
curl -i -X GET -u '<API_KEY>:' 'https://api.test.trustap.com/v2/fees?currency=usd&amount=896'
```

Deprecation
-----------

Deprecated endpoints have a description that describes what
endpoints/approach should be used instead.

Deprecated endpoints will remain available in the current API version, but
will be removed from subsequent API versions. To ensure a smooth migration
to later API versions, avoid using deprecated endpoints and replace them
with their recommended alternatives when they are deprecated.

Production
----------

This documentation references the staging environment of the Trustap
API, which is available at `https://api.test.trustap.com` and uses the
`trustap-stage` realm during authentication. This environment can be
used for implementing and testing features using test credit cards, bank
accounts, etc.

When all features using Trustap have been implemented and tested
sufficiently, the production environment of the Trustap API can be used
to process actual currency. This environment is available at
`https://api.trustap.com` and uses the `trustap` realm during
authentication.

Note that only your client ID will be the same in the staging and
production Trustap API environments; your client secret and API key will
be different in the two environments.


Version: 2.0.1

## Servers

```
https://api.test.trustap.com
```

## Security

### APIKey

Type: http
Scheme: basic

### OAuth2

Type: oauth2

## Download OpenAPI description

[Trustap API](https://docs.trustap.com/_bundle/apis/@v2.0/openapi.yaml)

## Buyers and Sellers

Users represent users of the platform.


### Create a new guest user

 - [POST /v2/guest_users](https://docs.trustap.com/apis/openapi/buyers-and-sellers/v2_users.createguestuser.md): This endpoint creates a new guest user which can be used as the buyer or
the seller in a transaction. Guest users can be used to create transactions
for users that don't yet have login details, or who choose not to use the
logged-in user for creating the new transaction. Emails are sent to guest
users which will contain details for adding guest transactions to their
logged-in profile.

### Get the status of a user's account completion

 - [GET /v2/users/{user_id}/account_status](https://docs.trustap.com/apis/openapi/buyers-and-sellers/v2_users.getaccountpayoutstatus.md): This endpoint returns the status of the ability of the user identified
by the user_id in the path to accept payouts. It can only be accessed
with an API key.

## Payment

Payment endpoints for transactions.


### Get the Trustap fee for a transaction

 - [GET /v2/fees](https://docs.trustap.com/apis/openapi/payment/v2_transactions.getfees.md): This returns the Trustap fee, in the currency's smallest unit,
for a transaction involving goods with the supplied amount. See
[the Stripe
documentation](https://stripe.com/docs/currencies#zero-decimal)
for more details.

### Accept the payment for a transaction

 - [POST /v2/transactions/{transaction_id}/accept_payment](https://docs.trustap.com/apis/openapi/payment/v2_transactions.acceptpaymentfortransaction.md)

## Transactions

Endpoints for creating and managing transactions.


### Create a new transaction

 - [POST /v2/transactions](https://docs.trustap.com/apis/openapi/transactions/v2_transactions.createtransaction.md): Offline access is allowed for this endpoint.

### Get a transaction by its ID

 - [GET /v2/transactions/{transaction_id}](https://docs.trustap.com/apis/openapi/transactions/v2_transactions.gettransaction.md)

### Get the bank transfer details for a transaction

 - [GET /v2/transactions/{transaction_id}/bank_transfer_details](https://docs.trustap.com/apis/openapi/transactions/v2_transactions.getbanktransferdetails.md): Get the bank transfer details for a transaction with payment method bank_transfer.

### Get the buyer's contact details for a transaction

 - [GET /v2/transactions/{transaction_id}/buyer_details](https://docs.trustap.com/apis/openapi/transactions/v2_transactions.getbuyerdetailsfortransaction.md)

### Cancel a transaction

 - [POST /v2/transactions/{transaction_id}/cancel](https://docs.trustap.com/apis/openapi/transactions/v2_transactions.canceltransaction.md)

### Claim a transaction on behalf of a Trustap user

 - [POST /v2/transactions/{transaction_id}/claim](https://docs.trustap.com/apis/openapi/transactions/v2_transactions.claimtransaction.md): This endpoint enables a client to claim a transaction on behalf of a
Trustap user as a buyer or seller. This endpoint can only be accessed
by clients.

### Add items to a transaction

 - [POST /v2/transactions/{transaction_id}/items](https://docs.trustap.com/apis/openapi/transactions/v2_transactions.addtransactionitems.md): Adds one or more items to a transaction. Items with a
recurring_period are billed automatically on that interval.

### Set metadata for a transaction

 - [POST /v2/transactions/{transaction_id}/metadata](https://docs.trustap.com/apis/openapi/transactions/v2_transactions.settransactionmetadata.md)

## Transaction Issues

Transaction issues endpoints are used for reporting and managing transaction
issues.


### Accept a complaint for this transaction

 - [POST /v2/transactions/{transaction_id}/accept_complaint](https://docs.trustap.com/apis/openapi/transaction-issues/v2_transactions.acceptcomplaintfortransaction.md)

### Submit a complaint for this transaction

 - [POST /v2/transactions/{transaction_id}/submit_complaint](https://docs.trustap.com/apis/openapi/transaction-issues/v2_transactions.submitcomplaintfortransaction.md): A complaint is submitted for problems with transactions after the order
has been shipped or handover has been confirmed. Before that an order
issue should be submitted instead.

### Submit an order issue for this transaction

 - [POST /v2/transactions/{transaction_id}/submit_order_issue](https://docs.trustap.com/apis/openapi/transaction-issues/v2_transactions.submitorderissuefortransaction.md): An order issue is submitted for problems with transactions after payment
confirmation and before the order has been shipped or handover has been
confirmed. After that a complaint should be submitted instead.

## Handover

Endpoint for confirming handover of goods for transactions.


### Confirm the handover of goods for a transaction (deprecated)

 - [POST /v2/transactions/{transaction_id}/confirm_handover](https://docs.trustap.com/apis/openapi/handover/v2_transactions.confirmhandoverfortransaction.md): This endpoint is deprecated. 
Use the confirm delivery for transaction endpoint instead.

## Shipping

Shipping endpoints for transactions.


### Get the supported carriers

 - [GET /v2/carriers](https://docs.trustap.com/apis/openapi/shipping/v2_transactions.getsupportedcarriers.md): This returns the carriers that are currently supported for
automated tracking. The carrier name
should be shown to users but the code should be submitted to
the /track endpoint when submitting tracking details.
Likewise, when showing a transaction to the user, the carrier
field stored with the transaction should be used to index these
carriers and show the human-readable name of the carrier to the
user, if this index is found.

### Confirm delivery for this transaction

 - [POST /v2/transactions/{transaction_id}/confirm_delivery](https://docs.trustap.com/apis/openapi/shipping/v2_transactions.confirmdeliveryfortransaction.md): This endpoint allows a user to confirm the delivery
of the item in the case that the state of the transaction was
not updated asynchronously by Trustap

### Get the shipping details of the buyer for a transaction

 - [GET /v2/transactions/{transaction_id}/shipping_details](https://docs.trustap.com/apis/openapi/shipping/v2_transactions.getshippingdetailsfortransaction.md)

### Post the shipping details of the buyer for a transaction

 - [POST /v2/transactions/{transaction_id}/shipping_details](https://docs.trustap.com/apis/openapi/shipping/v2_transactions.setshippingdetailsfortransaction.md)

### Set postal tracking details for a transaction

 - [POST /v2/transactions/{transaction_id}/track](https://docs.trustap.com/apis/openapi/shipping/v2_transactions.tracktransaction.md): After the tracking information has been submitted then the state
of the transaction will be updated asynchronously by Trustap
once the delivery of the item has been confirmed, at which point
the delivered field of the transaction will be set.

