Example #1
0
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)