notify.py
2.98 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
94
95
96
97
98
99
100
101
102
103
104
105
from _sha256 import sha256
import logging
from agratek.api.merchant.views.notify_vendor import purchase_notify, update_harga, payment_notify
from opensipkd.base import get_settings
from opensipkd.base.models import Partner, flush_row
from opensipkd.pasar.models import H2hArInvoiceDet
from opensipkd.pasar.models.produk import PartnerPay
log = logging.getLogger(__name__)
def proses(data):
settings = get_settings()
mid = 'np_mid' in settings and settings["np_mid"] or None
key = 'np_key' in settings and settings["np_key"] or None
partner = Partner.query_kode("NP").first()
status = str(data["status"])
amount = data["amt"]
tx_id = data["tXid"]
merchant_token = data["merchantToken"]
ref_no = data["referenceNo"]
signature = sha256("{mid}{tx_id}{amount}{key}"\
.format(mid=mid, key=key, amount=str(amount),
tx_id=tx_id))
if merchant_token!=signature:
return
pay = PartnerPay.query_txid(tx_id).filter(cust_inv_no=ref_no).first()
if not pay:
return
result=dict()
pay.notify= dict(response=data,
result=result)
pay.status = 1
flush_row(pay)
payment_notify(pay)
return pay
"""
Common Parameter for Notification
Parameter Type Size Description
tXid N 30 Transaction ID
merchantToken AN 255 Merchant Token
referenceNo N 40 Merchant Order No
payMethod N 2 Payment method. Refer Code at Here
amt N 12 Payment amount
transDt N 8 Transaction date
transTm N 6 Transaction time
currency N 3 Currency
goodsNm N 100 Goods name
billingNm N 30 Billing name
matchCl N 1 Payment amount match flag. Refer Code at Here
status AN 1 Deposit Status
0: Deposit
1: Reversal
Additional Parameter for Credit Card Notification
Parameter Type Size Description
authNo N 10 Approval number
IssueBankCd A 4 Issue bank code. Refer Code at Here
IssueBankNm A Issue bank name.
acquBankCd A Acquire bank code. Refer Code at Here
acquBankNm A Acquire bank name.
cardNo AN 20 Card no with masking
cardExpYymm N Card expiry (YYMM)
instmntMon N 2 Installment month
instmntType N 2 Installment Type. Refer Code at Here
preauthToken AN 255 Preauth Token
recurringToken AN 255 Recurring token
ccTransType AN 2 Credit card transaction type
1: Normal
2: Recurring
3: Pre-auth
4: Captured
vat N 12 Vat number
fee N 12 service fee
notaxAmt N 12 tax free amount
Additional Parameter for Virtual Account Notification
Parameter Type Size Description
bankCd N 4 Bank Code. Refer Code at Here
vacctNo N 16 Bank Virtual Account number
vacctValidDt N 8 VA expiry date
vacctValidTm N 6 VA expiry time
depositDt N Deposit date
depositTm N Deposit time
Additional Parameter for Others Payment Method Notification
Parameter Type Size Description
mitraCd A 4 Mitra Code. Refer Code at Here
payNo N 12 Pay number to mitra
payValidDt N 8 CVS expiry date
payValidTm N 6 CVS expiry time
receiptCode ANS 20 Authorization number
mRefNo AN 18 Bank reference No
depositDt N Deposit date
depositTm N Deposit time
"""