Payment Related
This document covers all services for payment-related checkout, including the requests and responses associated with these services.
Get Available Payment Options
This method is used to get a list for all available payment options.
GET
Get-Available-Payment-Options
Path: https://{commerce_url}/orders/checkout/?page=PaymentOptionSelectionPage
The following payment options are currently available:
credit_card => 'Credit Card'
funds_transfer => 'Funds Transfer'
pay_on_delivery => 'Pay On Delivery'
bkm_express => 'BKM Express'
loyalty_money => 'Store Credit'
cash_register => 'Cash Register'
gpay => 'Garanti Pay'
redirection => "Redirect to Bank"
stored_card => 'Stored Card'
masterpass => 'Masterpass'
credit_payment => 'Credit Payment'
saved_card => 'Saved Card'
pay_later => 'Pay Later'
confirmation => 'Confirmation From User'
Requirement Authorization Token
Request Body
{
"payment_option": "credit_card",
}
Example Request
import requests
import json
url = "https://{commerce_url}/orders/checkout/?page=PaymentOptionSelectionPage"
headers = {
'Authorization': 'Token <token>',
'Content-Type': 'application/json'
}
response = requests.get(url, headers=headers)
print(response.text)
Example Response
{
"context_list": [
{
"page_context": {
"checkout_url": "https://{commerce_url}/checkout-with-token/<UNIQUE_CHECKOUT_TOKEN>",
"status_url": "https://{commerce_url}/checkout-with-token/<UNIQUE_CHECKOUT_TOKEN>/status/",
"payment_options": [
{
"pk": 1,
"name": "credit_card",
"slug": "credit_card",
"payment_type": "credit_card",
"payment_type_label": "Credit Card",
}
],
"unavailable_options": [
{
"name": "Redirect to Bank",
"slug": "redirection",
"payment_type": "redirection",
"payment_type_label": "Redirect to Bank",
"error_code": 1000,
"error_message": "Some error message about why the option is not available.",
}
]
},
"page_name": "PaymentOptionSelectionPage",
"page_slug": "PaymentOptionSelectionPage"
}
],
"template_name": "orders/checkout.html",
"errors": null,
"pre_order": {...}
}
Set Payment Option
This method is used to set the selected payment option to the current pre-order.
POST
Set-Payment-Option
Path: https://{commerce_url}/orders/checkout/?page=PaymentOptionSelectionPage
The endpoint result may vary depending on the selected payment option. Thus, the next page could be one of the following:
- BinNumberPage
- FundsTransferChoicePage
- BexSelectionPage
- LoyaltyMoneyPage
- CashRegisterPage
- PaySelectionPage
- RedirectionPaymentSelectedPage
- MobilExpressSelectionPage
- MasterpassBinNumberPage
- CreditPaymentSelectionPage
- PayLaterCompletePage
- SavedCardSelectionPage
- ConfirmationPaymentAgreementCheckPage
Requirement Authorization Token
Request Body
{
"payment_option": "credit_card",
}
Example Request
import requests
import json
url = "https://{commerce_url}/orders/checkout/?page=PaymentOptionSelectionPage"
data = {
"payment_option": "credit_card",
}
headers = {
'Authorization': 'Token <token>',
'Content-Type': 'application/json'
}
response = requests.post(url, headers=headers, data=data)
print(response.text)
Example Response
{
"context_list": [
{
"page_context": {
// page_context differs according to the payment option selection
// explained in payment strategy related documentation
},
"page_name": "PaymentOptionSelectionPage",
"page_slug": "PaymentOptionSelectionPage"
}
],
"template_name": "orders/checkout.html",
"errors": null,
"pre_order": {...}
}
Example Response - Pay on Delivery
When the user selects "Pay on Delivery" as the payment option, the following endpoint response is returned.
{
"context_list": [
{
"page_context": {
"payment_choices": [
{
"label": "Kredi Karti",
"sku": "00001",
"value": "credit_card"
},
{
"label": "Pesin",
"sku": "00002",
"value": "cash"
}
]
},
"page_name": "PayOnDeliveryPaymentChoicePage",
"page_slug": "PayOnDeliveryPaymentChoicePage"
}
],
"template_name": "orders/checkout.html",
"errors": null,
"pre_order": {...}
}
Set Payment Choice
This method is used to set the selected payment option (Pay on Delivery) to the current pre-order.
POST
Set-Payment-Choice
Path: https://{commerce_url}/orders/checkout/?page=PayOnDeliveryPaymentChoicePage
The ndpoint result may vary depending on "sms verification", "Pay on Delivery" configuration option.
Requirement Authorization Token
Request Body
{
"payment_choice": "cash",
}
Example Request
import requests
import json
url = "https://{commerce_url}/orders/checkout/?page=PayOnDeliveryPaymentChoicePage"
data = {
"payment_choice": "cash",
}
headers = {
'Authorization': 'Token <token>',
'Content-Type': 'application/json'
}
response = requests.post(url, headers=headers, data=data)
print(response.text)
Example Response - SMS Verification Required
{
"context_list": [
{
"page_context": {
"verification": true,
},
"page_name": "VerifySmsPage",
"page_slug": "VerifySmsPage"
},
],
"template_name": "orders/checkout.html",
"errors": null,
"pre_order": {...}
}
Example Response - SMS Verification Disabled
{
"context_list": [
{
"page_context": {
},
"page_name": "ThankYouPage",
"page_slug": "ThankYouPage"
}
],
"template_name": "orders/checkout.html",
"errors": null,
"pre_order": {...}
}
SMS Verification
This method is used to set the verification code for SMS verification.
POST
SMS Verification
Path: https://{commerce_url}/orders/checkout/?page=VerifySmsPage
Requirement Authorization Token
Request Body
{
"verify_code": "123456",
}
Example Request
import requests
import json
url = "https://{commerce_url}/orders/checkout/?page=VerifySmsPage"
data = {
"verify_code": "123456",
}
headers = {
'Authorization': 'Token <token>',
'Content-Type': 'application/json'
}
response = requests.post(url, headers=headers, data=data)
print(response.text)
Example Response
{
"context_list": [
{
"page_context": {
"verification_sent_datetime": "2023-03-15 15:00:00+00:00",
"seconds_left": 39,
"retry": true,
},
"page_name": "ThankYouPage",
"page_slug": "ThankYouPage"
}
],
"template_name": "orders/checkout.html",
"errors": null,
"pre_order": {...}
}
Created Order Information
This method is used to get created order information from pre-order.
GET
Created-Order-Information
Path: https://{commerce_url}/orders/checkout/?page=ThankYouPage
Requirement Authorization Token
Example Request
import requests
import json
url = "https://{commerce_url}/orders/checkout/?page=ThankYouPage"
headers = {
'Authorization': 'Token <token>',
'Content-Type': 'application/json'
}
response = requests.get(url, headers=headers)
print(response.text)
Example Response
{
"context_list": [
{
"page_context": {
"redirect_url": "https://{commerce_url}/completed/{ORDERNUMBER}",
"order_id": 123,
"order_number": "ON123",
"new_user": false,
"token": "df8a210c-c19d-4497-ad63-494fdea1f1e0",
"campaigns": [
{
"code": "1",
"message": "xyz"
},
],
},
}
],
"template_name": "orders/checkout.html",
"errors": null,
"pre_order": {...}
}