pay_info.py
2.48 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
from opensipkd.base.views import BaseView
from opensipkd.pasar.models.produk import PartnerPay
from pyramid.view import view_config
from ..tools import terbilang
import calendar
from datetime import datetime, timedelta
from ..pay_request_tools import methods, vacs, cvss, loans, cps, ems, get_str_hari, get_str_bulan, VA_IMG_SRC
class view_pay(BaseView):
@view_config(route_name = 'pay-info', renderer = 'templates/pay_info.pt')#permission = 'pay-form',
def the_form(self):
request = self.req
session = self.ses
url_dict = request.matchdict
meth = url_dict['meth']
pay_token = url_dict['pay_token']
row_pay = PartnerPay.query().filter(PartnerPay.token_pay_req == pay_token).first()
if meth == 'VA':
subject = 'No. Virtual Account'
content = row_pay.card_no
va_dt = row_pay.inv_valid_date
va_tm = row_pay.inv_valid_time
va_dt = datetime.strptime(va_dt, "%Y%m%d").date()
hari_str = get_str_hari(va_dt.day, va_dt.month, va_dt.year)
bulan_str = get_str_bulan(va_dt.month)
va_tm = datetime.strptime(va_tm, "%H%M%S").time()
jam_str = str(va_tm.hour) + str(va_tm.minute)
# Jum'at, 27 Desember 2019, Pukul 04:44 WIB
dt_tm_str = hari_str + ', ' + str(va_dt.day) + ' ' + bulan_str + ' ' + str(va_dt.year) + ', Pukul ' + str(va_tm) + ' WIB'
denom_str = row_pay.pay_denom
layanan = denom_str.split('-')[1]
img_src = VA_IMG_SRC[layanan]
amount = format(row_pay.amt_sell, ',d').replace(',', '.')
meth = row_pay.pay_req_mth
meth_str = dict(methods)[meth] + ', ' + dict(vacs)[denom_str]
bringback_url = row_pay.bringback_url
elif meth == 'CC':
content = row_pay.card_no
elif meth == 'CVS':
subject = ''
content = ''
elif meth == 'EM':
subject = ''
content = ''
elif meth == 'loan':
subject = ''
content = ''
elif meth == 'CP':
subject = ''
content = ''
return dict(
amount = amount,
dt_tm_str = dt_tm_str,
img_src = img_src,
meth_str = meth_str,
subject = subject,
content = content,
bringback_url = bringback_url
)