Creating a Buy Order
The buy order can be initiated either by first creating a quote and then initiating the transaction, or by passing the quote input details along with the transaction initiation request, which will immediately create a quote and execute the transaction.
Please note that if Partner is custodying crypto with Coinme, then externalCustodyCreditInfo can be left blank. If Partner is NOT custodying with Coinme and is sending to an external wallet, then Partner must provide the walletAddress and blockchainMemo (if applicable)
Complete a buy transaction using a specified customerId and quoteId
In this use case, the quote is first created using the Quotes endpoint. The Quotes endpoint will contain a quoteId which then needs to be passed in to initiate a buy transaction. The use case for this is when a partner wishes to first display the quote to the end user and ask for the end user's approval before initiating the transaction, since the quote contains various info, such as fees, coin price, etc.
Sample API Request for BUY with previously created quote: POST
URL: https://caas-staging.coinme.com/services/transaction
headers:
"Authorization":"asdfghj", //authorization token, required
'User-Agent: partnerapi' //required
Request body:
{
"customerId": "654987321", // required
"partnerTransactionId":"34567890", // optional, automatically generated if not provided
"quoteId":"1006491596889587712", // Quote Identifier refering to the specific crypto quote, required
"paymentMethodId": "12345", // optional. required if using Coinme digital payment processing
"externalCustodyCreditInfo": { //Optional, Applicable for BUY flow only, details for sending crypto to external wallet
"walletAddress":"1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa", //required for external crypto deposit
"blockchainMemo":"memo" //optional
},
"tags": "A_TAG", // optional, tags can be used to mark a transaction with unique keywords
"webSessionId": "123123" // optional, field is required only if partner is provisioned to have Coinme digital transaction processing screend by a security provider and only if partner is using a providerId that supports digital payment processing
}
Complete a buy transaction using only customerId
This flow supports a use case where the partner wishes to execute a buy without the end user's explicit approval. In this case, no quote was previously created using the Quotes endpoints. Instead, the information normally passed in the Quotes endpoint is now passed in here and Coinme's system will immediately execute the transaction based on the given inputs.
Sample API Request for BUY without previously created quote: POST
URL: https://caas-staging.coinme.com/services/quote-and-transaction
headers:
"Authorization":"asdfghj", //authorization token,required
'User-Agent: partnerapi' //required
"partnerId": "e4567-e89b-12d3-a456-426614174000",//Unique Identifier to identify the partner, required
Request body:
{
"customerId": "654987321",//required
"partnerTransactionId":"34567890",//optional, automatically generated if not provided
"paymentMethodId": "12345", //optional. required if using Coinme digital payment processing
"externalCustodyCreditInfo": { //Required for BUY flow only if quoteData.cryptoSettlementType is set to EXTERNAL, outlines details for sending crypto to external wallet
"walletAddress":"1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa", //required for external crypto deposit
"blockchainMemo":"memo" //optional
},
"quoteInput": { //details required to create a quote
"debitCurrencyCode":"USD", //required
"creditCurrencyCode":"BTC", //required
"amountValue": "100", //required
"amountCurrencyCode": "USD", //required
"providerId": "451231563453", //optional, should be specified only if fiat settlement is done through Coinme
"cryptoSettlementType": "EXTERNAL" //valid values are INTERNAL and EXTERNAL, specifies if the crypto will be deposited in Coinme's crypto wallet or an external wallet
"chain": "BTC" //optional - if partner is provisioned to use only one chain with the specific crypto, then this parameter is not required. If partner is provisioned to use more than 1 chain for same crypto, then this value is required
},
"tags": "A_TAG", //optional, tags can be used to mark a transaction with unique keywords
"webSessionId": "123123" //optional, field is required only if partner is provisioned to have Coinme digital transaction processing screened by a security provider
}
Sample API Response for BUY:
The same response is returned for both buy with and without previously created quote
Successful Response:
{
"data":
{ "partnerTransactionId":"34567890",
"creditCurrencyUnitPrice":"7.917",
"creditCurrencyUnitPriceCode":"DOGE/USD",
"debitCurrencyUnitPrice":"0.1263104711",
"debitCurrencyUnitPriceCode":"USD/DOGE",
"creditCurrencyAmount":"771.9075",//include the spread
"creditCurrencyCode":"DOGE",
"debitCurrencyAmount":"100",//Amount value requested by User
"debitCurrencyCode":"USD",
"totalFees":"2.5",//exchange fee value
"feeCurrencyCode":"USD", // exchange fee currency code
"feesMap":{
"exchangeFee":"2.5",
"processingFee":"0",
"blockchainFee": "0.4" // present if request for quote had cryptoSettlementType: EXTERNAL
},
"spreadAmount":"0.117",
"spreadCurrencyCode":"USD"
},
"errorResponse": null
}
Failure Response:
{
"data": null,
"errorResponse": {
"httpStatus":"200",
"timestamp":"2022-02-01T18:59:28.297Z",//UTC
"path":"/services/transaction POST",
"errorData": [
{
"errorCode":"123-123-123-123",//The error code is just a sample showing the structure of the error code.
"message":"Invalid QuoteId"
}
]
}
Error Codes
| Error Code | Error Message |
|---|---|
| 280-500-352-000 | Internal error occurred, please try again or contact support |
| 280-400-352-500 | Header/Field cannot be null or empty |
| 280-400-352-502 | Partner transaction id must be a unique non-empty string value |
| 280-400-352-503 | Request is containing duplicate tags |
| 280-404-352-901 | Unable to find quoteId <quote_id> |
| 280-404-352-902 | CustomerId does not match the quoteId |
| 109-412-151-045 | <user tier> Customer would exceed daily sell limit (<error code>). Available amount: <available amount> |
| 280-412-352-903 | SSN is not collected/verified |
| 280-400-352-667 | Required request header <headerName> for method parameter type <typeName> is not present |
| 280-500-352-907 | Unable to resolve quote GPS coordinates |
| 280-500-352-911 | No supported crypto settlement policies were found for partner {partnerId} and provider {providerId}! |
| 280-500-352-912 | Crypto settlement type {type} for order type {order_type}, partner {partnerId} and provider {providerId} is NOT supported! |
| 280-500-352-913 | externalCustodyCreditInfo.walletAddress is required for buy order and EXTERNAL crypto settlement |
| 280-400-352-914 | Wallet address {walletAddress} does not pass trm check |
| 280-400-352-916 | sourceWalletAddress is required for external sell |
Error messages for errors that occur while retrieving quote based on the given quoteId in the request.
| Error Code | Error Message |
|---|---|
| 171-500-201-000 | Internal error occurred, please try again or contact support |
| 171-404-201-905 | Unable to fetch UserQuoteData with id <quote_id>, quote expired or doesn't exist |
Error messages for errors that occur while retrieving partner data:
| Error Code | Error Message |
|---|---|
| 101-500-317-000 | Internal error occurred, please try again or contact support |
| 101-404-317-704 | PartnerProfile resource not found with identifier: <partner_id> |
Error messages for errors that occur while retrieving Customer data:
| Error Code | Error Message |
|---|---|
| 140-500-317-000 | Internal error occurred, please try again or contact support |
| 140-404-317-704 | AccountProfile resource not found with identifier: <account_id> |
Updated about 2 months ago