Skip to content

Commit 07bd659

Browse files
author
Lh4cKg
committed
added tbcpay module
1 parent 5f12978 commit 07bd659

File tree

21 files changed

+724
-0
lines changed

21 files changed

+724
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ docs/_build/
6666

6767
# PyBuilder
6868
target/
69+
.idea/
70+
.idea
6971

7072
# Jupyter Notebook
7173
.ipynb_checkpoints

payment/__init__.py

Whitespace-only changes.

payment/admin.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.contrib import admin
2+
3+
# Register your models here.

payment/apps.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# _*_ coding: utf-8 _*_
2+
3+
"""
4+
Created on Jul 14, 2017
5+
6+
@author: Lasha Gogua
7+
"""
8+
9+
from django.apps import AppConfig
10+
11+
12+
class PaymentConfig(AppConfig):
13+
label = 'payment'
14+
name = 'payment'
15+
verbose_name = 'Payment'

payment/config.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# _*_ coding: utf-8 _*_
2+
3+
"""
4+
Created on Jul 14, 2017
5+
6+
@author: Lasha Gogua
7+
"""
8+
9+
from collections import OrderedDict
10+
11+
12+
PAYMENT_MODULES = OrderedDict(
13+
{
14+
"tbc":
15+
{
16+
"display_name": "თიბისი",
17+
"payment_type": "plastic_card",
18+
"module_name": "tbc",
19+
"image": "tbc.jpg",
20+
"min_limit": 1,
21+
"max_limit": 1000,
22+
"ufc_merchant_key": "TbcMerchant",
23+
"merchant_url": "https://securepay.ufc.ge:18443/ecomm2/MerchantHandler",
24+
"customer_url": "https://securepay.ufc.ge/ecomm2/ClientHandler",
25+
"merchant": {
26+
"MerchantName": "მერჩანტის უნიკალური იდენტიფიკატორი",
27+
"Currency": "981",
28+
"Password": "მერჩანტის პაროლი",
29+
"KeyFile": "სერტიფიკატის პაროლის ფაილის სახელი, მაგ. 0000000-Key",
30+
"Description": "აღწერა",
31+
},
32+
"is_testing": True,
33+
},
34+
},
35+
)
36+
37+
38+
# currency codes (ISO 4217)
39+
# https://en.wikipedia.org/wiki/ISO_4217
40+
41+
CURRENCY_CODES = OrderedDict(
42+
{
43+
'GEL': 981,
44+
'USD': 840,
45+
'EUR': 978,
46+
}
47+
)

payment/crypto/__init__.py

Whitespace-only changes.

payment/crypto/crypto.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# _*_ coding: utf-8 _*_
2+
3+
"""
4+
Created on Jul 14, 2017
5+
6+
@author: Lasha Gogua
7+
"""
8+
9+
from OpenSSL import crypto
10+
11+
12+
def p12_to_pem(cert=None, password=None, file_name=None, output=None):
13+
"""
14+
p12 certificate convert to pem format
15+
:param cert: Certificate absolute path
16+
:param password: Certificate passphrase
17+
:param file_name: Certificate file name
18+
:param output: Certificate output directory
19+
:return: certificate and key in pem format
20+
"""
21+
22+
if not (cert or password):
23+
cert = input('Enter Certificate absolute path: \n')
24+
password = input('Enter Certificate passphrase: \n')
25+
26+
with open(cert, 'rb') as f:
27+
c = f.read()
28+
29+
p12 = crypto.load_pkcs12(c, password)
30+
31+
pem_dump_cert = crypto.dump_certificate(crypto.FILETYPE_PEM, p12.get_certificate())
32+
pem_dump_key = crypto.dump_privatekey(crypto.FILETYPE_PEM, p12.get_privatekey())
33+
34+
pem_cert = pem_dump_cert + pem_dump_key
35+
36+
with open('%s%s.pem' % (output or '', file_name or p12.get_friendlyname()), 'wb') as pem:
37+
pem.write(pem_cert)
38+
39+
with open('%s%s-key.pem' % (output or '', file_name or p12.get_friendlyname()), 'wb') as pem_key:
40+
pem_key.write(pem_dump_key)
41+
42+
return pem, pem_key

payment/migrations/__init__.py

Whitespace-only changes.

payment/models.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# _*_ coding: utf-8 _*_
2+
3+
"""
4+
Created on Jul 14, 2017
5+
6+
@author: Lasha Gogua
7+
"""
8+
9+
from django.conf import settings
10+
from django.db import models
11+
12+
13+
class Transaction(models.Model):
14+
transaction_id = models.CharField('Transaction Identifier', max_length=64, unique=True)
15+
status = models.CharField('Status', max_length=10)
16+
status_code = models.PositiveIntegerField('Status Code', default=0)
17+
amount = models.DecimalField('Amount', decimal_places=2, max_digits=12, null=True)
18+
currency = models.CharField('Currency', max_length=5)
19+
basket = models.BigIntegerField('Basket', null=True, blank=True)
20+
provider = models.CharField('Provider', max_length=500, null=True, blank=True)
21+
created_at = models.DateTimeField(auto_now_add=True)
22+
updated_at = models.DateTimeField(auto_now=True)
23+
24+
class Meta:
25+
db_table = 'payment_transactions'
26+
verbose_name = 'Transaction'
27+
verbose_name_plural = 'Transactions'
28+
29+
def __str__(self):
30+
return 'Status: %s - Status Code: %s - Transaction ID: %s' % (self.status, self.status_code, self.transaction_id)

payment/static/images/tbc.jpg

3.44 KB
Loading

0 commit comments

Comments
 (0)