Giter Club home page Giter Club logo

baidupay's Introduction

Baidupay

百度商户平台支付 ruby gem。使用之前请先阅读 https://dianshang.baidu.com/platform/doclist/index.html#!/home

注:所有代码均魔改自 Rei 的 alipay,因百度电商平台功能比较少,所以代码砍了很多。

Installation

Add this line to your application's Gemfile:

gem 'baidupay'

And then execute:

$ bundle

Or install it yourself as:

$ gem install baidupay

Usage

在开始使用之前,需要准备 4 项配置:

  1. DEAL_ID:跳转百度收银台支付必带参数之一,是百度收银台的财务结算凭证,与账号绑定的结算协议一一对应,每笔交易将结算到dealId对应的协议主体。
  2. APP_KEY:用以表示应用身份的唯一id,在应用审核通过后进行分配,一经分配后不会发生更改,来唯一确定一个应用。
  3. PUBLIC_KEY: 平台请求TP应用时,TP用于验签使用的公钥,在应用审核通过后分配,一经分配不会发生更改,每个应用对应不同的平台公钥。
  4. PRIVATE_KEY: 进行 RSA 签名计算时候需要用,该密钥由本地生成,需要将对应的公钥上传自百度商户平台,平台用于验签使用,需要在申请应用时填写。

建立一个客户端以便快速调用API:

@client = Alipay::Client.new(
  deal_id: DEAL_ID,
  app_key: APP_KEY,
  public_key: PUBLIC_KEY,
  private_key: PRIVATE_KEY
)

计算签名:

@client.sign(tp_order_id: 'NO129388445') #=> 'eKn5tjMLugCvU4nv9WjwIN7+AEb3l13fKUWqYMnQpkwmo+...'

验证异步通知:

if @client.verify?(request.request_parameters)
  render plain: 'success'
end

License

The gem is available as open source under the terms of the MIT License.

baidupay's People

Contributors

giaogiaocat avatar

Stargazers

 avatar  avatar

Watchers

 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.