Skip to main content

API

Response Formats

Although the response parameters of the Craftgate API differ depending on whether the transaction is successful and whether a single or multiple result is returned, they use a common framework among themselves.

Failed Transactions

It is the return format used when a systematic or fictional error occurs. It only contains a field named errors that contains error information.

errors
Error

Contains information about the error that occurred. For detailed information, see: Payment Error Groups

errorCode
string

The unique code for the error

errorDescription
string

Explanatory message that mentions the attribute of the error

errorGroup
string

(see: Payment Error Groups) Error group sent in case of an error is occurred that is payment related

Successful Transactions

Responses given as a result of successful transactions contain different parameters depending on whether the transaction result is singular or plural.

Single Result Transactions

It is the return format used for transactions or queries that produce single results, such as receiving payment, returning payment, creating a buyer, viewing merchant details. It only contains a field named data that contains the result of the transaction.

data
any

The result of the operation or query performed. Structure and contents are detailed on the documentation page for the relevant transaction or query.

Sample: Example of a forwarded response for the detail of a payment:

{
"data": {
"id": 5,
"createdDate": "2021-11-15T14:07:18",
"price": 100.00000000,
"paidPrice": 100.00000000,
...
}
}

Multiple Result Transactions

It is the answer format that is returned as a result of transactions or queries that have the potential to produce multiple results, such as search or listing.

items
any[]

It contains the results retrieve as a result of the operation or query. The structure and contents of the results are detailed on the documentation page for the relevant transaction or query.

totalSize
number

Returned as a result of operations with pagination such as search or listing. It refers to the total number of results reached as the result of the query. This field is not included in the return of failed transactions.

size
number

It is returned as a result of operations with pagination such as search or listing. Indicates the number of results to exist per page in the query. This field is not included in the return of failed transactions.

page
number

It is returned as a result of operations with pagination such as search or listing. Indicates the number of page in query. This field is not included in the return of failed transactions.

Sample: Example of response when the list of payments is requested:

{
"data": {
"items": [
{
"id": 5,
"createdDate": "2021-11-15T14:07:18",
...
},
{
"id": 4,
"createdDate": "2021-11-15T14:07:18",
...
},
{
"id": 3,
"createdDate": "2021-11-15T14:07:18",
...
}
],
"page": 0,
"size": 25,
"totalSize": 3
}
}

No result transactions

A blank response may be given as a result of ineffective transactions such as deleting a stored card. Although such transactions are quite rare, it is recommended to act with the expectation that no response will be given in deletion transactions. On the other hand, since these answers can be returned with 204 No Content HTTP code and this code indicates successful transactions, it is not recommended to only check if the status code is 200 OK when checking whether the request is successful.

Constants and Enum Values

Some constants and enum values used as request and response parameters of different transactions are listed under this heading.

General

Status

Status that can be used when communicating with the Craftgate API:

ValueDescription
ACTIVEActive, represents records that available to be used
PASSIVEPassive, represents records that not available to be used

Currencies

Currencies that can be used when communicating with the Craftgate API:

ValueDescription
TRYTurkish Lira
USDU.S. Dollar
EUREuro
GBPBritish Pound
CNYChinese Yuan
ARSArgentine Peso
BRLBrazilian Real
AEDUnited Arab Emirates Dirham
IQDIraqi Dinar
AZNAzerbaijani Manat
KZTKazakhstani Tenge

Card Types

Types expressing the configuration of the use of card:

ValueDescription
CREDIT_CARDCredit card
DEBIT_CARDDebit card
PREPAID_CARDPrepaid card

Member

Member Types

ValueDescription
PERSONALPersonal member
PRIVATE_COMPANYPrivate Company member
LIMITED_OR_JOINT_STOCK_COMPANYLimited or joint stock company member

Payout Destinations

ValueDescription
IBANIBAN
WALLETMember wallet

Payout Merchant Types

ValueDescription
MERCHANTMerchant
SUB_MERCHANT_MEMBERSub merchant member

Payout Transaction Types

ValueDescription
PAYMENTPayout for payments
WITHDRAWPayout for withdraws
RASPayout for refund after settlement

Payout Return Status

