def wx(scharge): content = {} content['bank_billno'] = time.strftime("%Y%m%d") + random_str(10, True) content['bank_type'] = "2032" content['discount'] = "0" content['fee_type'] = "1" content['input_charset'] = "UTF-8" content[ 'notify_id'] = "69-7UJP78XyQUJzZJUD3A71sSfGUr95QPrKFl-aowsQztEG_6TUmyYRyP7PcjHiA3aufQten6HmW0KbnhcCyklRMsrVjYl22" content['out_trade_no'] = scharge['order_no'] content['partner'] = "1224524301" # Channel Parameter content['product_fee'] = str(scharge['amount']) content['sign_type'] = "MD5" content['time_end'] = time.strftime("%Y%m%d%H%M%S") content['total_fee'] = str(scharge['amount']) content['trade_mode'] = "1" content['trade_state'] = "0" content['transaction_id'] = random_str(28, True) content['transport_fee'] = "0" sign_str = '' for k in sorted(content): sign_str += k + "=" + content[k] + "&" sign_str = sign_str + "key=4553960e88b99b76094c14cc278546e0" return content, sign_str
def upmp(scharge): content = {} content['orderTime'] = time.strftime("%Y%m%d%H%M%S") content['settleDate'] = time.strftime("%m%d") content['orderNumber'] = scharge['order_no'] content['exchangeRate'] = "0" content['settleCurrency'] = "156" content['transType'] = "04" # 01:paid 04: refund succeed content['respCode'] = "00" content['charset'] = "UTF-8" traceNumber = random_str(6, True) traceTime = content['orderTime'][4:] acqCode = random_str(8, True) content['sysReserved'] = "{{traceTime={0}&acqCode={1}&traceNumber={2}}}".format(traceTime, acqCode, traceNumber) content['version'] = "1.0.0" content['settleAmount'] = str(scharge['amount']) content['transStatus'] = "00" content['merId'] = "802310048993293" content['qn'] = content['orderTime'] + traceNumber + random_str(1, True) sign_str = '' for k in sorted(content): sign_str += k + "=" + content[k] + "&" # MD5 encryption for the key 'lxwCOpO2WPEss4Eit4cnr9xCEXRIiUTU' from upmp_secret sign_str = sign_str + "bd0c7aa7f01c9710a9de408903d955c8" return content, sign_str.encode('utf-8')
def jdpay_wap(): env_name, root_url, live_key, app_id = datagen.get_current_env() url = "{0}/v1/charges".format(root_url) # request body charge = Model.ChargeBase.ChargeDict charge['order_no'] = random_str(10) charge['subject'] = 'TestOrder4jdpay_wap' charge['body'] = 'appletest4Pay' charge['amount'] = 10 charge['channel'] = 'jdpay_wap' charge['currency'] = 'cny' charge['client_ip'] = '127.0.0.1' id = [('id', app_id)] extra = [("success_url", "http://pingxx.com"), ("fail_url", "htpps://pingxx.com")] charge['app'] = dict(id) charge['extra'] = dict(extra) mycharge = APIClient._http_call(url, "post", "json", "json", None, {"Authorization": "Bearer {0}".format(live_key)}, 30, **charge) print(mycharge) sshCmd.ssh_cmd("114.215.237.77", "56f27c2B", "echo "">/var/www/example/ziteng") threading._start_new_thread(sshCmd.ssh_cmd("114.215.237.77", "56f27c2B", "echo "">/var/www/example/ziteng")) time.sleep(5) Forward.forward_json(mycharge) ret = sshCmd.ssh_cmd("114.215.237.77", "56f27c2B", "echo "">/var/www/example/ziteng") print ret if int(filter(lambda x: x.isdigit(), ret)) > 1: print "The charge file had updated on %s" % ctime() else: print "forward the charge to update file again..." threading._start_new_thread(sshCmd.ssh_cmd("114.215.237.77", "56f27c2B", "echo "">/var/www/example/ziteng")) time.sleep(2) Forward.forward_json(mycharge)
def base(is_private,channel, needforward=True, **extra): if is_private == False: env_name, root_url, live_key, app_id = datagen.get_current_env() else: env_name, root_url, live_key, app_id = datagen.get_my_env() url = "{0}/v1/charges".format(root_url) # request body charge = Model.ChargeBase.ChargeDict() charge['order_no'] = random_str(10) charge['subject'] = "Autopay_TestOrder4{0}".format(channel) charge['body'] = "appletesting4Pay" charge['amount'] = 10 charge['channel'] = channel charge['currency'] = "cny" charge['client_ip'] = "127.0.0.1" id = [("id", app_id)] charge['app'] = dict(id) charge['extra'] = extra myCharge = APIClient._http_call(url, "POST", "json", "json", None, {"Authorization": "Bearer {0}".format(live_key)}, 30, **charge) print(myCharge) if (needforward): time.sleep(5) Forward.forward_json(myCharge) else: return myCharge
def bfb(scharge): content = {} content['bank_no'] = "" content['bfb_order_create_time'] = time.strftime("%Y%m%d%H%M%S") content['bfb_order_no'] = random_str(31, True) content['buyer_sp_username'] = "" content['currency'] = "1" content['extra'] = scharge['id'] content['fee_amount'] = "0" content['input_charset'] = "1" content['order_no'] = scharge['order_no'] content['pay_result'] = "1" content['pay_time'] = time.strftime("%Y%m%d%H%M%S") content['pay_type'] = "2" content['sign_method'] = "1" content['sp_no'] = "1500300006" content['total_amount'] = str(int(scharge['amount'])) content['transport_amount'] = "0" content['unit_amount'] = content['total_amount'] content['unit_count'] = "1" content['version'] = "2" sign_str = '' for k in sorted(content): sign_str += k + "=" + content[k] + "&" sign_str = sign_str + "key=w837cG3xQk2KMQ3EZVdByEryJpTN7MzC" return content, sign_str
def alipay(scharge): trade_no = "".join(map(str, [random.choice(string.digits) for i in range(20)])) notify_id = random_str(34) content = {} content['discount'] = "0.00" content['payment_type'] = "1" content['subject'] = scharge['subject'] content['trade_no'] = trade_no content['buyer_email'] = "*****@*****.**" content['gmt_create'] = time.strftime('%Y-%m-%d %H:%M:%S', time.gmtime(float(scharge['created']))) content['notify_type'] = "trade_status_sync" content['quantity'] = "1" content['out_trade_no'] = scharge['order_no'] content['seller_id'] = "2088711316963982" content['notify_time'] = time.strftime("%Y-%m-%d %H:%M:%S") content['body'] = scharge['body'] content['trade_status'] = "TRADE_SUCCESS" content['is_total_fee_adjust'] = "N" content['total_fee'] = str("%.2f"%(int(scharge['amount']) /100)) content['gmt_payment'] = time.strftime("%Y-%m-%d %H:%M:%S") content['seller_email'] = "*****@*****.**" content['price'] = content['total_fee'] content['buyer_id'] = "2088002603371617" content['notify_id'] = notify_id content['use_coupon'] = "N" sign_str = '' for k in sorted(content): sign_str += k + "=" + content[k] + "&" sign_str = sign_str[:-1] # print sign_str return content, sign_str.encode('utf-8')
def upacp(scharge): content = {} content['accessType'] = "0" content['bizType'] = "000000" content['certId'] = "21267647932558653966460913033289351200" content['currencyCode'] = "156" content['encoding'] = "UTF-8" content['merId'] = "802310048993438" content['orderId'] = scharge['order_no'] content['txnTime'] = time.strftime("%Y%m%d%H%M%S") # yyyyMMddHHmmss content['traceNo'] = random_str(6, True) content['queryId'] = "201507301809011396558" # content['txnTime'] + content['traceNo'] + "8" content['reqReserved'] = scharge['id'] content['respCode'] = "00" content['respMsg'] = "Success!" content['settleAmt'] = str(scharge['amount']) content['settleCurrencyCode'] = "156" content['settleDate'] = time.strftime("%m%d") # MMdd content['signMethod'] = "01" content['txnAmt'] = str(scharge['amount']) content['txnSubType'] = "01" content['traceTime'] = time.strftime("%m%d%H%M%S") content['txnType'] = "01" content['version'] = "5.0.0" sign_str = '' for k in sorted(content): sign_str += k + "=" + content[k] + "&" sign_str = sign_str[:-1] # print sign_str return content, sign_str.encode('utf-8')
def yeepay_wap(scharge): content = {} content['amount'] = str(scharge['amount']) content['bank'] = '招商银行' content['bankcode'] = 'CMB' content['cardtype'] = '1' content['lastno'] = random_str(4, True) content['merchantaccount'] = '10012446009' # from channel parameter: yeepay_mer_id content['orderid'] = str(scharge['order_no']) content['status'] = '1' content['yborderid'] = random_str(18, True) sign_str = '' for k in sorted(content): sign_str += content[k] return content, sign_str.encode('utf-8')
def bfb(): env_name, root_url, test_key, app_id = datagen.get_my_test_env() url = "{0}/v1/charges".format(root_url) # request body charge = Model.ChargeBase.Charge() charge.order_no = random_str(10) charge.channel = "bfb" myCharge = APIClient._http_call(url, "POST", "json", "json", None, {"Authorization": "Bearer {0}".format(test_key)}, 30, subject=charge.subject, body=charge.body, app={"id": charge.app.id}, amount=charge.amount, channel=charge.channel, client_ip=charge.client_ip, currency=charge.currency, order_no=charge.order_no) return myCharge["id"]
def wx_pub(scharge, isQR=False): content = {} content['appid'] = "wx95df8698f12122c7" content['bank_type'] = "CFT" if isQR else "CMB_CREDIT" content['cash_fee'] = str(scharge['amount']) content['fee_type'] = "CNY" content['is_subscribe'] = "Y" content['mch_id'] = "10037269" content['nonce_str'] = random_str(32) content['openid'] = "o9zpMs5MW2-62GAy5hRrjdYVCktU" if isQR else scharge['extra']['open_id'] content['out_trade_no'] = scharge['order_no'] content['result_code'] = "SUCCESS" content['return_code'] = "SUCCESS" content['time_end'] = time.strftime("%Y%m%d%H%M%S") content['total_fee'] = str(scharge['amount']) content['trade_type'] = "NATIVE" if isQR else "JSAPI" content['transaction_id'] = random_str(28, True) sign_str = '' for k in sorted(content): sign_str += k + "=" + content[k] + "&" sign_str = sign_str + "key=XA3FIAMP35I0PUVG429N0J66F9JCB5VE" # from channel parameter:wx_pub_key return content, sign_str
def bfb(): env_name, root_url, live_key, app_id = datagen.get_current_env() url = "{0}/v1/charges".format(root_url) # request body charge = Model.ChargeBase.Charge() charge.order_no = random_str(10) charge.channel = "bfb" myCharge = APIClient._http_call(url, "POST", "json", "json", None, {"Authorization": "Bearer {0}".format(live_key)}, 30, subject=charge.subject, body=charge.body, app={"id": charge.app.id}, amount=charge.amount, channel=charge.channel, client_ip=charge.client_ip, currency=charge.currency, order_no=charge.order_no) # Get the charge info(json) and send to another API for forward #And the demo app will receive the charge Info for pay #print(myCharge) Forward.forward_json(myCharge)
def yeepay_wap(): env_name, root_url, live_key, app_id = datagen.get_current_env() url = "{0}/v1/charges".format(root_url) # request body charge = Model.ChargeBase.ChargeDict() charge['order_no'] = random_str(10) charge['subject'] = "TestOrder4YeepayWap" charge['body'] = "appletesting4Pay" charge['amount'] = 10 charge['channel'] = "yeepay_wap" charge['currency'] = "cny" charge['client_ip'] = "127.0.0.1" id = [("id", app_id)] extra = [("product_category", "1"), ("identity_id", "d2:bf:11:78:09:69"), ("identity_type", "0"), ("terminal_type", "1"), ("terminal_id", "d2:bf:11:78:09:69"), ("user_ua", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:36.0) Gecko/20100101 Firefox/36.0"), ("result_url", "https://pingxx.com")] charge['extra'] = dict(extra) charge['app'] = dict(id) myCharge = APIClient._http_call(url, "post", "json", "json", None, {"Authorization": "Bearer {0}".format(live_key)}, 30, **charge) print(myCharge) sshCmd.ssh_cmd("114.215.237.77", "56f27c2B", "echo "">/var/www/example/ziteng.php") threading._start_new_thread(sshCmd.ssh_cmd, ("114.215.237.77", "56f27c2B", "php /var/www/example/client4ziteng.php")) time.sleep(5) Forward.forward_json(myCharge) ret = sshCmd.ssh_cmd("114.215.237.77", "56f27c2B", "echo $(stat -c %s /var/www/example/ziteng.php)") print ret if int(filter(lambda x: x.isdigit(), ret)) > 1: print "The charge file had updated on %s" % ctime() else: print "forward the charge to update the file again..." threading._start_new_thread(sshCmd.ssh_cmd, ("114.215.237.77", "56f27c2B", "php /var/www/example/client4ziteng.php")) time.sleep(2) Forward.forward_json(myCharge)
def bfb_wap(): env_name, root_url, live_key, app_id = datagen.get_current_env() url = "{0}/v1/charges".format(root_url) # request body charge = Model.ChargeBase.ChargeDict() charge['order_no'] = random_str(10) charge['subject'] = "TestOrder4bfbWap" charge['body'] = "appletesting4Pay" charge['amount'] = 10 charge['channel'] = "bfb_wap" charge['currency'] = "cny" charge['client_ip'] = "127.0.0.1" id = [("id", app_id)] extra = [("result_url", "http://pingxx.com"), ("bfb_login", "false")] charge['extra'] = dict(extra) charge['app'] = dict(id) myCharge = APIClient._http_call(url, "POST", "json", "json", None, {"Authorization": "Bearer {0}".format(live_key)}, 30, **charge) print(myCharge) sshCmd.ssh_cmd("114.215.237.77", "56f27c2B", "echo "">/var/www/example/ziteng.php") threading._start_new_thread(sshCmd.ssh_cmd, ("114.215.237.77", "56f27c2B", "php /var/www/example/client4ziteng.php")) time.sleep(5) Forward.forward_json(myCharge) ret = sshCmd.ssh_cmd("114.215.237.77", "56f27c2B", "echo $(stat -c %s /var/www/example/ziteng.php)") print ret if int(filter(lambda x: x.isdigit(), ret)) > 1: print "The charge file had updated on %s" % ctime() else: print "forward the charge to update the file again..." threading._start_new_thread(sshCmd.ssh_cmd, ("114.215.237.77", "56f27c2B", "php /var/www/example/client4ziteng.php")) time.sleep(2) Forward.forward_json(myCharge)
def alipay(): """ 1- Generate the charge via API 2- Forward the charge so that the demoapp will reflush """ env_name, root_url, live_key, app_id = datagen.get_current_env() url = "{0}/v1/charges".format(root_url) # request body charge = Model.ChargeBase.Charge() charge.order_no = random_str(10) # myCharge = APIClient._http_call(url,"POST","json","json",None,{"Authorization":"Bearer sk_live_vjfr90jj1q985KuPO84iP8KO"},30,charge.__dict__) myCharge = APIClient._http_call(url, "POST", "json", "json", None, {"Authorization": "Bearer {0}".format(live_key)}, 30, subject=charge.subject, body=charge.body, app={"id": charge.app.id}, amount=charge.amount, channel=charge.channel, client_ip=charge.client_ip, currency=charge.currency, order_no=charge.order_no) #Get the charge info(json) and send to another API for forward #And the demo app will receive the charge Info for pay print(myCharge) Forward.forward_alipay(myCharge)
def alipay_wap(scharge): trade_no = "".join(map(str, [random.choice(string.digits) for i in range(20)])) notify_id = random_str(34) #由于对字段顺序有要求,所以使用OrderedDict content=OrderedDict([("payment_type","1"),\ ('subject',scharge['subject']),\ ('trade_no',trade_no),\ ("buyer_email","*****@*****.**"),\ ("gmt_create",time.strftime('%Y-%m-%d %H:%M:%S', time.gmtime(float(scharge['created'])))),\ ("notify_type","trade_status_sync"),\ ("quantity","1"),\ ("out_trade_no",scharge['order_no']),\ ("notify_time",time.strftime("%Y-%m-%d %H:%M:%S")),\ ("seller_id","2088711316963982"),\ ("trade_status","TRADE_SUCCESS"),\ ("is_total_fee_adjust","N"),\ ("total_fee",str("%.2f"%(int(scharge['amount']) /100))),\ ("gmt_payment",time.strftime("%Y-%m-%d %H:%M:%S")),\ ("seller_email","*****@*****.**"),\ ("price",str("%.2f"%(int(scharge['amount']) /100))),\ ("buyer_id","2088202893408772"),\ ("notify_id",notify_id),\ ("use_coupon","N")]) return content