コード例 #1
0
ファイル: rest_api.py プロジェクト: cash2one/Logistics
def api_shop_native_alipay():
    """
    生成支付宝支付二维码
    :return:
    """
    kw = Schema({
        'shop': {
            'id': schema_unicode,
            'name': schema_unicode_empty,
            'tel': schema_unicode_empty,
        },
        'cash': schema_float_2
    }).validate(ctx.request.input())
    # 记录这次尝试
    transact_num = gen_transact_num()
    shop = kw['shop']
    TopUpLogic.create(transact_num=transact_num,
                      shop_id=shop['id'],
                      shop_name=shop['name'],
                      shop_tel=shop['tel'],
                      cash=kw['cash'])
    # 创建预支付交易会话, 获取支付宝支付二维码
    result = alipay_generate_prepay_native(transact_num, kw['cash'])
    if result['result'] == 'success':
        return {'transact_num': transact_num, 'code_url': result['code_url']}
    else:
        raise ValueError('AliPay[NATIVE] Error: %s' % result['msg'])
コード例 #2
0
ファイル: rest_api.py プロジェクト: cash2one/Logistics
def api_shop_app_top_up():
    # shop_id, cash
    kw = ctx.request.input()
    # 记录这次尝试
    transact_num = gen_transact_num()
    kw.transact_num = transact_num
    s = SyncAccount.get_basic_from_id(kw.shop_id)
    kw.shop_name = s['name']
    kw.shop_tel = s['tel']
    TopUpLogic.create(**kw)
    return {
        'transact_num': transact_num,
        'notify_url': WEB_NOTIFY_URL  # 回调接口
    }
コード例 #3
0
ファイル: rest_api.py プロジェクト: cash2one/Logistics
def api_shop_wap_top_up_as_pay():
    # shop_id, cash
    kw = ctx.request.input()
    # 记录这次尝试
    transact_num = gen_transact_num()
    s = Shop.objects(id=kw.shop_id).first()

    # todo 暂时用充值尝试的记录
    TopUpLogic.create(transact_num=transact_num,
                      shop_id=kw.shop_id,
                      shop_name=s.name,
                      shop_tel=s.tel,
                      cash=kw.cash)
    # 创建手机wap转账接口链接
    url = gen_wap_transfer_link(transact_num, kw.cash, '商户现金支付')
    logging.info(url)
    return {'transact_num': transact_num, 'url': url}
コード例 #4
0
ファイル: rest_api.py プロジェクト: cash2one/Logistics
def api_shop_wap_top_up():
    # 输入: shop_id, cash
    kw = ctx.request.input()
    # 记录这次尝试
    transact_num = gen_transact_num()
    kw.transact_num = transact_num
    s = Shop.objects(id=kw.shop_id).first()
    kw.shop_name = s.name
    kw.shop_tel = s.tel
    TopUpLogic.create(**kw)
    # 创建手机wap充值接口链接
    url = create_wap_trade(transact_num, kw.cash, '商户充值')
    logging.info(url)
    # 返回示例 {'transact_num': transact_num,
    #         'url': 'http://wappaygw.alipay.com/service/rest.htm?service=alipay.wap.auth.authAndExecute
    # &format=xml&v=2.0&_input_charset=utf-8
    # &req_data=<auth_and_execute_req><request_token>20160226c760e7d843186665408fa6729ee21979</request_token>
    # </auth_and_execute_req>&sec_id=MD5&partner=2088901729140845&sign=f7d02ce9ece212677a512108687594fb}
    return {'transact_num': transact_num, 'url': url}
コード例 #5
0
ファイル: rest_api.py プロジェクト: cash2one/Logistics
def api_shop_h5_wx_top_up():
    kw = Schema({
        'shop_id': schema_unicode,
        'cash': schema_float_2,
        'code': schema_unicode,  # 用于获取用户标识openid
    }).validate(ctx.request.input())
    code = kw.pop('code')
    # 记录这次尝试
    transact_num = gen_transact_num()
    kw.transact_num = transact_num
    s = Shop.objects(id=kw.shop_id).first()
    kw.shop_name = s.name
    kw.shop_tel = s.tel
    TopUpLogic.create(**kw)
    # 创建预支付交易会话, 获取预支付交易会话标识
    result = wx_generate_prepay_jsapi(transact_num, kw['cash'],
                                      ctx.request.remote_addr, code)
    if result['result'] == 'success':
        return {
            'prepay_id': result['prepay_id'],
        }
    else:
        raise ValueError('wxPay[JSAPI] Error: %s' % result['msg'])
コード例 #6
0
ファイル: rest_api.py プロジェクト: cash2one/Logistics
def api_shop_web_top_up():
    # shop_id, cash
    params = ctx.request.input()
    # 记录这次尝试
    transact_num = gen_transact_num()
    params.transact_num = transact_num
    s = Shop.objects(id=params.shop_id).first()
    params.shop_name = s.name
    params.shop_tel = s.tel
    TopUpLogic.create(**params)
    # 创建PC网页端充值接口链接
    url = create_web_trade(transact_num, params.cash)
    logging.info(url)
    # 返回示例 {
    #     "transact_num": "20160226117671",
    #     "url": "https://mapi.alipay.com/gateway.do?seller_email=abcx%40123feng.com&seller_id=2088901729140845"
    #            "&total_fee=0.01&service=create_direct_pay_by_user"
    #            "&_input_charset=utf-8&sign=d4ee6f2151e2a0aafce26865b4fb4ad9"
    #            "&out_trade_no=20160226117671&payment_type=1"
    #            "&notify_url=http%3A%2F%2F123.57.45.209%3A5000%2Fpay%2Falipay%2Fweb%2Fnotify"
    #            "&sign_type=MD5&partner=2088901729140845&subject=charge",
    # }
    return {'transact_num': transact_num, 'url': url}