ValueDescription
NOT_BOUNCEDThe first value that occurs when money is sent. It means that the money transfer is sent on the first try.
BOUNCEDThe status that occurs when the money transfer is marked as returned.
UPDATEDThe status that occurs when the sub-merchant information is updated together with the Name / Surname / Iban information that is the subject of money transfer.
PAYOUT_STARTEDThe status that occurs when sending money again for a returned transaction.
PAYOUT_COMPLETEDThe status that occurs after the money transfer is made again for a returned transaction.

Payments

Payment Types

Values expressing the way a payment is collected:

ValueDescription
CARD_PAYMENTPayment fully deducted from card
DEPOSIT_PAYMENTTop-up payment from card
WALLET_PAYMENTPayment fully deducted from wallet
CARD_AND_WALLET_PAYMENTPayment, some of which is debited from a card and some from a wallet
BANK_TRANSFERBank transfer

Payment Groups

Group names expressing the product or service to which the payment is done:

ValueDescription
PRODUCTProduct
LISTING_OR_SUBSCRIPTIONAd, listing, service or subscription

Payment Status

Values expressing the status of the payment:

ValueDescription
FAILUREPayment is failed
SUCCESSPayment is successful
INIT_THREEDS3D Secure payment is initiated.
CALLBACK_THREEDSAfter entering the sms code on the bank's 3D Secure SMS page, the transaction is waiting by Craftgate. In this case, Craftgate is waiting for buyer return to the callback address of merchant and complete the payment.

Payment Item Confirmation Status

Values expressing approval status for a payment item

ValueDescription
WAITING_FOR_APPROVALAwaiting approval
APPROVEDApproved

Payment Phases

Transaction type/phase of the payment at the bank:

ValueDescription
AUTHIn standard provision transaction, the payment is set as this status value.
PRE_AUTHIf a Pre-authorization is made, the payment phase takes this value. In the pre-authorization process, the payment is not withdrawn directly, the relevant amount is blocked on the user's card by the bank during the provisioning period.
POST_AUTHIn case of capture for a pre-authorized transaction, the payment phase takes this value.

Payment Methods

Users can pay below methods from Common Payment Page/Form;

DeğerAçıklama
CARDUser pays with card
MASTERPASSUser pays with own Masterpass account
PAPARAUser pays with own Papara account
PAYONEERUser pays with own Payoneer account
PLUXEEUser pays with own Pluxee card
EDENREDUser pays with own Edenred card
EDENRED_GIFTUser pays with own Edenred gift card
PAYPALUser pays with own PayPal account
AFTERPAYUser pays with own Afterpay account
KLARNAUser pays with own Klarna account
STRIPEUser pays with own Stripe account

Payout Status

Values expressing the Payout status:

ValueDescription
NO_PAYOUTMoney transfer will not be done
WAITING_FOR_PAYOUTWaiting for money transfer
PAYOUT_STARTEDMoney transfer started
PAYOUT_COMPLETEDMoney transfer completed

Payout Types

Values expressing Payout Types:

ValueDescription
SETTLEMENTRepresents money transfers due to Payment/Cancellation/Return transactions
BOUNCED_SETTLEMENTRepresents a money transfer to resend transactions that have been refunded for some reason after the money has been sent
WITHDRAWRepresents money transfers based on sub-merchants' wallet balance withdrawal requests

Payout Source

Values expressing the Payout Source:

ValueDescription
COLLECTIONRepresents money transfers due to Payment/Cancellation/Return transactions
BOUNCEDRepresents a money transfer to resend transactions that have been refunded for some reason after the money has been sent
WITHDRAWRepresents money transfers based on your sub-merchants' wallet balance withdrawal requests

MD Status

These are the numerical values transmitted to Craftgate by the bank after verification for payments made with 3D Secure. Although banks and payment institutions sometimes return with their unique MD Status figures, the values in the table below can be accepted as standard.

MD StatusDescription
03D Secure verification or signature invalid
1Full Verification, processing can be continued
2Card holder or bank not registered in the system
3The bank of the card is not registered in the system
4Verification attempt, cardholder has chosen to register later in the system
5Unable to verify
63D Secure error
7System error

Payment Sources

Indicates which type of integration a payment is coming from.

ValueDescription
APIvia API
MASTERPASSvia Masterpass
CHECKOUT_FORMvia Common Payment Form

Alternative Payment Methods

Alternative Payment Methods which are supported by Craftgate

DeğerAçıklama
PAPARAPapara
PAYONEERPayoneer
PLUXEEPluxee
EDENREDEdenred
EDENRED_GIFTEdenred Gift Card
PAYPALPayPal
KLARNAKlarna
AFTERPAYAfterpay
STRIPEStripe

