-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathsale-using-emv-technology-with-contactless.py
More file actions
93 lines (76 loc) · 3.46 KB
/
Copy pathsale-using-emv-technology-with-contactless.py
File metadata and controls
93 lines (76 loc) · 3.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
from CyberSource import *
from pathlib import Path
import os
import json
from importlib.machinery import SourceFileLoader
config_file = os.path.join(os.getcwd(), "data", "Configuration.py")
configuration = SourceFileLoader("module.name", config_file).load_module()
# To delete None values in Input Request Json body
def del_none(d):
for key, value in list(d.items()):
if value is None:
del d[key]
elif isinstance(value, dict):
del_none(value)
return d
def sale_using_emv_technology_with_contactless():
clientReferenceInformationCode = "123456"
clientReferenceInformation = Ptsv2paymentsClientReferenceInformation(
code = clientReferenceInformationCode
)
processingInformationCapture = False
processingInformationCommerceIndicator = "retail"
processingInformation = Ptsv2paymentsProcessingInformation(
capture = processingInformationCapture,
commerce_indicator = processingInformationCommerceIndicator
)
orderInformationAmountDetailsTotalAmount = "100.00"
orderInformationAmountDetailsCurrency = "USD"
orderInformationAmountDetails = Ptsv2paymentsOrderInformationAmountDetails(
total_amount = orderInformationAmountDetailsTotalAmount,
currency = orderInformationAmountDetailsCurrency
)
orderInformation = Ptsv2paymentsOrderInformation(
amount_details = orderInformationAmountDetails.__dict__
)
pointOfSaleInformationCatLevel = 2
pointOfSaleInformationEntryMode = "contactless"
pointOfSaleInformationTerminalCapability = 2
pointOfSaleInformationEmvCardSequenceNumber = "999"
pointOfSaleInformationEmvFallback = False
pointOfSaleInformationEmv = Ptsv2paymentsPointOfSaleInformationEmv(
card_sequence_number = pointOfSaleInformationEmvCardSequenceNumber,
fallback = pointOfSaleInformationEmvFallback
)
pointOfSaleInformationTrackData = "%B38000000000006^TEST/CYBS ^2012121019761100 00868000000?;38000000000006=20121210197611868000?"
pointOfSaleInformation = Ptsv2paymentsPointOfSaleInformation(
cat_level = pointOfSaleInformationCatLevel,
entry_mode = pointOfSaleInformationEntryMode,
terminal_capability = pointOfSaleInformationTerminalCapability,
emv = pointOfSaleInformationEmv.__dict__,
track_data = pointOfSaleInformationTrackData
)
requestObj = CreatePaymentRequest(
client_reference_information = clientReferenceInformation.__dict__,
processing_information = processingInformation.__dict__,
order_information = orderInformation.__dict__,
point_of_sale_information = pointOfSaleInformation.__dict__
)
requestObj = del_none(requestObj.__dict__)
requestObj = json.dumps(requestObj)
try:
config_obj = configuration.Configuration()
client_config = config_obj.get_configuration()
api_instance = PaymentsApi(client_config)
return_data, status, body = api_instance.create_payment(requestObj)
print("\nAPI RESPONSE CODE : ", status)
print("\nAPI RESPONSE BODY : ", body)
write_log_audit(status)
return return_data
except Exception as e:
write_log_audit(e.status if hasattr(e, 'status') else 999)
print("\nException when calling PaymentsApi->create_payment: %s\n" % e)
def write_log_audit(status):
print(f"[Sample Code Testing] [{Path(__file__).stem}] {status}")
if __name__ == "__main__":
sale_using_emv_technology_with_contactless()