Payment Related
This document covers all services for payment-related checkout, including the requests and responses associated with these services.
NOTE
Authenticated Endpoints
Accessing authenticated endpoints requires users to establish a session through Session Authentication. To do this:
- Users must log in using their credentials (e.g., username and password) via a designated authentication endpoint.
- Upon successful login, the server will generate and return a session cookie to the client.
- This session cookie must be included in subsequent API requests as part of the headers. The session cookie serves as proof of authentication and ensures secure access to protected resources.
GET
Available Payment Options
This method is used to get a list for all available payment options.
Path: https://{commerce_url}/orders/checkout/?page=PaymentOptionSelectionPage
The following payment_option
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'
Example Request
import requests
url = "https://{commerce_url}/orders/checkout/?page=PaymentOptionSelectionPage"
payload = 'payment_option=credit_card'
headers = {
'x-requested-with': 'XMLHttpRequest',
'Cookie': 'osessionid=<session_id>',
'Content-Type': 'application/x-www-form-urlencoded'
}
response = requests.request("GET", url, headers=headers, data=payload)
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": {...}
}
POST
Set Payment Option
This method is used to set the selected payment option to the current pre-order.
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
Example Request
import requests
url = "https://{commerce_url}/orders/checkout/?page=PaymentOptionSelectionPage"
payload = 'payment_option=credit_card'
headers = {
'x-requested-with': 'XMLHttpRequest',
'Cookie': 'osessionid=<session_id>',
'Content-Type': 'application/x-www-form-urlencoded'
}
response = requests.request("POST", url, headers=headers, data=payload)
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": {...}
}
POST
Set Payment Choice
This method is used to set the selected payment option (Pay on Delivery) to the current pre-order.
Path: https://{commerce_url}/orders/checkout/?page=PayOnDeliveryPaymentChoicePage
The endpoint result may vary depending on "sms verification", "Pay on Delivery" configuration option.
Example Request
import requests
url = "https://{commerce_url}/orders/checkout/?page=PayOnDeliveryPaymentChoicePage"
payload = 'payment_choice=cash'
headers = {
'x-requested-with': 'XMLHttpRequest',
'Cookie': 'osessionid=<session_id>',
'Content-Type': 'application/x-www-form-urlencoded'
}
response = requests.request("POST", url, headers=headers, data=payload)
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": {...}
}
POST
SMS Verification
This method is used to set the verification code for SMS verification.
Path: https://{commerce_url}/orders/checkout/?page=VerifySmsPage
Example Request
import requests
url = "https://{commerce_url}/orders/checkout/?page=VerifySmsPage"
payload = 'verify_code=123456'
headers = {
'x-requested-with': 'XMLHttpRequest',
'Cookie': 'osessionid=<session_id>',
'Content-Type': 'application/x-www-form-urlencoded'
}
response = requests.request("POST", url, headers=headers, data=payload)
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": {...}
}
GET
Created Order Information
This method is used to get created order information from pre-order.
Path: https://{commerce_url}/orders/checkout/?page=ThankYouPage
Example Request
import requests
url = "https://{commerce_url}/orders/checkout/?page=ThankYouPage"
payload = {}
headers = {
'x-requested-with': 'XMLHttpRequest',
'Cookie': 'osessionid=<session_id>'
}
response = requests.request("GET", url, headers=headers, data=payload)
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": {...}
}