Offline Alternative Payment Methods

Offline Alternative Payment Methods which are supported by Craftgate

DeğerAçıklama
FUND_TRANSFERPay with Fund Transfer
CASH_ON_DELIVERYCash on Delivery

Additional Actions Of Alternative Payment Methods

Additional Action of Alternative Payment Methods which are supported by Craftgate

DeğerAçıklama
REDIRECT_TO_URLRedirect the user to the url
OTP_REQUIREDOTP verification code is required
SHOW_HTML_CONTENTRender returning HTML at the screen
WAIT_FOR_WEBHOOKWait for Webhook message from Craftgate
APPROVAL_REQUIREDApprove is required to complete flow
NONEThere is no additional action

Category Codes

DeğerAçıklama
MOBILE_PHONE_PRICE_ABOVE_REGULATION_LIMITMobile phone whose price is above regulation limit
MOBILE_PHONE_PRICE_BELOW_REGULATION_LIMITMobile phone whose price is below regulation limit
TABLETTablet
COMPUTERComputer
CONSTRUCTION_MARKETConstruction Market
GOLDGold
DIGITAL_PRODUCTSDigital Products
SUPERMARKETSupermarket
WHITE_GOODSWhite Goods
WEARABLE_TECHNOLOGYWearable Technology
SMALL_HOME_APPLIANCESSmall Home Appliances
TVTv
GAMES_CONSOLESGames Consoles
AIR_CONDITIONER_AND_HEATERAir Conditioner & Heater
ELECTRONICSElectronics
ACCESSORIESAccessories
MOM_AND_BABY_AND_KIDSMom & Baby & Kids
SHOESShoes
CLOTHINGClothing
COSMETICS_AND_PERSONAL_CARECosmetics & PersonalCare
FURNITUREFurniture
HOME_LIVINGHome Living
AUTOMOBILE_MOTORCYCLEAutomobile Motorcycle
OTHEROther

Reward Types

Indicates the type of rewards provided by the bank.

ValueDescription
REWARD_MONEYReward/Point Usage
ADDITIONAL_INSTALLMENTAdditional Installment
POSTPONING_INSTALLMENTPostpone Installment
EXTRA_POINTSExtra point
GAINING_MINUTESGaining minutes
POSTPONING_STATEMENTStatement Postponement

Refunds

Refund Status Types

Values that express the status of a refund.

ValueDescription
SUCCESSSuccessful refund
FAILUREFailed refund

Refund Status Types of Payment

Values that represent the refund status of a payment.

ValueDescription
NO_REFUNDPayment not successful
NOT_REFUNDEDPayment has no refund
PARTIAL_REFUNDEDPartially refunded
FULLY_REFUNDEDFully refunded

Refund Types

Values that indicate where a refund amount will be refunded.

ValueDescription
PROVIDERTo Provider (Card or APM)
WALLETTo Wallet

Money Transfer

Money Transfer Request Result Status

It is the value that expresses the result of receiving a money transfer request.

ValueDescription
SUCCESSMoney transfer completed successfully.
FAILUREMoney transfer failed.
NO_RECORD_FOUNDNo record found to send money

Transferring/Withdrawing Money from/to Wallet

Types of Wallet Transfer/Withdrawal

The reasons for sending money to the member defined by the merchant in the Craftgate system.


The default figure for a standard merchant is REDEEM_ONLY_LOYALTY. If sent optionally, REDEEM_ONLY_LOYALTYfigure should be sent.
ValueDescription
REDEEM_ONLY_LOYALTYThe type that can be used within the scope of loyalty programs. This type of money sent to the member can only be spent within the system by the member.

Daily Transaction Report

Daily Transaction Report File Types

ValueDescription
CSVComma Separated Values file extension.
XLSXExcel file extension.

Signature Calculation

Any direct request to the Craftgate APIs must be authenticated using the merchant account's access keys. You can see the access keys of the merchant via Merchant Panel.

If you are using Craftgate Client, it will be sufficient to give the access keys information to the Craftgate object as a parameter. If you are not using a client, the following steps are obligatory to perform.

To do the authentication of your merchant account, you must send the following headers in every request you make to API Gateway:

