PayCodes¶
PayCodes serivce enables using codes for payments in TMS transactions
Introduction¶
To start using codes from PayCodes to pay for transactions it it require to prepare cofigured code rules for the codes. Every rule is assigned to an application and has its slug. Rule can also be used to configure price duduction in case the rule is for discount codes.
API method’s description¶
Methods available:
generate_code¶
Method is used for generating new code using the provided code rule
request params: * rule_slug: String * creator: String - name identificating the creator * valid_from: String - date from which the code can be used * valid_to: String - date to which the code can be used
response params: * code: String * pattern: Dictionary - object with patterns attributes * rule: Dictionary - object with rules attributes
{
"rule_slug":"<example-rule>",
"creator": "<creator>",
"valid_from": "2100-09-01",
"valid_to": "2100-11-01"
}
{
'code': 'CLJG1J',
'pattern': {
'pattern': 'ABCDEFGHIJKLMNOPQRSTUWVZ0123456789',
'id': 8,
'slug': 'alfanumeryczne'
},
'rule': {
'code_duration': 1024,
'sap_id': 300481,
'application_id': 20658,
'description': 'testowa',
'price': 123456,
'prod_subcat_id': 1,
'prod_id': 1,
'is_active': True,
'code_expiration': 360,
'channel_id': 5935,
'id': 3,
'pattern_slug': 'alfanumeryczne',
'code_lenght': 6,
'merchant_id': 1,
'slug': 'test',
'config: {
'test': 'test'
}
'prod_cat_id': 1
'code_duration_date': None,
}
}
use_code¶
Method is used to utilate the code and set it status to ‘used’. In case the code had been used already before the status of response would be False
request params: * code: String * rule_slug: String * client: String
response params: * status
{
"code": "Z73HNS73",
"rule_slug": "<example-rule>",
"client": "<client-name>"
}
get_code¶
Method to retreive a given code, eg. to check if it is active and can be used,w
request params: * code: String * rule_slug: String
response params: * status
{
'code': {
'code': 'CLJG1J',
'gen_time': '2014-07-24 18:23:30.586785+02'
'id': 4065441,
'creator': 'pskrzynski2',
'end_time': '2014-07-24 18:23:30.586785+02',
'start_time': '2014-07-24 18:23:30.586785+02',
'rule_slug': 'test',
'use_time': None,
'is_active': True,
'client': None
}
'pattern': {
'pattern': 'ABCDEFGHIJKLMNOPQRSTUWVZ0123456789',
'id': 8,
'slug': 'alfanumeryczne'
},
'rule': {
'code_duration': 1024,
'sap_id': 300481,
'application_id': 20658,
'description': 'testowa',
'price': 123456,
'prod_subcat_id': 1,
'prod_id': 1,
'is_active': True,
'code_expiration': 360,
'channel_id': 5935,
'id': 3,
'pattern_slug': 'alfanumeryczne',
'code_lenght': 6,
'merchant_id': 1,
'slug': 'test',
'config: {
'test': 'test'
}
'prod_cat_id': 1,
'code_duration_date': '2014-07-24 18:23:30.586785+02'
}
}
generate_code_list¶
Method is used for generating a batch of codes using the provided code rule
request params: * rule_slug: String * number_of_codes: int * creator: String - name identificating the creator * valid_from: String - date from which the code can be used * valid_to: String - date to which the code can be used
response params: * codes: List
{
'codes': ['CLJG1J5','CLJG13J','CLJG11J','CLJG13J']
}