Giter Site home page Giter Site logo

elixir-alipay's Introduction

Alipay

Alipay Elixir SDK

Support API

Installation

If available in Hex, the package can be installed as:

  1. Add alipay to your list of dependencies in mix.exs:
```elixir
def deps do
  [{:alipay, git: "https://github.com/davidqhr/elixir-alipay" }]
end
```
  1. Ensure alipay is started before your application:
```elixir
def application do
  [applications: [:alipay]]
end
```

Usage

policy = %Alipay.Mapi.Policy{ pid: "", key: "", sign_type: "MD5" }

url = Alipay.Mapi.create_direct_pay_by_user_url(policy, %{
  out_trade_no: "no",
  subject: "subject",
  notify_url: "https://example.com",
  return_url: "https://example.com",
  total_fee: "10.00"
})

# open the url in a browser

elixir-alipay's People

Contributors

davidqhr avatar

Stargazers

tt67wq avatar fanspace avatar Yue Zhuo avatar

Watchers

James Cloos avatar  avatar

elixir-alipay's Issues

新版验签需要公钥,大致写了下,如果有兴趣可以加入项目

params=%{"app_id" => "20171021xxxxxx", "auth_app_id" => "2017102109xxxxx",
  "buyer_id" => "2088002xxxxxxxxxxx",
  "buyer_logon_id" => "how***@xxxxx.cn", "buyer_pay_amount" => "0.01",
  "charset" => "utf-8",
  "fund_bill_list" => "[{\"amount\":\"0.01\",\"fundChannel\":\"ALIPAYACCOUNT\"}]",
  "gmt_create" => "2017-10-26 14:05:23", "gmt_payment" => "2017-10-26 14:05:25",
  "invoice_amount" => "0.01",
  "notify_id" => "xxxxxxxxxxxxxxxxxxxxxxxxxx",
  "notify_time" => "2017-10-26 15:29:53", "notify_type" => "trade_status_sync",
  "out_trade_no" => "201710261alipay-198",
  "point_amount" => "0.00", "receipt_amount" => "0.01",
  "seller_email" => "[email protected]", "seller_id" => "208811135xxxxxxxxxxx",
  "sign" => "P458IeGg..............trQ==",
  "sign_type" => "RSA2", "subject" => "1", "total_amount" => "0.01",
  "trade_no" => "2017102621001004390xxxxxxxxxxx",
  "trade_status" => "TRADE_SUCCESS", "version" => "1.0"}

sn = params["sign"]

params = Map.drop(params, ["sign", "sign_type"])

needSigned = Enum.map(params, fn({k, v}) -> "#{k}=#{URI.decode(v)}" end) |> Enum.join("&")

pkeys="-----BEGIN PUBLIC KEY-----\nYOUR public keys...\n-----END PUBLIC KEY-----"

snio= :base64.decode(sn)

spk = :public_key.pem_decode(pkeys) |> hd |> :public_key.pem_entry_decode

s = :public_key.verify(needSigned , :sha256, snio, spk)

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.