def alipay_trade_page(order): """ 页面接口示例:alipay.trade.page.pay,--统一收单下单 """ client = alipay_base_config() # 对照接口文档,构造请求对象 model = AlipayTradePagePayModel() # 必填 model.out_trade_no = order.order_id model.total_amount = str(order.total_price) model.subject = "天天生鲜测试" model.product_code = "FAST_INSTANT_TRADE_PAY" # 选填中有些必填 settle_detail_info = SettleDetailInfo() settle_detail_info.amount = str(order.total_price) # 必填 settle_detail_info.trans_in_type = "userId" # 必填 settle_detail_info.trans_in = settings.ALIPAY_UID # 必填 settle_detail_infos = list() settle_detail_infos.append(settle_detail_info) settle_info = SettleInfo() settle_info.settle_detail_infos = settle_detail_infos model.settle_info = settle_info # 与银行有关 # sub_merchant = SubMerchant() # sub_merchant.merchant_id = "2088301300153242" # model.sub_merchant = sub_merchant request = AlipayTradePagePayRequest(biz_model=model) # 得到构造的请求,如果http_method是GET,则是一个带完成请求参数的url,如果http_method是POST,则是一段HTML表单片段 response = client.page_execute(request, http_method="GET") return response
def get_payment_page(request, houseid): # https://opendocs.alipay.com/apis/api_1/alipay.trade.page.pay model = AlipayTradePagePayModel() # 产品订单号 model.out_trade_no = '202003051646520001' # 订单总金额 model.total_amount = 200 # 订单主题 model.subject = '租房订金' # model.body = '支付宝测试' # 销售产品码,与支付宝签约的产品码名称。 注:目前仅支持FAST_INSTANT_TRADE_PAY model.product_code = 'FAST_INSTANT_TRADE_PAY' # 结算详细信息 settle_detail_info = SettleDetailInfo() settle_detail_info.amount = 200 # 结算收款方的账户类型 settle_detail_info.trans_in_type = 'cardAliasNo' # 结算收款方 settle_detail_info.trans_in = '6216603100004601162' settle_detail_infos = list() settle_detail_infos.append(settle_detail_info) # 结算信息 settle_info = SettleInfo() settle_info.settle_detail_infos = settle_detail_infos model.settle_info = settle_info # sub_merchant = SubMerchant() # sub_merchant.merchant_id = '2088102180149774' # model.sub_merchant = sub_merchant request = AlipayTradePagePayRequest(biz_model=model) url = alipay_client.page_execute(request, http_method='GET') # 此处应该补充生成交易流水的代码 ---> Model # 将用户信息、房源信息、交易编号、交易金额、交易时间、交易状态、……写入数据库 # 还需要一个设计一个接口作为接收通知的接口其中包括对订单交易结果的查询 # 最后还要更新之前的交易流水信息 # request = AlipayTradeQueryRequest(biz_model=model) # content = alipay_client.page_execute(request) return DefaultResponse(data={'url': url})
""" # 对照接口文档,构造请求对象 model = AlipayTradePagePayModel() model.out_trade_no = "pay201805020000226" model.total_amount = 50 model.subject = "测试" model.body = "支付宝测试" model.product_code = "FAST_INSTANT_TRADE_PAY" settle_detail_info = SettleDetailInfo() settle_detail_info.amount = 50 settle_detail_info.trans_in_type = "userId" settle_detail_info.trans_in = "2088302300165604" settle_detail_infos = list() settle_detail_infos.append(settle_detail_info) settle_info = SettleInfo() settle_info.settle_detail_infos = settle_detail_infos model.settle_info = settle_info sub_merchant = SubMerchant() sub_merchant.merchant_id = "2088301300153242" model.sub_merchant = sub_merchant request = AlipayTradePagePayRequest(biz_model=model) # 得到构造的请求,如果http_method是GET,则是一个带完成请求参数的url,如果http_method是POST,则是一段HTML表单片段 response = client.page_execute(request, http_method="GET") print("alipay.trade.page.pay response:" + response) """ 构造唤起支付宝客户端支付时传递的请求串示例:alipay.trade.app.pay """ model = AlipayTradeAppPayModel() model.timeout_express = "90m" model.total_amount = "9.00" model.seller_id = "2088301194649043"