Payments
The Omnitron module where the payments and their configurations are stored. POS, Bank,Card, CardType, MultiCurrencyCard, BinNumber, Installment, PaymentOption and BankAccount models are in the payments application. Virtual POS settings to be used on webshop and mobile platforms, management of bank settings, defining new card types and management of their settings, payment options such as credit-card, cash-register etcCredit and debit card settings can be managed using different checkout providers through the payments application.
POS
Stores the settings of the virtual POS you will use on your website or mobile application. It can be accessed from the Sales Channels > Payment Management > Add/Edit POS Integration menu on the Omnitron panel.
Model Structure
Figure 1: POS Model Structure
Location: Omnitron.payments.models.Pos
Inherited from omnicore_project.omnicore.utils.models.IntegrationRelation
and omnicore_project.omnicore.payments.models.BasePos.
Slug and channel make a unique set.
- channel : ForeignKey. The sales channel linked to the relevant POS.
- name : CharField, with a maximum length of 64 characters. The name of the relevant POS visible to the users.
- slug : CharField, with a maximum length of 64 characters. Abbreviation of the relevant POS.
- gateway : EnumField. The pre-defined payment infrastructure on Omnitron that will be used by the relevant POS. The values it can take are:
omnicore.libs.payment_gateways.garanti.GarantiGateway
omnicore.libs.payment_gateways.nestpay.NestpayGateway
omnicore.libs.payment_gateways.cmi.CMIGateway
omnicore.libs.payment_gateways.posnet.PosnetGateway
omnicore.libs.payment_gateways.payu.PayUGateway
omnicore.libs.payment_gateways.mastercard.MastercardGateway
omnicore.libs.payment_gateways.masterpass.MasterpassGateway
omnicore.libs.payment_gateways.bex.BexGateway
omnicore.libs.payment_gateways.hyper_pay.HyperpayGateway
omnicore.libs.payment_gateways.paymentsos.PayUPolandGateway
omnicore.libs.payment_gateways.paymentsos.PayURomaniaGateway
omnicore.libs.payment_gateways.payu_ro.PayuRoGateway
omnicore.libs.payment_gateways.fastpay.FastPayGateway
omnicore.libs.payment_gateways.maximumpay.MaximumPayGateway
omnicore.libs.payment_gateways.liqpay.LiqPayGateway
omnicore.libs.payment_gateways.gpay.GPayGateway
omnicore.libs.payment_gateways.easypay.EasyPayGateway
omnicore.libs.payment_gateways.mobilexpress.MobilExpressGateway
omnicore.libs.payment_gateways.mobilexpress.MobilExpressCreditCardGateway
omnicore.libs.payment_gateways.iyzico.IyzicoGateway
omnicore.libs.payment_gateways.iyzico.IyzicoBKMGateway
omnicore.libs.payment_gateways.finansbank.FinansBankGateway
omnicore.libs.payment_gateways.denizbank.DenizBankGateway
omnicore.libs.payment_gateways.yandex_money.YandexMoneyGateway
omnicore.libs.payment_gateways.paypal.PaypalGateway
omnicore.libs.payment_gateways.alpha.AlphaGateway
omnicore.libs.payment_gateways.dummypay.DummyPayGateway
omnicore.libs.payment_gateways.ykb_credit.YKBCreditGateway
omnicore.libs.payment_gateways.compay.ComPayGateway
omnicore.libs.payment_gateways.compay.ComPayCreditGateway
omnicore.libs.payment_gateways.param.ParamGateway
omnicore.libs.payment_gateways.garanti_switch.GarantiSwitchGateway
omnicore.libs.payment_gateways.iyzico.PayWithIyzicoGateway
omnicore.libs.payment_gateways.tompay.TomPayGateway
omnicore.libs.payment_gateways.iyzico.IyzicoFundsTransferGateway
omnicore.libs.payment_gateways.paycell.PaycellGateway
omnicore.libs.payment_gateways.posas_giftcard.PosAsGiftCardGateway
omnicore.libs.payment_gateways.multisafepay.MultiSafepayGateway
omnicore.libs.payment_gateways.garanti_credit.GarantiCreditGateway
omnicore.libs.payment_gateways.multisafepay.MultiSafepayDirectGateway
omnicore.libs.payment_gateways.ozan.OzanGateway
omnicore.libs.payment_gateways.netopia.NetopiaGateway
omnicore.libs.payment_gateways.teqpay.TeqPayGateway
omnicore.libs.payment_gateways.payu_pl.PayuPLGateway
omnicore.libs.payment_gateways.stripe.StripeGateway
omnicore.libs.payment_gateways.bulut.BulutGateway
omnicore.libs.payment_gateways.fibabank.FibaCreditGateway
omnicore.libs.payment_gateways.mobilexpress_hosted.MobilExpressHostedGateway
omnicore.libs.payment_gateways.paymob.PaymobGateway
omnicore.libs.payment_gateways.tompay_credit.TompayCreditGateway
omnicore.libs.payment_gateways.paytr.PaytrGateway
omnicore.libs.payment_gateways.payzee.PayzeeGateway
omnicore.libs.payment_gateways.mobilexpress_v8.MobilExpressV8CreditCardGateway
- resource_url : URLField. The source URL used by the relevant POS for payment without 3D.
- three_d_resource_url : URLField. The source URL used by the relevant POS for 3D payment.
- config : JSONField. Stores information such as the verification of the relevant POS.
Model Function
Name | Description |
get_gateway(self): | It creates and returns a new object with the class at the gateway selected with the parameters of the POS instance. |
is_payu(self): | Returns whether the selected gateway of the POS instance is Payu. |
is_liqpay(self): | Returns whether the selected gateway of the POS instance is LiqPay. |
is_easypay(self): | Returns whether the selected gateway of the POS instance is EasyPay. |
is_iyzico(self): | Returns whether the selected gateway of the POS instance is İyzico. |
is_finansbank(self): | Returns whether the selected gateway of the POS instance is Finansbank. |
is_dummypay(self): | Returns whether the selected gateway of the POS instance is DummyPay. |
is_masterpass(self): | Returns whether the selected gateway of the POS instance is Masterpass. |
is_nestpay(self): | Returns whether the selected gateway of the POS instance is Nestpay. |
is_denizbank(self): | Returns whether the selected gateway of the POS instance is DenizBank. |
is_posas_giftcard | Returns whether the selected gateway of the POS instance is posas_giftcard. |
is_paypal | Returns whether the selected gateway of the POS instance is paypal. |
is_ozan | Returns whether the selected gateway of the POS instance is ozan. |
is_multisafepaydirect | Returns whether the selected gateway of the POS instance is multisafepaydirect. |
is_paytr | Returns whether the selected gateway of the POS instance is paytr. |
is_payzee | Returns whether the selected gateway of the POS instance is payzee. |
is_mobilexpress_v8_cc | Returns whether the selected gateway of the POS instance is mobilexpress_v8_cc. |
Figure 2: Model Methods and Inheritance Structure
Serializer Structure
Location: omnitron.payments.resources.serializers.PosSerializer
Unlike the model structure, it includes an additional field called "PK," and "gateway_display," which returns the read-only equivalent of the selected gateway.
Figure 3: PosSerializer Structure
Service Structure
Location: omnitron.payments.service.PosService
create_pos
(name, slug, gateway, resource_url, channel, config, three_d_resource_url):- This function is used to create a POS object. First, it verifies that there is no existing record with the same channel and slug. After this verification, it checks whether the entered config is valid on the selected gateway. If no error occurs following this check, the process is completed successfully.
update_pos(
instance, kwargs):- This function is used to update an existing POS. First, it checks the change status of the POS channel to be updated. Changing the sales channels linked to the POS is prohibited. If a slug occurs in kwargs, it checks for uniqueness. As in the
create_pos
function, the update process is completed if an error is not encountered following a config verification. In case of an error, an error message is returned to the user.
- This function is used to update an existing POS. First, it checks the change status of the POS channel to be updated. Changing the sales channels linked to the POS is prohibited. If a slug occurs in kwargs, it checks for uniqueness. As in the
Figure 4: PosService Structure
View Structure
PosViewSet {omnitron.payments.resources.views.PosViewSet} is located on the endpoint /api/v1/pos/
.
Allows GET, POST, PUT, PATCH and DELETE methods inherited from ModelViewSet. perform_create(), perform_update() and get_queryset() functions are overridden; perform create/update operations on the relevant PosService.
Location: omnitron.payments.resources.views.PosViewSet
Figure 5: PosViewSet Structure
Potential Responses
201 Created
400 Bad Request
404 Not Found
405 Method Not Allowed
406 Not Acceptable
GET
POS
Retrieves attribute values from the POS table. Gets the filter parameters with {omnitron.payments.resources.filters.PosFilter}
in PosFilter as query parameters. Supports pagination by inheriting ViewSet from ListModelMixin with query parameters of page=X and limit=Y.
Path: /api/v1/pos/
Filters: Filtering can only be done with channel
, id
and modified_date
.
Example: ?channel=1
Response
{
"count": 1,
"next": "/api/v1/pos/?page=2",
"previous": null,
"results": [
{
"pk": 1,
"name": " Test Garanti Pay",
"slug": "gpay",
"gateway": "omnicore.libs.payment_gateways.gpay.GPayGateway",
"config": {
"auth": {
"password": "111111",
"merchant_id": "111111",
"terminal_id": "111111",
"prov_username": {
"oos": "oos",
"refund": "refund"
}
},
"mode": "TEST",
"version": "v0.01",
"store_key": "111111",
"refund_url": "https://sanalposprovtest.garanti.com.tr/VPServlet",
"company_name": "AAA",
"timeout_period": 300
},
"resource_url": "https://sanalposprovtest.garanti.com.tr/servlet/gt3dengine",
"three_d_resource_url": null,
"channel": 1,
"gateway_display": "Gpay",
"modified_date": "2022-02-10T06:28:55.575801Z",
"created_date": "2022-02-10T06:28:55.575773Z"
}
]
}
POST
Create POS
Adds a new record to the POS table. Verified with PosSerializer. Returns HTTP400 if data is not available. Returns HTTP406 if there is an error or incompatibility at the service layer during the registration process.
Path: /api/v1/pos/
{
"name": "POS",
"slug": "POS",
"gateway": "omnicore.libs.payment_gateways.dummypay.DummyPayGateway",
"config": {
"three_d_enabled": false,
"fail_on_void": false,
"auth": {},
"fail_on_refund": false
},
"resource_url": "https://dummypay.net/",
"three_d_resource_url": "https://dummypay.net/",
"channel": 1
}
Response
The success response status is HTTP201 and the response body contains the generated POS information HTTP400 and HTTP406 response statuses mean that the POS object was not created.
Status 201
{
"pk": 11,
"name": "POS",
"slug": "POS",
"gateway": "omnicore.libs.payment_gateways.dummypay.DummyPayGateway",
"config": {
"three_d_enabled": false,
"fail_on_refund": false,
"fail_on_void": false,
"auth": {}
},
"resource_url": "https://dummypay.net/",
"three_d_resource_url": "https://dummypay.net/",
"channel": 1,
"gateway_display": "Dummypay",
"modified_date": "2023-01-13T11:08:43.792169Z",
"created_date": "2023-01-13T11:08:43.792140Z"
}
Errors
Status 400
{
"non_field_errors": [
"The fields slug, channel must make a unique set."
]
}
Status 406
{
"non_field_errors": "{"username": ["This field is required."], "store_key": ["This field is required."], "password": ["This field is required."], "client_id": ["This field is required."]}",
"error_code": "pos_100_2"
}
GET
POS Detail
Retrieves the object of the corresponding primary key from the POS table. If it cannot find the object, it returns HTTP404.
Path: /api/v1/pos/{id}/
Returns POS information with the provided ID.
Response
Successful response status is HTTP200 and response BODY is the details of the object.
{
"pk": 1,
"name": " Test Garanti Pay",
"slug": "gpay",
"gateway": "omnicore.libs.payment_gateways.gpay.GPayGateway",
"config": {
"auth": {
"password": "111111",
"merchant_id": "111111",
"terminal_id": "111111",
"prov_username": {
"oos": "oos",
"refund": "refund"
}
},
"mode": "TEST",
"version": "v0.01",
"store_key": "111111",
"refund_url": "https://sanalposprovtest.garanti.com.tr/VPServlet",
"company_name": "AAA",
"timeout_period": 300
},
"resource_url": "https://sanalposprovtest.garanti.com.tr/servlet/gt3dengine",
"three_d_resource_url": null,
"channel": 1,
"gateway_display": "Gpay",
"modified_date": "2023-01-13T11:08:43.792169Z",
"created_date": "2023-01-13T11:08:43.792140Z"
}
DELETE
POS
Path: /api/v1/pos/{id}/
Permanently deletes POS with the provided ID.
Response: Only returns status 204 in response
PATCH
-PUT
Update POS
Path: /api/v1/pos/{id}/
POS information with the provided ID is updated.
Request
{
"Pk":1,
"name":"DummyPay",
"Slug":"dummy-pay",
"gateway":"omnicore.libs.payment_gateways.dummypay.DummyPayGateway",
"Config":{
"Three_d_enabled":false,
"Fail_on_void":false,
"Fail_on_refund":false
},
"resource_url":"https://dummypay.net/",
"three_d_resource_url":"https://dummypay.net/",
"Channel":1,
"gateway_display":"Dummypay"
}
Response
{
"Pk":10,
"name":"DummyPay",
"Slug":"dummy-pay",
"gateway":"omnicore.libs.payment_gateways.dummypay.DummyPayGateway",
"Config":{
"Three_d_enabled":false,
"Fail_on_refund":false,
"Fail_on_void":false,
"Auth":{}
},
"resource_url":"https://dummypay.net/",
"three_d_resource_url":"https://dummypay.net/",
"Channel":1,
"gateway_display":"Dummypay",
"modified_date": "2023-01-13T11:37:10.547812Z",
"created_date": "2023-01-13T11:08:43.792140Z"
}
Errors
-- OR 406
{
"non_field_errors": "Channel: Shop of Pos: dummy_pos cannot change.",
"error_code": "pos_100_3"
}
-- OR 406
{
"non_field_errors": [
"The fields slug, channel must make a unique set."
]
}
-- OR 406
{
"non_field_errors": "{"username": ["This field is required."], "store_key": ["This field is required."], "password": ["This field is required."], "client_id": ["This field is required."]}",
"error_code": "pos_100_2"
}
GET
Schema Structure
Path: /api/v1/pos/schema/
Returns the schema structure for the POS endpoint.
{
"name": "Schema",
"description": "",
"renders": [
"application/json",
"text/html",
"text/csv",
"application/xls",
"application/xml"
],
"parses": [
"application/json",
"application/x-www-form-urlencoded",
"multipart/form-data"
],
"actions": {
"POST": {
"pk": {
"type": "integer",
"required": false,
"read_only": true,
"label": "ID"
},
"name": {
"type": "string",
"required": true,
"read_only": false,
"label": "Name",
"max_length": 64
},
"slug": {
"type": "string",
"required": true,
"read_only": false,
"label": "Slug"
},
"gateway": {
"type": "choice",
"required": true,
"read_only": false,
"label": "Gateway",
"choices": [
{
"display_name": "alpha",
"value": "omnicore.libs.payment_gateways.alpha.AlphaGateway"
},
]
},
"config": {
"type": "json field",
"required": false,
"read_only": false,
"label": "Config",
"choices": {
"fiba_credit": {
"client_id": {
"type": "string",
"required": true,
"read_only": false,
"label": "Client Id",
"max_length": 64
},
"client_secret": {
"type": "string",
"required": true,
"read_only": false,
"label": "Client Secret Key",
"max_length": 64
},
...
},
"resource_url": {
"type": "url",
"required": true,
"read_only": false,
"label": "Resource url",
"max_length": 200
},
"three_d_resource_url": {
"type": "url",
"required": false,
"read_only": false,
"label": "Three d resource url",
"max_length": 200
},
"channel": {
"type": "pk field",
"required": true,
"read_only": false,
"label": "Channel"
},
"gateway_display": {
"type": "method field",
"required": false,
"read_only": true,
"label": "Gateway display"
},
"modified_date": {
"type": "datetime",
"required": false,
"read_only": true,
"label": "Modified date"
},
"created_date": {
"type": "datetime",
"required": false,
"read_only": true,
"label": "Created date"
}
}
},
"filters": {
"id": {
"type": "NumberFilter",
"lookup_types": [
"exact",
"gt",
"gte",
"lt",
"lte"
]
},
"channel": {
"type": "ModelChoiceFilter",
"lookup_types": [
"exact"
]
},
"modified_date": {
"type": "DateFilter",
"lookup_types": [
"exact",
"gt",
"gte",
"lt",
"lte",
"date"
]
},
"pk": {
"type": "NumberFilter",
"lookup_types": [
"exact",
"gt",
"gte",
"lt",
"lte"
]
}
},
"ordering": "__all__"
}
Bank
Permits bank definitions on Omnitron. It can be accessed from the Sales Channels > Payment Managements > Banks menu on Omnitron.
Model Structure
Location: Omnitron.payments.models.Bank
omnicore_project.omnicore.utils.models
IntegrationRelation and omnicore_project.
omnicore.payments.models.
Inherited from BaseBank.
Slug and channel make a unique set.
Name | Description |
channel | ForeignKey. The ID of the sales channel defined with the bank. |
name | CharField, with a maximum length of 64 characters. Represents the bank name. |
slug | CharField, with a maximum length of 64 characters. Shor name of the relevant bank. |
logo | ImageField. Logo of the relevant bank. |
Figure 6: Bank Model Structure
Figure 7: Bank Model Methods and Inheritance Structure
Serializer Structure
BankSerializer allows complex data such as Querysets and model instances to be converted into native datatypes that can then be easily rendered to JSON or other content types. The serializer also provides deserialization by allowing parsed data to be converted back to complex types, after validating incoming data.
Location: Omnitron.payments.resources.serializers.BankSerializer
Provides the fields in the model structure. "PK" is also included.
Figure 8: BankSerializer Structure
Service Structure
The service layer carries business applications for creating and updating the Bank object(s). BankService also includes other business requirements.
Location: omnitron.payments.service.BankService
create_bank
(self, name, slug, channel, kwargs):- Used to create a bank. There are logos in kwargs. First, a check is performed to determine whether a bank with the same slug and sales channel exists. The bank is then created with the provided information.
update_bank
(self, instance, kwargs):- Used to change the information of the defined bank. The sales channel cannot be changed and an update with the same slug and sales channel cannot be made. Updates the bank after the checks are completed.
get_csv_dataset
(self, csvfile):- Reads the parameter CSV file, converts it to "Dataset" format in tablib and returns it. Used in the bulk_create function.
get_image
(url):- This is a static function. It returns a ContentFile type response by sending a get request to the address with the provided URL. Used in the bulk_create function.
bulk_create_with_file
(self, uploaded_file, channel_id):
Bulk creates banks using the crate_bank function by reading the banks provided as CSV files.
Figure 9: BankService Structure
View Structure
BankViewSet {omnitron.payments.resources.views.BankViewSet}
is located on the endpoint /api/v1/banks/
.
Allows GET, POST, PUT, PATCH and DELETE methods inherited from ModelViewSet. The perform_create(), perform_update() and get_queryset() functions are overridden; perform create/update operations on the relevant BankService.
Figure 10: BankViewSet Structure
Potential Responses
201 Created
400 Bad Request
404 Not Found
405 Method Not Allowed
406 Not Acceptable
GET
Banks
Path: /api/v1/banks/
Returns the recorded banks in Omnitron.
Response
{
"count": 29,
"next": "http://localhost:8000/api/v1/banks/?page=2",
"previous": null,
"results": [
{
"pk": 2,
"name": "Türkiye Finans Katılım Bankası",
"slug": "turkiye-finans-katlm-bankas",
"logo": null,
"channel": 1,
"modified_date": "2017-02-01T14:18:17.752654Z",
"created_date": "2017-02-01T14:18:17.752631Z"
},
…
}
Filters
Filtering can only be made with channel, ID and modified_date.
/api/v1/banks/?channel=1
Response
{
"count": 1,
"next": "/api/v1/banks/?page=2",
"previous": null,
"results": [
{
"pk": 1,
"name": "Test Bank",
"slug": "test-bank",
"logo": null,
"channel": 1,
"modified_date": "2017-02-01T14:18:17.752654Z",
"created_date": "2017-02-01T14:18:17.752631Z"
}]
}
POST
Create Bank
Path: /api/v1/banks/
Adds a new record to the Bank table. It is validated with BankSerializer. If the data is not suitable, it returns HTTP400. If there is an error or non-compliance in the service layer during the recording process, it returns HTTP406.
{
"name": "Test Bank",
"slug": "test-bank",
"logo": null,
"channel": 1
}
Response
HTTP 200
{
"pk": 2,
"name": "Test Bank",
"slug": "test-bank",
"logo": null,
"channel": 1,
"modified_date": "2023-01-13T13:28:34.304746Z",
"created_date": "2023-01-13T13:28:34.304708Z"
}
Errors
{
"non_field_errors": [
"The fields slug, channel must make a unique set."
]
}
GET
Bank Detail
Path: /api/v1/banks/{id}/
Returns bank information with the provided ID.
Response
{
"pk": 2,
"name": "Test Bank",
"slug": "test-bank",
"logo": null,
"channel": 1,
"modified_date": "2023-01-13T13:28:34.304746Z",
"created_date": "2023-01-13T13:28:34.304708Z"
}
DELETE
Bank
Path: /api/v1/banks/{id}/
Permanently deletes banks with the provided ID.
Response
Only returns status 204
in response.
PUT
-PATCH
Update Bank
Path: /api/v1/banks/{id}/
Permits changes to banks with the provided ID.
{
"name": "Edited Test Bank",
"slug": "test-bank",
"logo": null,
"channel": 1
}
Response
{
"pk": 2,
"name": "Edited Test Bank",
"slug": "test-bank",
"logo": null,
"channel": 1,
"modified_date": "2023-01-13T13:31:55.092127Z",
"created_date": "2023-01-13T13:31:29.377205Z"
}
Errors
HTTP 400
{
"non_field_errors": [
"The fields slug, channel must make a unique set."
]
}
-- OR HTTP 406
{
"non_field_errors": "Channel: Test Edited of Bank: test-bank cannot change.",
"error_code": "bank_100_2"
}
POST
Bulk Bank Creation
Path: /api/v1/banks/bulk_create/?channel_id={channel_id}
Permits the bulk creation of banks with the CSV file. It is mandatory to provide channel ID as a query parameter. The fields in BankSerializer must be present in the CSV file. The logo must be expressed within the URL.
{
filename: csv_file.csv
}
Response
{
"<name>": "<Creation status>"
}
Card Type
Used for the type identification of the cards to be defined on Omnitron. It can be accessed from the Sales Channels > Payment Management > Card Types menu on Omnitron.
Model Structure
Location: omnitron.payments.models.CardType
Inherited from omnicore_project.omnicore.utils.models.IntegrationRelation
and omnicore_project.omnicore.payments.models.BaseCardType.Slug
and channel make a unique set.
Name | Description |
channel | ForeignKey. Represents the sales channel where the card type can be used. |
name | CharField, with a maximum length of 64 characters. Represents the name of the relevant card type. |
slug | SlugField, with a maximum length of 64 characters. Abbreviation of the relevant card type. |
logo | ImageField. Logo of the relevant card type. |
Figure 11: CardType Model Structure
Figure 12: CardType Model Methods and Inheritance
Serializer Structure
CardTypeSerializer allows complex data such as Querysets and model instances to be converted to native datatypes that can then be easily rendered into JSON or other content types. The Serializer also provides deserialization, allowing parsed data to be converted back into complex types after validating the incoming data.
Location: omnitron.payments.resources.serializers.CardTypeSerializer
Includes a "PK" field in addition to the model structure.
Service Structure
The service layer carries business practices for creating and updating CardType object(s).
Location: omnitron.payments.service.CardTypeService
create_card_type
(name, slug, channel, kwargs):- Used to create a card type. There are logos in kwargs. Defining a logo is not mandatory. It first performs a check for records with the same slug and channel. If none are found, the registration process is completed successfully.
update_card_type
(instance, kwargs)- Used to update the existing card type. Instance represents the record to be updated. Channel, slug and logo can be included in kwargs. Represents the modified data. The channel cannot be changed. While updating the slug, a check is performed to determine whether there are records of the new slug and channel. After the check is performed, the update process is completed.
Figure 13: CardTypeService Structure
View Structure
CardTypeViewSet {omnitron.payments.resources.views.CardTypeViewSet}
is located in the endpoint /api/v1/card_types/
Allows GET, POST, PUT, PATCH and DELETE methods inherited from ModelViewSet. perform_create(), perform_update() and get_queryset() functions are overridden; perform create/update operations on the relevant CardTypeService.
Location: omnitron.payments.resources.views.CardTypeViewSet
Figure 14: CardTypeViewSet Structure
Potential Responses
201 Created
400 Bad Request
404 Not Found
405 Method Not Allowed
406 Not Acceptable
GET
Credit Card Types
Path: /api/v1/card_types/
Returns the card types registered on Omnitron.
Filters
Filtering can only be done with channel, ID and modified_date.
/api/v1/card_types/?channel=1
Response
{
"count": 1,
"next": "http://{customer_omnitron_url}/api/v1/card_types/?page=2",
"previous": null,
"results": [
{
"pk": 1,
"name": "Bonus",
"slug": "bonus",
"logo": "http://logo.url",
"channel": 1,
"modified_date": "2017-02-01T14:18:17.763175Z",
"created_date": "2017-02-01T14:18:17.763148Z"
}]
}
GET
Credit Card Type Detail
Path: /api/v1/card_types/{id}/
Returns card types with the provided ID.
Response
{
"pk": 1,
"name": "Bonus",
"slug": "bonus",
"logo": "http://logo.url.jpg",
"channel": 1,
"modified_date": "2017-02-01T14:18:17.763175Z",
"created_date": "2017-02-01T14:18:17.763148Z"
}
DELETE
Credit Card Type
Path: /api/v1/card_types/{id}/
Permanently deletes card types with the provided ID.
Response
Only returns status 204
in response
PUT
-PATCH
Update Credit Card Type
Path: /api/v1/card_types/{id}/
Updates card types with the provided ID.
{
"pk": 1,
"name": "Bonus-v2",
"slug": "bonus",
"channel": 1
}
Response
{
"pk": 1,
"name": "Bonus-v2",
"slug": "bonus",
"logo": "http://logo.url",
"channel": 1
}
Errors
{
"logo": [
"The submitted data was not a file. Check the encoding type on the form."
]
}
-- OR
{
"non_field_errors": [
"The fields slug, channel must make a unique set."
]
}
-- OR HTTP 406
{
"non_field_errors": "Channel: test of CardType: test cannot change.",
"error_code": "card_type_100_2"
}
POST
Create a New Card Type
Adds a new record to the CardType table. Validated with CardTypeSerializer. Returns HTTP400 if data is not available. Returns HTTP406 if there is an error or incompatibility at the service layer during the recording process.
Path: /api/v1/card_types/
{
"name": "New Type",
"slug": "new-type",
"logo": "<logo file>",
"channel": 1
}
Response
HTTP 200
{
"pk": 2,
"name": "New Type",
"slug": "new-type",
"logo": "http://logo.url",
"channel": 1,
"modified_date": "2023-01-13T14:30:39.534199Z",
"created_date": "2023-01-13T14:30:39.534173Z"
}
Response
HTTP 400
{
"logo": [
"The submitted data was not a file. Check the encoding type on the form."
]
}
-- OR
{
"non_field_errors": [
"The fields slug, channel must make a unique set."
]
}
Card
Used to define and process cards that can be used in sales channels on Omnitron. Creating a card firstly requires the creation of a card type, POS and the bank to which it will be linked. It can be accessed from the Sales Channels > Payment Management > Card Settings menu on the Omnitron panel.
Model Structure
Location:omnitron.payments.models.Card
Inherited from omnicore_project.omnicore.utils.models.IntegrationRelation
and omnicore_project.omnicore.payments.models.BaseCard.
Slug-channel-bank-card_type
and bank-card_type-card_payment_type
make a unique set.
- channel: ForeignKey. Represents the sales channel where the card will be valid.
- name : CharField, with a maximum length of 64 characters. Represents the card name.
- slug: SlugField, with a maximum length of 64 characters. Abbreviation of the relevant card.
- bank: ForeignKey. Represents the bank linked to the card.
- card_type: ForeignKey. Represents the card type.
- card_payment_type: EnumField. Represents the card payment type. Its location is
omnicore_project.omnicore.payments.enums.CardPaymentType
, and the options are:
- credit
- debit
- cash_payment: ForeignKey. It represents the POS infrastructure to be linked when the card is used for purchases without installments.
- installment_payment: ForeignKey. It represents the POS infrastructure to be linked when the card is used for purchases with installments.
- three_d_payment: ForeignKey. It represents the POS infrastructure to be linked when the card is used for purchases with 3D.
- is_commerce_card: NullBooleanField. It is False by default. Represents whether the card is a commerce card.
Figure 15: Card Model and Relations
Figure 16: Card Model Methods and Inheritance
Serializer Structure
Location: Omnitron.payments.resources.serializers.CardSerializer
Includes a "PK" field in addition to the model structure.
Figure 17: Card serializer structure
Service Structure
Location: Omnitron.payments.service.CardService
create_card
(name, slug, bank, card_type, card_payment_type, cash_payment, installment_payment, channel, three_d_payment=None):
- First, it verifies that the parameter channel, bank, card_type, cash_payment, installment_payment and three_d_payment channels (if any) are identical.
If any of the parameters are linked to another sales channel, it throws a CardIncompatibleException
.
- Afterwards, the parameters slug, bank slug, card_type slug, and the DEFAULT_CARD_SLUG in the settings are checked. If the slugs are different and the parameter slug is equal to the DEFAULT_CARD_SLUG in the settings, it throws a CardIncompatibleException.
- Before proceeding with the card creation process, two more checks must be made. These are:
- Is there any other card which has the same bank, same cart_type and same card_payment_type?
- Is there any other card which has the same bank, same card_type, same slug and same channel?
- If there are any matching results, it throws a CardAlreadyExistsException.
- The card is successfully created when the checks are completed.
def update_card
(instance, kwargs):- Instance represents the card to be updated. Kwargs includes the parameters for update. The channels of the provided parameters must be identical for the update. If not, it throws a
CardIncompatibleException
. - This is followed by a slug check, as in
create_card
. - Finally, a check is performed to determine whether an existing card exists with the same data, as in
create_card
. - If none exist, the update process is completed successfully.
- Instance represents the card to be updated. Kwargs includes the parameters for update. The channels of the provided parameters must be identical for the update. If not, it throws a
Figure 18: Card Service Structure
View Structure
CardViewSet {omnitron.payments.resources.views.CardViewSet}
is located in the endpoint /api/v1/cards/
Allows GET, POST, PUT, PATCH and DELETE methods inherited from ModelViewSet. perform_create(), perform_update() and get_queryset() functions are overridden; perform create/update operations on the relevant PosService.
Location: Omnitron.payments.resources.views.CardViewSet
Figure 19: CardViewSet Structure
Potential Responses
201 Created
400 Bad Request
404 Not Found
405 Method Not Allowed
406 Not Acceptable
GET
All Credit Cards
Path: /api/v1/cards/
Returns all cards registered in the system.
Filters
Location: Omnitron.payments.resources.filters.CardFilter
Filtering can be performed with all fields available in the Card model.
Example: ?name=Bonus&bank=2
Response
{
"count": 1,
"next": null,
"previous": null,
"results": [
{
"pk": 1,
"name": "Bonus",
"bank": 2,
"card_type": 1,
"card_payment_type": "credit",
"cash_payment": 10,
"installment_payment": 2,
"slug": "bonus",
"three_d_payment": 10,
"is_commerce_card": false,
"channel": 1,
"modified_date": "2017-02-01T14:18:17.776010Z",
"created_date": "2017-02-01T14:18:17.775977Z"
}
]
}
GET
Card Detail
Path: /api/v1/cards/{id}/
Returns card information with the provided ID.
Response
{
"pk": 1,
"name": "Bonus",
"bank": 2,
"card_type": 1,
"card_payment_type": "credit",
"cash_payment": 10,
"installment_payment": 2,
"slug": "bonus",
"three_d_payment": 10,
"is_commerce_card": false,
"channel": 1,
"modified_date": "2017-02-01T14:18:17.776010Z",
"created_date": "2017-02-01T14:18:17.775977Z"
}
PUT
-PATCH
Update Card
Path: /api/v1/cards/{id}/
Updates the card information with the provided ID.
{
"pk": 1,
"name": "New Card",
"bank": 2,
"card_type": 1,
"card_payment_type": "credit",
"cash_payment": 10,
"installment_payment": 2,
"slug": "new-card",
"three_d_payment": 10,
"is_commerce_card": false,
"channel": 1
}
Response
{
"pk": 1,
"name": "New Card",
"bank": 2,
"card_type": 1,
"card_payment_type": "credit",
"cash_payment": 10,
"installment_payment": 2,
"slug": "new-card",
"three_d_payment": 10,
"is_commerce_card": false,
"channel": 1,
"modified_date": "2023-01-16T07:35:04.404826Z",
"created_date": "2023-01-16T07:25:39.965970Z"
}
Response / 400
{
"non_field_errors": [
"The fields slug, channel, bank, card_type must make a unique set.",
"The fields bank, card_type, card_payment_type must make a unique set."
]
}
Response / 406
{
"non_field_errors": "Card: <bank> <card_tpye> <bank_slug> <channel_name> incompatible.",
"error_code": "card_100_2"
}
POST
Create Card
Adds a new record to the card table. Verified with CardSerializer. Returns HTTP400 if data is not available. Returns HTTP406 if there is an error or incompatibility at the service layer during the registration process.
Path: /api/v1/cards/
{
"name": "new",
"bank": 2,
"card_type": 1,
"card_payment_type": "debit",
"cash_payment": 10,
"installment_payment": 2,
"slug": "new",
"three_d_payment": 10,
"is_commerce_card": false,
"channel": 1
}
Response / 201
{
"pk": 2,
"name": "new",
"bank": 2,
"card_type": 1,
"card_payment_type": "debit",
"cash_payment": 10,
"installment_payment": 2,
"slug": "new",
"three_d_payment": 10,
"is_commerce_card": false,
"channel": 1,
"modified_date": "2023-01-16T07:25:39.965998Z",
"created_date": "2023-01-16T07:25:39.965970Z"
}
Response / 400
{
"non_field_errors": [
"The fields slug, channel, bank, card_type must make a unique set.",
"The fields bank, card_type, card_payment_type must make a unique set."
]
}
Response / 406
{
"non_field_errors": "Card: <bank> <card_tpye> <bank_slug> <channel_name> incompatible.",
"error_code": "card_100_2"
}
DELETE
Credit Card
Path: /api/v1/cards/{id}/
Permanently deletes cards with the provided ID.
Returns status 204
in response.
POST
Bulk Card Creation
Path: /api/v1/cards/{id}/bulk_create/
Used to bulk create BIN numbers for cards with the provided ID. The CSV file is a single column and contains the BIN number. For this process, it uses the bulk_create
function of BinNumberService
.
{
filename: csv_file.csv
}
Response
{
"<bin_number>": "<Creation status>"
}
HTTP 406
{
"non_field_errors": "File not found please provide an appropriate file",
"error_code": "file_100_1"
}
Bank Identification Number
The BIN that can be shopped within sales channels are defined. Each BIN is linked to a card. The match is made when the card information is entered in the sales channels. When we enter the details of a card on the Sales Channels>Payment Management>Card Settings page on the Omnitron panel, the bottom of the opened page displays a table with the title Card BIN Numbers.
Model Structure
Location: omnitron.payments.models.BinNumber
Bin_number and channel make a unique set. Inherited from omnicore_project.omnicore.utils.models.IntegrationRelation
and omnicore_project.omnicore.payments.models.BaseBinNumber
.
- channel: ForeignKey. The sales channel linked to the BIN number.
- bin_number: CharField. Its maximum length is 6 characters. The BIN number to be defined.
- card: ForeignKey. Represents the card linked to the BIN number.
is_active
: BooleanField. Represents the active status of the BIN number. It is True by default.
Figure 20: BinNumber Model Structure
Figure 21: Bank Model Methods and Inheritance Structure
Serializer Structure
Location: omnitron.payments.resources.serializers.BinNumberSerializer
Includes a "PK" field in addition to the model structure.
Figure 22: BinNumberSerializer Structure
Service Structure
Location: omnitron.payments.service.BinNumberService
- create_bin_number(bin_number, card, kwargs):
- Used to create a BIN number. The channel instance is included in kwargs. The channel and the bank of the parameter card in kwargs must have the same ID. If it does not, it throws a
BinNumberChannelIncompatibleException
. This is followed by a check to determine the uniqueness of the BIN number and channel. If it is not unique, it throws aBinNumberAlreadyExistsException
. After these checks, the BIN number is created successfully.
- Used to create a BIN number. The channel instance is included in kwargs. The channel and the bank of the parameter card in kwargs must have the same ID. If it does not, it throws a
- update_bin_number(instance, kwargs):
- Used to update an existing BIN number. The instance represents the BIN number to be updated. Kwargs includes the information to be updated. First, the sales channels linked to the data to be updated are checked. In case of an incompatible sales channel, it throws a
BinNumberChannelIncompatibleException
. If the bin_number field is to be updated afterwards, a check is performed to determine whether an identical BIN number exists. If it is not unique, it throws aBinNumberAlreadyExistsException
. After these checks, the update process is completed successfully.
- Used to update an existing BIN number. The instance represents the BIN number to be updated. Kwargs includes the information to be updated. First, the sales channels linked to the data to be updated are checked. In case of an incompatible sales channel, it throws a
- bulk_create_with_file(csvfile, card):
- Used to bulk create BIN numbers. The csvfile parameter represents the CSV file containing the BIN numbers. The card parameter represents the card that will be linked to these BIN numbers. The CSV file is a single column and contains the BIN number. It redirects the BIN numbers read from the CSV file to the
create_bin_number
function individually.
- Used to bulk create BIN numbers. The csvfile parameter represents the CSV file containing the BIN numbers. The card parameter represents the card that will be linked to these BIN numbers. The CSV file is a single column and contains the BIN number. It redirects the BIN numbers read from the CSV file to the
Figure 23: BinNumberService Structure
View Structure
BinNumberViewSet {omnitron.payments.resources.views.BinNumberViewSet}
is located in the endpoint /api/v1/bin_numbers/
.
Allows GET, POST, PUT, PATCH and DELETE methods inherited from ModelViewSet. perform_create(), perform_update() and get_queryset() functions are overridden; perform create/update operations on the relevant BinNumberService.
Location: Omnitron.payments.resources.views.BinNumberViewSet
Figure 24: BinNumberViewSet Structure
Potential Responses
201 Created
400 Bad Request
404 Not Found
405 Method Not Allowed
406 Not Acceptable
GET
All BINs
Path: /api/v1/bin_numbers/
Returns all BIN numbers registered on Omnitron.
Filters
Filters can be applied to bin_number_length (6 or 8) in addition to all fields on the serializer. E.g.: ?card=1
Response
{
"count": 1,
"next": "http://{customer_omnitron_url}/api/v1/bin_numbers/?page=2",
"previous": null,
"results": [
{
"pk": 1,
"bin_number": "524659",
"card": 5,
"is_active": true,
"channel": 1,
"modified_date": "2017-02-01T14:18:17.782154Z",
"created_date": "2017-02-01T14:18:17.782137Z"
}]
}
GET
BIN by ID
Path: /api/v1/bin_numbers/{id}/
Returns BIN numbers with the provided ID.
Response
{
"bin_number": "524659",
"card": 5,
"is_active": false,
"channel": 1,
"bin_number_length": "6",
"modified_date": "2017-02-01T14:18:17.782154Z",
"created_date": "2017-02-01T14:18:17.782137Z"
}
POST
Create BIN
Path: /api/v1/bin_numbers/
It is used to create BIN numbers.
{
"bin_number": "123452",
"card": 5,
"is_active": true,
"channel": 1
}
Response / 200
{
"pk": 724,
"bin_number": "123452",
"card": 5,
"is_active": true,
"channel": 1,
"bin_number_length": "6",
"modified_date": "2023-01-16T10:03:28.949597Z",
"created_date": "2023-01-16T10:03:28.949570Z"
}
Response / 400
{
"non_field_errors": [
"The fields bin_number, channel must make a unique set."
]
}
Response / 406
{
"non_field_errors": "Channel: <channel_name> <card_name> channel incompatible.",
"error_code": "bin_number_100_3"
}
DELETE
BIN
Path: /api/v1/bin_numbers/{id}/
Deletes BIN numbers with the provided ID. Returns status 204
in response.
PATCH
Create BIN
Path: /api/v1/bin_numbers/{id}/
Updates the bin_number information with the provided ID.
{
"bin_number": "123454",
"card": 5,
"is_active": true,
"channel": 1
}
Response
{
"pk": 724,
"bin_number": "123454",
"card": 5,
"is_active": true,
"bin_number_length": "6",
"channel": 1,
"modified_date": "2023-01-16T10:05:53.338918Z",
"created_date": "2023-01-16T10:03:28.949570Z"
}
Installment
Used for installments with the cards registered on Omnitron. Covers concepts such as the number of installments and late interest. When we enter the details of a card on the Sales Channels > Payment Management > Card Settings page on the Omnitron panel, the bottom of the opened page displays a table with the title “Term Commission Rates”.
Model Structure
Location: Omnitron.payments.models.Installment
Inherited from omnicore_project.omnicore.utils.models.IntegrationRelation
and omnicore_project.omnicore.payments.models.BaseInstallment.
The label field supports multiple languages.
- card: ForeignKey. Represents the card on which the relevant installment will be valid.
- installment_count: PositiveIntegerField. Represents how many installments the created installment object will allow.
- label: CharField. Its maximum length is 16 characters. The label/visible name of the created installment object. interest_rate: DecimalField. The late interest-interest rate applicable for the installment. It accepts 6 digits after the comma. Its maximum length is 8 digits.
- is_active: BooleanField. Shows the active status of the relevant installment object. It is True by default.
- config: JSONField. Contains the settings/configuration of the relevant installment object. It is an empty DICT object by default.
Figure 25: Installment Model Structure
Model Functions
- get_interest_amount(self, price):
- Multiplies and returns the interest_rate defined in the instance with the parameter price.
- get_single_installment_amount(self, price):
- Calculates and returns the single installment amount according to the price with the
interest_rate
andinstallment_count
defined in the instance.
- Calculates and returns the single installment amount according to the price with the
Figure 26: Installment Model Methods and Inheritance
Serializer Structure
Location: Omnitron.payments.resources.serializers.InstallmentSerializer
The validate_config
function runs to validate the config field. If min_limit or max_limit is defined in the config, there must be no more than 2 digits after the comma, and the total length must not exceed 11 digits.
Service Structure
Location: omnitron.payments.service.InstallmentService
create_installment
(installment_count, card, label, interest_rate, config=None):- Used to create an installment object. First, a check is performed to determine whether another active installment instance has occurred with an identical card, installment_count and config. If this has occurred, it throws an
InstallmentAlreadyExistsException
. The active language of the project is then assessed, translations to the label field are made (if required), and the installment is created.
- Used to create an installment object. First, a check is performed to determine whether another active installment instance has occurred with an identical card, installment_count and config. If this has occurred, it throws an
update_installment(
instance, kwargs):- Instance represents the installment to be updated. Kwargs includes the data to be updated. If there is a card in kwargs, a check is performed to determine whether the channel ID of the bank of the existing instance card matches the channel ID of the card bank in kwargs. If there is no match, it throws an
InstallmentChannelIncompatibleException
. The language of the project is then selected, the label field is translated and the update process is completed.
- Instance represents the installment to be updated. Kwargs includes the data to be updated. If there is a card in kwargs, a check is performed to determine whether the channel ID of the bank of the existing instance card matches the channel ID of the card bank in kwargs. If there is no match, it throws an
Figure 27: InstallmentService Structure
View Structure
InstallmentViewSet {omnitron.payments.resources.views.InstallmentViewSet}
is located in the endpoint /api/v1/installments/
Allows GET, POST, PUT, PATCH and DELETE methods inherited from ModelViewSet. perform_create(), perform_update() and get_queryset() functions are overridden; perform create/update operations on the relevant InstallmentService.
Location: omnitron.payments.resources.views.InstallmentViewSet
Figure 28: InstallmentViewSet Structure
Potential Responses
201 Created
400 Bad Request
404 Not Found
405 Method Not Allowed
406 Not Acceptable
GET
All Installment Instances
Path: /api/v1/installments/
Returns all installment instances.
Filters
Filters can be applied via card
, installment_count
, interest_rate
and is_active
. E.g.: ?card=1
Response
{
"count": 1,
"next": "http://{customer_omnitron_url}/api/v1/installments/?page=2",
"previous": null,
"results": [
{
"pk": 1,
"card": 1,
"installment_count": 1,
"label": "In Advance",
"interest_rate": "0.000000",
"is_active": true,
"config": {},
"translations": null,
"modified_date": "2017-02-01T14:18:17.787615Z",
"created_date": "2017-02-01T14:18:17.787596Z"
}]
}
GET
Installment Detail
Path: /api/v1/installments/{id}/
Returns installments with the provided ID.
Response
{
"pk": 1,
"card": 1,
"installment_count": 1,
"label": "In Advance",
"interest_rate": "0.000000",
"is_active": true,
"config": {},
"translations": null,
"modified_date": "2017-02-01T14:18:17.787615Z",
"created_date": "2017-02-01T14:18:17.787596Z"
}
PUT
-PATCH
Update Installment
Path: /api/v1/installments/{id}/
Updates installments with the provided ID.
{
"card": 1,
"installment_count": 1,
"label": "Spot Price",
"interest_rate": "0.000000",
"is_active": true,
"config": {},
"translations": null
}
Response
{
"pk": 1,
"card": 1,
"installment_count": 1,
"label": "Spot Price",
"interest_rate": "0.000000",
"is_active": true,
"config": {},
"translations": null,
"modified_date": "2023-01-16T13:02:55.275401Z",
"created_date": "2023-01-16T11:35:18.523510Z"
}
Response / 400
{
"label": [
"This field is required."
]
}
Response / 406
{
"non_field_errors": "Installment: 1 already exists.",
"error_code": "installment_100_1"
}
POST
Create Installment
Creates installment objects.
Path: /api/v1/installments
{
"card": 1,
"installment_count": 99,
"label": "99 installment",
"interest_rate": "0.000000",
"is_active": true,
"config": {},
"translations": null
}
Response / 201
{
"pk": 74,
"card": 1,
"installment_count": 99,
"label": "99 installment",
"interest_rate": "0.000000",
"is_active": true,
"config": {},
"translations": null,
"modified_date": "2023-01-16T11:35:18.523546Z",
"created_date": "2023-01-16T11:35:18.523510Z"
}
Response / 400
{
"label": [
"This field is required."
]
}
Response / 406
{
"non_field_errors": "Installment: 1 already exists.",
"error_code": "installment_100_1"
}
DELETE
Installment
Path: /api/v1/installments/{id}
Deletes installments with the provided ID. Returns status 204
in response.
Bank Account
A BankAccount instance must be created for payments by bank transfer. When we enter the details of a bank on the Sales Channels > Payment Management > Banks menu on the Omnitron panel, the opened page displays a table with the title Bank Accounts.
Model Structure
Location: Omnitron.payments.models.BankAccount Slug
– channel and iban channel form a unique set.
Inherited from omnicore_project.omnicore.utils.models.IntegrationRelation
and omnicore_project.omnicore.payments.models.BaseBankAccount
.
- channel: ForeignKey. Represents the sales channel linked to the relevant bank account.
- slug: SlugField. Its maximum length is 255 characters, and can be null. Abbreviation for bank account instance.
- iban: CharField. The IBAN number of the relevant bank account. Its maximum length is 34 characters.
- bank: ForeignKey. Represents the bank linked to the bank account. holder_name: CharField. Its maximum length is 255 characters. Represents the owner of the bank account.
- is_active: BooleanField. It is True by default. Represents the active status of the bank account.
- sort_order: IntegerField. It is 0 by default. Specifies the sort order of bank accounts.
- description: CharField. Its maximum length is 255 characters. Represents the annotation associated with the bank account.
Figure 29: BankAccount Model Structure
Figure 30: BankAccount Model Methods and Inheritance
Serializer Structure
Location: Omnitron.payments.resources.serializers.BankAccountSerializer
Includes a "PK" field in addition to the model structure. The slug field is mandatory.
Service Structure
Location: omnitron.payments.service.BankAccountService
create_bank_account
(bank, holder_name, iban, kwargs):- Used to create a bank account. Kwargs includes slug and channel. First, it checks the channel ID of the parameter bank and the channel ID in kwargs. If not identical, it throws a
BankAccountChannelIncompatibleException
. If there is a bank account with an identical IBAN and channel, it throws aBankAccountAlreadyExistException
. If there is a bank account with an identical slug and channel, it throws aBankAccountAlreadyExistException
. After these checks, the process is completed.
- Used to create a bank account. Kwargs includes slug and channel. First, it checks the channel ID of the parameter bank and the channel ID in kwargs. If not identical, it throws a
update_bank_account
(bank_account, kwargs):- The parameter bank_account checks the bank account to be updated. Kwargs includes the data to be updated. During the update, the bank account channel cannot be updated. In case of a change attempt, it throws a
BankAccountChannelCannotChangeException
. The updating bank channel must also be the same. It then checks for any existing bank accounts with the data for update. If any are found, it throws aBankAccountAlreadyExistException
. It carries out the same check with the slug for update. After these checks are performed, the update process is completed.
- The parameter bank_account checks the bank account to be updated. Kwargs includes the data to be updated. During the update, the bank account channel cannot be updated. In case of a change attempt, it throws a
delete_bank_account
(bank_account):- Updates the is_active field of the parameter bank account to False.
Figure 31: BankAccountService Structure
View Structure
BankAccountViewSet {omnitron.payments.resources.views.BankAccountViewSet} is located in the endpoint /api/v1/bank_accounts/
Allows GET, POST, PUT, PATCH and DELETE methods inherited from ModelViewSet. perform_create(), perform_update() and get_queryset() functions are overridden; perform create/update operations on the relevant BankAccountService.
Location: omnitron.payments.resources.views.BankAccountViewSet
Figure 32: BankAccountViewSet Structure
Potential Responses
201 Created
400 Bad Request
404 Not Found
405 Method Not Allowed
406 Not Acceptable
GET
All Bank Accounts
Path: /api/v1/bank_accounts/
Lists all registered bank accounts by sort_order
.
Filters
Filtering can be done by ID, bank, IBAN and channel. E.g.: ?channel=1&bank=1
Response
{
"count": 1,
"next": null,
"previous": null,
"results": [
{
"pk": 1,
"bank": 3,
"slug": "account",
"holder_name": "Company Name",
"iban": "tr00000000000",
"is_active": true,
"sort_order": 0,
"description": "Bank",
"channel": 1,
"modified_date": "2023-01-16T13:54:53.704234Z",
"created_date": "2023-01-16T13:38:30.442930Z"
}
]
}
GET
Bank Account Detail
Path: /api/v1/bank_accounts/{id}/
Returns bank accounts with the provided ID.
Response
{
"pk": 1,
"bank": 3,
"slug": "account",
"holder_name": "Company Name",
"iban": "tr00000000000",
"is_active": true,
"sort_order": 0,
"description": "Bank",
"channel": 1,
"modified_date": "2023-01-16T13:54:53.704234Z",
"created_date": "2023-01-16T13:38:30.442930Z"
}
PUT
-PATCH
Update Bank Account
Updates an existing bank account object with a given body.
Path: /api/v1/bank_accounts/{pk}/
Body
{
"bank": 3,
"slug": "new_slug",
"holder_name": "New Holder1",
"iban": "tr00000000000",
"is_active": true,
"sort_order": 0,
"description": "New Bank Account",
"channel": 1
}
or
{
"holder_name": "New Holder2"
}
Response / 200
{
"pk": 1,
"bank": 3,
"slug": "new_slug",
"holder_name": "New Holder1",
"iban": "tr00000000000",
"is_active": true,
"sort_order": 0,
"description": "New Bank Account",
"channel": 1,
"modified_date": "2023-01-16T13:52:30.812893Z",
"created_date": "2023-01-16T13:38:30.442930Z"
}
Response / 400
{
"non_field_errors": [
"The fields slug, channel must make a unique set.",
"The fields iban, channel must make a unique set."
]
}
Response / 406
{
"non_field_errors": "Channel: <channel_name> Bank <bank_name> channel incompatible.",
"error_code": "bank_account_101"
}
-- OR
{
"non_field_errors": "Channel: Unified of BankAccount: tr00000000000 cannot change.",
"error_code": "bank_account_102"
}
POST
Create Bank Account
Creates a new bank account object.
Path: `/api/v1/bank_accounts/``
Body
{
"bank": 3,
"slug": "new_slug",
"holder_name": "New Holder",
"iban": "tr00000000000",
"is_active": true,
"sort_order": 0,
"description": "New Bank Account",
"channel": 1
}
Response / 201
{
"bank": 3,
"slug": "new_slug",
"holder_name": "New Holder",
"iban": "tr00000000000",
"is_active": true,
"sort_order": 0,
"description": "New Bank Account",
"channel": 1,
"modified_date": "2023-01-16T13:54:53.704234Z",
"created_date": "2023-01-16T13:38:30.442930Z"
}
Response / 400
{
"non_field_errors": [
"The fields slug, channel must make a unique set.",
"The fields iban, channel must make a unique set."
]
}
Response / 406
{
"non_field_errors": "Channel: <channel_name> Bank <bank_name> channel incompatible.",
"error_code": "bank_account_101"
}
DELETE
Bank Account
Path: /api/v1/bank_accounts/{id}/
Updates the is_active
field of bank accounts with the provided ID to False. Returns status 204
in response.
Payment Option
Used to create and list payment options for the sales channels on Omnitron. It can be accessed from Sales Channels > Payment Management > Payment Options on the Omnitron panel.
Model Structure
Location: omnitron.payments.models.PaymentOption
Slug and channel make a unique set. The name field is specified as translatable.
Inherited from omnicore_project.omnicore.utils.models.IntegrationRelation
and omnicore_project.omnicore.payments.models.BasePaymentOption
.
- channel: ForeignKey. Represents the sales channel linked to the payment option.
- name: CharField. Its maximum length is 128 characters. Represents the name of the payment option.
- slug: SlugField. Its maximum length is 128 characters. Represents the abbreviation of the payment option.
- payment_type: EnumField. Represents the type of the payment option. These are the options.
- credit_card
- funds_transfer
- pay_on_delivery
- bkm_express
- loyalty_money
- cash_register
- gpay
- redirection
- stored_card
- masterpass
- credit_payment
- sort_order: IntegerField. It is set at 0 by default. Determines the sort order of the payment options.
- config: JSONField. It is a DICT object by default. Contains the configurations of the payment options.
- is_active: BooleanField. It is True by default. Represents the active status of the payment option.
Figure 33: PaymentOption Model
Model Functions
get_rules
(self):- Returns the object list of the rule list defined in the config field of the Payment Option instance.
get_initial_order_status
(self, order):- Returns the
OrderStatus
object of the parameter order according to the rule list defined in the config field of the Payment Option instance.
- Returns the
get_pos_using_slug
(self):- Returns the POS instance by querying the
pos_slug
value defined in the config field of the Payment Option instance in the POS Model.
- Returns the POS instance by querying the
is_credit_card
(self):- Returns whether the
payment_type
field of the Payment Option instance iscredit_card
.
- Returns whether the
is_funds_transfer
(self):- Returns whether the payment_type field of the Payment Option instance is
funds_transfer
.
- Returns whether the payment_type field of the Payment Option instance is
is_pay_on_delivery
(self):- Returns whether the
payment_type
field of the Payment Option instance ispay_on_delivery
.
- Returns whether the
is_loyalty_money
(self):- Returns whether the payment_type field of the Payment Option instance is
loyalty_money
.
- Returns whether the payment_type field of the Payment Option instance is
is_bkm_express
(self):- Returns whether the payment_type field of the Payment Option instance is
bkm_express
.
- Returns whether the payment_type field of the Payment Option instance is
is_cash_register
(self):- Returns whether the payment_type field of the Payment Option instance is
cash_register
.
- Returns whether the payment_type field of the Payment Option instance is
is_garanti_pay
(self):- Returns whether the payment_type field of the Payment Option instance is GPAY.
is_redirection_payment
(self):- Returns whether the payment_type field of the Payment Option instance is redirected.
is_mobilexpress
(self):- Returns whether the payment_type field of the Payment Option instance is stored_card.
is_credit_payment
(self):- Returns whether the payment_type field of the Payment Option instance is
credit_payment
.
- Returns whether the payment_type field of the Payment Option instance is
Figure 34: PaymentOption Methods and Inheritance
Serializer Structure
Location: Omnitron.payments.resources.serializers.PaymentOptionSerializer
Includes a "PK" field in addition to the model structure.
Service Structure
Location: Omnitron.payments.service.PaymentOptionService
- create_payment_option(slug, name, payment_type, channel, config=None, sort_order=0, is_active=True, kwargs):
- Used to create a new payment option. Kwargs contains the name. First, it checks that the slug and channel are unique. If it is not unique, it throws a PaymentOptionAlreadyExistsException. It defines a translation for the name field according to the language option active on Omnitron. The process is then completed.
update_payment_option
(instance, slug, kwargs): Instance represents the payment option parameter to be updated. The data contained in slug and kwargs is for performing updates. The channel cannot be changed. In case any changes are attempted to the parameters, it throws aPaymentOptionChannelCannotChangeException
. Any attempts to update the slug will prompt a check to be performed to determine the uniqueness of the slug and channel. If it is not unique, it throws aPaymentOptionAlreadyExistsException
. If the name exists in kwargs, its translations are added and the update process is completed.delete_payment_option
(instance):- Updates the
is_active
field of the instance parameter to False.
- Updates the
Figure 35: PaymentOptionService Structure
View Structure
PaymentOptionViewSet {omnitron.payments.resources.views.PaymentOptionViewSet} is located in the endpoint /api/v1/installments/
Allows GET, POST, PUT, PATCH and DELETE methods inherited from ModelViewSet. perform_create(), perform_update() and get_queryset() functions are overridden; perform create/update operations on the relevant PaymentOptionService.
Location: Omnitron.payments.resources.views.PaymentOptionViewSet
Potential Responses
201 Created
400 Bad Request
404 Not Found
405 Method Not Allowed
406 Not Acceptable
GET
All Payment Options
Path: /api/v1/payment_options/
Returns all payment option objects.
Filters
Filtering can be made via the channel, slug, name, payment_type
and is_active
fields.
E.x: ?slug=ödeme-seceneği&name=ödemeseceneği
Filters are managed via omnitron.payments.resources.filters.PaymentOptionFilter class
.
Response
{
"count": 2,
"next": null,
"previous": null,
"results": [
{
"PK": 2,
"name": "Credit Card",
"slug": "credit_card",
"payment_type": "credit_card",
"sort_order": 0,
"is_active": false,
"config": {},
"translations": null,
"channel": 1,
"modified_date": "2023-01-16T13:54:53.704234Z",
"created_date": "2023-01-16T13:38:30.442930Z"
},
{
"PK": 3,
"name": "Remintment",
"slug": "remintment",
"payment_type": "funds_transfer",
"sort_order": 2,
"is_active": true,
"config": {
"pos_slug": "ME",
"rule": {
"params": {},
"klass": "omnishop.payments.rules.StoredCardRequiredRule"
}
},
"translations": null,
"channel": 1,
"modified_date": "2023-01-16T13:54:53.704234Z",
"created_date": "2023-01-16T13:38:30.442930Z"
}
]
}
GET
Payment Option Detail
Path: /api/v1/payment_options/{id}/
Returns the payment options with the provided ID.
Response
{
"PK": 2,
"name": "Credit Card",
"slug": "credit_card",
"payment_type": "credit_card",
"sort_order": 0,
"is_active": false,
"config": {},
"translations": null,
"channel": 1,
"modified_date": "2022-03-28T13:33:51.859441Z",
"created_date": "2017-02-01T14:46:02.110133Z"
}
PUT
-PATCH
Update Payment Option
Path: /api/v1/payment_options/{id}/
Updates the payment options with the provided ID.
{
"PK": 2,
"name": "Debit Card",
"slug": "debit_card",
"payment_type": "credit_card",
"sort_order": 0,
"is_active": false,
"config": {},
"translations": null,
"channel": 1
}
Response
{
"PK": 2,
"name": "Debit Card",
"slug": "debit_card",
"payment_type": "credit_card",
"sort_order": 0,
"is_active": false,
"config": {},
"translations": null,
"channel": 1,
"modified_date": "2023-01-17T06:09:11.965773Z",
"created_date": "2023-01-17T06:09:11.965748Z"
}
Response / 400
{
"non_field_errors": [
"The fields slug, channel must make a unique set."
]
}
Response / 406
{
"non_field_errors": "Channel: test of PaymentOption new-option cannot change.",
"error_code": "payment_option_101"
}
POST
Create Payment Option
Used to create new payment option objects. HTTP 400 and HTTP 406 responses may be returned if the request body is not compatible.
Path: /api/v1/payment_options/
{
"name": "New Option",
"slug": "new-option",
"payment_type": "credit_card",
"sort_order": 0,
"is_active": false,
"config": {},
"translations": null,
"channel": 1
}
Response / 201
{
"PK": 4,
"name": "New Option",
"slug": "new-option",
"payment_type": "credit_card",
"sort_order": 0,
"is_active": false,
"config": {},
"translations": null,
"channel": 1,
"modified_date": "2023-01-17T06:09:11.965773Z",
"created_date": "2023-01-17T06:09:11.965748Z"
}
Response / 400
{
"non_field_errors": [
"The fields slug, channel must make a unique set."
]
}