Header NameDescription
x-api-keyAPI access key
x-rnd-keyCustom generated random string value
x-auth-versionThe version number of the authentication algorithm. If you are not sure what value you should give, you can give V1
x-signatureSignature created using the above parameters, secret access password and some information specific to the request.
For more information, see: Signature Calculation Algorithm

Signature Calculation Algorithm

A signature is a validation value used to verify that the request comes from the right source. Since it is specific to the request, it must be recalculated and sent with every request. To calculate the signature figure:

  • The following figures are merged
    • Raw URL of the request (including hostname, protocol and query string)
    • API access key (API Key) of the merchant account
    • The secret key of the merchant account
    • A string randomly generated upon request
    • The body of the request, if available
  • Calculate the SHA-256 hash of the concatenated string (Please note that the SHA-256 output should be digest (bytes) and the byte encoding should be UTF-8.)
  • Calculate Base64-encrypted hash

If you want to calculate the signature for the requests you send to the Craftgate Sandbox, the information used should include the information used for the sandbox account. In other words, https://sandbox-api.craftgate.io, which is the sandbox api url in the url, api key and secret key information of your sandbox account. In the live environment, this information should belong to your live account. That is, https://api.craftgate.io, which is the api url of the live system in the url, and the api key and secret key of your live account.

Make sure that the encoding of the payload content does not change during the calculation. If it changes, you will get the error "Signature is not equal!" because it will be different in the payload and different in the computed data.

For the details of the algorithm, you can check the codes below for our clients.

Sample 1

Parameters
NameValue
Request URLhttps://api.craftgate.io/onboarding/v1/members/1
Request Body-
API Keykey-1
Secret KeyFooBar123!
Random KeyXa15Fp11T
Signature Calculation
  • Full URL:
    https://api.craftgate.io/onboarding/v1/members/1
  • Query String: -
  • API Key:
    key-1
  • Secret Key:
    FooBar123!
  • Random Key:
    Xa15Fp11T
  • Request Body: -
  • Concatenated String:
    https://api.craftgate.io/onboarding/v1/members/1key-1FooBar123!Xa15Fp11T
  • Signature:
    y1TtnjNCJEvlkP5ufCkK3H0i2guMB/bKL4Ayw3VlKWA=
Headers to be Added on Request:
NameValue
x-api-keykey-1
x-rnd-keyrGciw1df
x-auth-versionV1
x-signaturey1TtnjNCJEvlkP5ufCkK3H0i2guMB/bKL4Ayw3VlKWA=

Sample 2

Parameters
NameValue
Request URLhttps://api.craftgate.io/onboarding/v1/members
Request Body{"email": "haluk.demir@example.com","name": "Haluk Demir","phoneNumber": "905551111111","address": "Beylerbeyi Cad. Lale Sok. No: 38 Daire: 3 Üsküdar","contactName": "Haluk","contactSurname": "Demir","memberExternalId": "0ac49f08-f2a9-4326-a4d8-f6c1b01596fb"}
API Keykey-1
Secret KeyFooBar123!
Random KeyXa15Fp11T
Signature Calculation
  • Full URL:
    https://api.craftgate.io/onboarding/v1/members
  • Query String: -
  • API Key: key-1
  • Secret Key:
    FooBar123!
  • Random Key:
    Xa15Fp11T
  • Request Body:
    {"email": "haluk.demir@example.com","name": "Haluk Demir","phoneNumber": "905551111111","address": "Beylerbeyi Cad. Lale Sok. No: 38 Daire: 3 Üsküdar","contactName": "Haluk","contactSurname": "Demir","memberExternalId": "0ac49f08-f2a9-4326-a4d8-f6c1b01596fb"}
  • Concatenated String:
    https://api.craftgate.io/onboarding/v1/memberskey-1FooBar123!Xa15Fp11T{"email": "haluk.demir@example.com","name": "Haluk Demir","phoneNumber": "905551111111","address": "Beylerbeyi Cad. Lale Sok. No: 38 Daire: 3 Üsküdar","contactName": "Haluk","contactSurname": "Demir","memberExternalId": "0ac49f08-f2a9-4326-a4d8-f6c1b01596fb"}
  • Signature:
    nv8y2bSnFjYNRzVRqzkHTK5RXKuN04hoK6fLE2+nzTw=
Headers to be Added on Request:
NameValue
x-api-keykey-1
x-rnd-keyXa15Fp11T
x-auth-versionV1
x-signaturepYuONv7/IgM14OAuSoANWUUgfVSwRX3bYeSZLXltb04=