GithubHelp home page GithubHelp logo

global-open.-sdk-python's Introduction

Language:Python  
Python version:2.6+  
Copyright:Ant financial services group  

1 The sample for pay

    default_alipay_client = DefaultAlipayClient("https://open-na.alipay.com", client_id, MERCHANT_PRIVATE_KEY, ALIPAY_PUBLICK_KEY)

    alipay_pay_request = AlipayPayRequest()
    alipay_pay_request.path = "/ams/sandbox/api/v1/payments/pay"

    alipay_pay_request.product_code = ProductCodeType.AGREEMENT_PAYMENT
    alipay_pay_request.payment_notify_url = "https://www.merchant.com/notify"
    alipay_pay_request.payment_redirect_url = "https://www.merchant.com?param1=sl"
    alipay_pay_request.payment_request_id = "pay_python_test"

    payment_method = PaymentMethod()
    payment_method.payment_method_type = "GCASH"
    payment_method.payment_method_id = "20200404095550158596535057754730166962669640ZMvNAaATop"
    alipay_pay_request.payment_method = payment_method

    amount = Amount("PHP", "10000")
    alipay_pay_request.payment_amount = amount

    order = Order()
    order.reference_order_id = "102775765675669"
    order.order_description = "Mi Band 3 Wrist Strap Metal Screwless Stainless Steel For Xiaomi Mi Band 3"
    order.order_amount = amount

    goods_arr = []
    good = Goods()
    good.goods_brand = "goods_brand"
    good.goods_name = "goods_name"
    goods_arr.append(good)
    order.goods = goods_arr

    merchant = Merchant()
    merchant.merchant_mcc = "merchantMcc"
    merchant.reference_merchant_id = "referenceMerchantId"

    order.merchant = merchant
    alipay_pay_request.order = order

    settlement_strategy = SettlementStrategy()
    settlement_strategy.settlement_currency = "USD"
    alipay_pay_request.settlement_strategy = settlement_strategy

    env = Env()
    env.terminal_type = TerminalType.APP
    env.os_type = OsType.IOS
    alipay_pay_request.env = env

    # alipay_pay_request.is_authorization = "true"

    print(alipay_pay_request.to_ams_json())

    rsp_body = default_alipay_client.execute(alipay_pay_request)

    alipay_pay_response = AlipayPayResponse(rsp_body)

    if alipay_pay_response.result.result_status.name != ResultStatusType.F.name:
        print(alipay_pay_response.payment_id)
        print(alipay_pay_response.payment_create_time)
    else:
        print(alipay_pay_response.result.result_message)

2 If you don't care about HTTP calls,the sample for sign and verify

from com.alipay.ams.api.tools.signature_tool import *

sign(http_method, path, client_id, req_time, req_body, merchant_private_key)
verify(http_method, path, client_id, rsp_time, rsp_body, rsp_signature, alipay_public_key)

global-open.-sdk-python's People

Contributors

lifelong-creator avatar antfin-oss avatar tcboy avatar antintlwuyu avatar gsysniff avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.