payme-pkg
payme-pkg copied to clipboard
Dynamic Data Fiscalization
Add a detail object to Order model
| Detail key | Type | Summary | Required |
|---|---|---|---|
receipt_type |
Number | Sale/Refund = 0 | ✅ |
shipping |
Object | Delivery | ❌ |
items |
Array | Commodity item | ✅ |
{
"result": {
"allow": true,
"detail": {
"receipt_type" : 0,
"shipping": {},
"items": []
}
}
}
Items array parameters:
| Name | Type | Description | Required |
|---|---|---|---|
discount |
Number | Discount based on quantity of products or services (tiyins) | ❌ |
title |
String | Product or service name | ✅ |
price |
Number | Price per unit of products or services (tiyins) | ✅ |
count |
Number | Quantity of products or services | ✅ |
code |
String | ICPS (Identification code of product or service) | ✅ |
units |
Number | Measurement unit code | ❌ |
package_code |
String | Product packaging code | ✅ |
vat_percent |
Number | Percentage of VAT payable for this product | ✅ |
Shipping object parameters (optional field):
| Name | Type | Description | Required |
|---|---|---|---|
title |
String | Maybe delivery location | ✅ |
price |
Number | Cost of delivery | ✅ |
With only required objects and their keys, we need to add like following for each product or service in our Order model:
"detail": {
"receipt_type": 0,
"items": [
{
"title": "<product-or-service-name>",
"price": "<price>",
"count": "<quantity-int>",
"code": "<ICPS>",
"package_code": "<package-code>"
"vat_percent": "<percent-int>",
}
]
}
BaseOrder:
| Detail key | Type | Summary | Required |
|---|---|---|---|
receipt_type |
int | Sale/Refund = 0 | ✅ |
amount |
bigint | Amount | ✅ |
items |
m2m | Commodity item | ✅ |
shipping |
fk | ShippingDetail | ❌ |
Item:
| Name | Type | Description | Required |
|---|---|---|---|
discount |
bigint | Discount based on quantity of products or services (tiyins) | ❌ |
title |
str | Product or service name | ✅ |
price |
bigint | Price per unit of products or services (tiyins) | ✅ |
count |
int | Quantity of products or services | ✅ |
fiscal_data |
fk | FiscalData | ✅ |
FiscalData:
| Name | Type | Description | Required |
|---|---|---|---|
code |
str | ICPS (Identification code of product or service) | ✅ |
units |
int | Measurement unit code | ❌ |
package_code |
str | Product packaging code | ✅ |
vat_percent |
int | Percentage of VAT payable for this product | ✅ |
ShippingDetail:
| Name | Type | Description | Required |
|---|---|---|---|
title |
str | Maybe delivery location | ✅ |
price |
bigint | Cost of delivery | ✅ |
Example of Usage:
from django.db import models
from payme.models import Item, BaseOrder
class Product(models.Model):
item = models.ForeignKey(Item)
image = models.CharField(max_length=255)
desc = models.CharField(max_length=255)
class Order(BaseOrder):
user_id = models.IntegerField()
user_comment = models.CharField(max_length=255)
count of items problem: https://t.me/c/1924284038/1/5680
fixed on version 3+