# 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 are tagged with the word `DEPRECATED` at the start
of their description. The deprecation message will describe what
endpoints/approach should be used instead.

Note that deprecated endpoints will not be removed from the current
version of the API, but their use is discouraged. Furthermore, migrating
to later major versions of the API will be made easier by avoiding
deprecated endpoints.

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.

## 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.

### 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.

### 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)

### End the complaint period for this transaction

 - [POST /v2/transactions/{transaction_id}/end_complaint_period](https://docs.trustap.com/apis/openapi/transaction-issues/v2_transactions.endcomplaintperiodfortransaction.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

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

## 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 the buyer to manually 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.

