Commit 2d546897 authored by RobertDing's avatar RobertDing

ADD - 绑定银行卡

parent aecd254e
__pycache__
*.swp
#!/usr/bin/env python
# -*- coding:utf-8 -*-
#
# Author : RobertDing
# E-mail : robertdingx@gmail.com
# Date : 16/06/13 21:19:05
# Desc : 借款相关接口测试
#
import json
import datetime
import request
import settings
req = request.Request('apiBorrower')
class RunHelper(object):
def run(self):
print(self.params)
content = req.handler(self.endpoint)(**self.params)
raw = json.loads(content)
print(raw)
class Register(RunHelper):
def __init__(self):
self.params = {
'mobile': '18518756705',
'password': '88889999',
'channel': settings.CHANNEL,
#'partnerId': 'wx12313',
'idType': 1,
'idNo': '412725199208183032',
'name': '丁英才',
'sendPassword': 0,
}
self.endpoint = 'registerAndVerify'
class CheckBank(RunHelper):
def __init__(self):
self.params = {
'uid': settings.UID,
'bank': 'CCB',
'cardNo': '6225096554333',
'phone': '18518756705',
'province': '广东',
'city': '广州',
}
self.endpoint = 'checkSecureBank'
pass
class BindBank(RunHelper):
def __init__(self):
self.params = {
'uid': settings.UID,
'verifiedData': json.dumps(settings.verifiedData),
'smsCode': settings.SMSCODE
}
self.endpoint = 'bindSecureBank'
pass
class CreateLoad(RunHelper):
def __init__(self):
self.params = {
'uid': settings.UID,
'type': 123,
'applyTime': int(datetime.datetime.now().timestamp()),
'amount': 10000,
'periodType': 30,
'periods': 1,
'repayType': 2,
}
self.endpoint = 'createLoan'
pass
......@@ -24,7 +24,8 @@ class Request(object):
URL = settings.BASE_URL
def __init__(self):
def __init__(self, subject):
self.subject = subject
yingtz_key = base64.b64decode(open(settings.YINGTZ_KEY_TEST).read())
self.yingtz_key = RSA.importKey(yingtz_key)
self.gmei_key = RSA.importKey(open(settings.GMEI_PRIVATE_KEY_PKCS8).read())
......@@ -34,9 +35,11 @@ class Request(object):
def _fetch(**kwargs):
params = self.encrypt_param(kwargs)
resp = requests.post(self.URL+endpoint, data=params)
url = settings.BASE_URL.format(
subject=self.subject, endpoint=endpoint)
resp = requests.post(url, data=params)
content = self.decrypt(resp.content)
return content
return str(content, encoding='utf8')
return _fetch
def encrypt_param(self, params):
......
......@@ -7,7 +7,7 @@
# Desc :
#
BASE_URL = 'http://www.xiaoying.com/api/apiBorrower/'
BASE_URL = 'http://www.xiaoying.com/api/{subject}/{endpoint}'
MD5KEY = bytes('74ba4d7ad1d5bc705e6c96bbf599c3f1', encoding='utf8')
PARTNER = 'WEI_ZHENG_FEN_QI'
......@@ -16,3 +16,17 @@ YINGTZ_KEY_TEST = 'yingtz_key_test.pem'
YINGTZ_KEY_PROD = 'yingtz_key_prod.pem'
GMEI_PRIVATE_KEY = 'gmei_private_key.pem'
GMEI_PRIVATE_KEY_PKCS8 = 'gmei_private_key_pkcs8.pem'
UID = 69013645522124800
verifiedData = {
'cardNo': '6225096554333',
'ticket': '69014705305616384',
'phone': '18518756705',
'bankName': '中国建设银行',
'bankCode': 'CCB',
'quickPay': False
}
SMSCODE = '298578'
CARDID = '104599'
BANKCARDID = '1112864'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment