new_alipay 0.1.3 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +3 -3
- data/README.md +72 -4
- data/lib/new_alipay/batch_trans.rb +35 -0
- data/lib/new_alipay/version.rb +1 -1
- data/lib/new_alipay.rb +2 -1
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 46625bdc1bd808457c5e746d43e74a5d83e27183
|
4
|
+
data.tar.gz: 53b1202549e0ea1255c2370f147635a2f5cea095
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef2d0e7e85112d78e64f4484412eb2b99749255540c4443251446a83b45b7cbc181a5ba0106bc4ac31eaf19437def966e938ae38643a277153120da28e1bbc84
|
7
|
+
data.tar.gz: 63dee58909b1c66e5729b6f25cb5d80daa388b969294e53ec0878bfb2b8a27fc97696c0d91ceceac3a4cd9755a849d1027d14652a8b5709de36f9e8da9d84cd1
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
new_alipay (0.1.
|
4
|
+
new_alipay (0.1.3)
|
5
5
|
|
6
6
|
GEM
|
7
|
-
remote: https://
|
7
|
+
remote: https://ruby.taobao.org/
|
8
8
|
specs:
|
9
9
|
actionmailer (3.2.21)
|
10
10
|
actionpack (= 3.2.21)
|
@@ -112,4 +112,4 @@ DEPENDENCIES
|
|
112
112
|
rspec (~> 3.2)
|
113
113
|
|
114
114
|
BUNDLED WITH
|
115
|
-
1.
|
115
|
+
1.11.2
|
data/README.md
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
# NewAlipay
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
3
|
+
支付宝快捷支付+支付宝批量付款
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
@@ -22,7 +20,77 @@ Or install it yourself as:
|
|
22
20
|
|
23
21
|
## Usage
|
24
22
|
|
25
|
-
|
23
|
+
###移动支付
|
24
|
+
####配置文件
|
25
|
+
将以下代码写入`config/initializers/new_alipay.rb`
|
26
|
+
```ruby
|
27
|
+
NewAlipay.seller_email='133xxxxyyyy'
|
28
|
+
NewAlipay.partner='2088xxxxxxxxxx'
|
29
|
+
NewAlipay.key='324234kuwerwerwerweewxxxxxxx'
|
30
|
+
```
|
31
|
+
####创建订单
|
32
|
+
```ruby
|
33
|
+
rsa= NewAlipay.mobile_trade_create({
|
34
|
+
notify_url: 'http://test.yourserver.com/',
|
35
|
+
out_trade_no: "#{Time.now.strftime('%Y%m%d%H%M%S')}_#{Random.rand(1000)}",
|
36
|
+
subject: 'test',
|
37
|
+
body: 'test',
|
38
|
+
total_fee: 0.01
|
39
|
+
})
|
40
|
+
#=>输出创建的支付订单的签名字符串
|
41
|
+
```
|
42
|
+
####校验参数(RSA方式)
|
43
|
+
```ruby
|
44
|
+
result = NewAlipay.verify_rsa?({
|
45
|
+
discount: "0.00",
|
46
|
+
payment_type: 1,
|
47
|
+
subject: '100元购买90天(送100元话费)',
|
48
|
+
trade_no: "20150715000010007900xxxxxx",
|
49
|
+
buyer_email: "152xxxxwwww",
|
50
|
+
gmt_create: '2015-07-15 14:36:09',
|
51
|
+
notify_type: 'trade_status_sync',
|
52
|
+
quantity: 1,
|
53
|
+
out_trade_no: '20150715143551584527',
|
54
|
+
seller_id: '2088xxxxxxxxx',
|
55
|
+
notify_time: '2015-07-15 14:36:09',
|
56
|
+
body: '100元购买90天(送100元话费)',
|
57
|
+
trade_status: 'TRADE_FINISHED',
|
58
|
+
is_total_fee_adjust: 'N',
|
59
|
+
total_fee: 0.01,
|
60
|
+
gmt_payment: '2015-07-15 14:36:09',
|
61
|
+
seller_email: "133xxxxyyyy",
|
62
|
+
gmt_close: '2015-07-15 14:36:09',
|
63
|
+
price: 0.01,
|
64
|
+
buyer_id: "208870xxxxxxyyyyy",
|
65
|
+
notify_id: "60f9sd2a318ds12a44165a056xxxxxxx",
|
66
|
+
use_coupon: 'N',
|
67
|
+
sign_type: 'RSA',
|
68
|
+
sign: "xxxxx/yygiAQo9Ey4JkdGSUV+F1xxxxM2Z3pA5C32423cZZjEPiLEURGZpSQ="
|
69
|
+
})
|
70
|
+
puts "\nverify:#{result}\n"
|
71
|
+
#=>true
|
72
|
+
```
|
73
|
+
|
74
|
+
###批量付款
|
75
|
+
####配置文件
|
76
|
+
将以下代码写入`config/initializers/new_alipay.rb`
|
77
|
+
```ruby
|
78
|
+
NewAlipay.seller_email='133xxxxyyyy'
|
79
|
+
NewAlipay.partner='2088xxxxxxxxxx'
|
80
|
+
NewAlipay.key='324234kuwerwerwerweewxxxxxxx'
|
81
|
+
NewAlipay.account_name='xxxx公司/你的真实姓名'
|
82
|
+
```
|
83
|
+
####批量付款(获取url)
|
84
|
+
```ruby
|
85
|
+
|
86
|
+
request_url = NewAlipay::BatchTrans.submit({
|
87
|
+
notify_url: 'http://test.yourserver.com/callback',
|
88
|
+
batch_fee: 0.01,
|
89
|
+
batch_num: 1,
|
90
|
+
detail_data: "#{Time.new.strftime('%Y%m%d')+18.times.inject('') { |acc, i| acc+=('0'..'9').to_a[(i+Random.rand(1000))%10]; acc }}^152xxxxyyyy^某某^0.01^测试支付"
|
91
|
+
|
92
|
+
})
|
93
|
+
```
|
26
94
|
|
27
95
|
## Development
|
28
96
|
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module NewAlipay
|
2
|
+
module BatchTrans
|
3
|
+
|
4
|
+
#支付宝网关地址(新)
|
5
|
+
ALIPAY_GATEWAY_NEW = 'https://mapi.alipay.com/gateway.do?'
|
6
|
+
|
7
|
+
module_function
|
8
|
+
# 建立请求,以表单HTML形式构造(默认)
|
9
|
+
# @param para_temp 请求参数数组
|
10
|
+
# @return 提交表单HTML文本
|
11
|
+
def submit(para_temp)
|
12
|
+
parameters = {
|
13
|
+
"service" => "batch_trans_notify",
|
14
|
+
"partner" => NewAlipay.partner,
|
15
|
+
"notify_url" => para_temp[:notify_url],
|
16
|
+
"email" => NewAlipay.seller_email,
|
17
|
+
"account_name" => NewAlipay.account_name,
|
18
|
+
"pay_date" => Time.new.strftime('%Y-%m-%d'),
|
19
|
+
"batch_no" => Time.new.strftime('%Y%m%d')+16.times.inject('') { |acc, i| acc+=('0'..'9').to_a[(i+Random.rand(1000))%10]; acc },
|
20
|
+
"batch_fee" => para_temp[:batch_fee],
|
21
|
+
"batch_num" => para_temp[:batch_num],
|
22
|
+
"detail_data" => para_temp[:detail_data],
|
23
|
+
"_input_charset" => "utf-8"
|
24
|
+
}
|
25
|
+
signing_str_array = parameters.inject([]) { |memo, (key, v)| memo << "#{key}=#{v}"; memo }
|
26
|
+
sorted_signing_str_array = signing_str_array.sort! { |m, n| m.to_s <=> n.to_s }
|
27
|
+
sign = Digest::MD5.hexdigest(sorted_signing_str_array.join('&')+NewAlipay.key)
|
28
|
+
|
29
|
+
sorted_signing_str_array << "sign=#{sign}" << 'sign_type=MD5'
|
30
|
+
|
31
|
+
"#{ALIPAY_GATEWAY_NEW}#{sorted_signing_str_array.join('&')}"
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
data/lib/new_alipay/version.rb
CHANGED
data/lib/new_alipay.rb
CHANGED
@@ -3,10 +3,11 @@ require "new_alipay/version"
|
|
3
3
|
require "faraday"
|
4
4
|
require 'openssl'
|
5
5
|
require 'base64'
|
6
|
+
require 'new_alipay/batch_trans'
|
6
7
|
|
7
8
|
module NewAlipay
|
8
9
|
class << self
|
9
|
-
attr_accessor :seller_email, :partner, :key
|
10
|
+
attr_accessor :seller_email, :partner, :key, :account_name
|
10
11
|
attr_accessor :rsa_private_key_path, :alipay_public_key_path
|
11
12
|
end
|
12
13
|
module_function
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: new_alipay
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- saxer
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-03-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -80,7 +80,7 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '3.2'
|
83
|
-
description: 支付宝移动支付
|
83
|
+
description: "支付宝移动支付"
|
84
84
|
email:
|
85
85
|
- 15201280641@qq.com
|
86
86
|
executables: []
|
@@ -97,6 +97,7 @@ files:
|
|
97
97
|
- bin/console
|
98
98
|
- bin/setup
|
99
99
|
- lib/new_alipay.rb
|
100
|
+
- lib/new_alipay/batch_trans.rb
|
100
101
|
- lib/new_alipay/version.rb
|
101
102
|
- new_alipay.gemspec
|
102
103
|
- rsa.php
|
@@ -121,8 +122,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
121
122
|
version: '0'
|
122
123
|
requirements: []
|
123
124
|
rubyforge_project:
|
124
|
-
rubygems_version: 2.4.
|
125
|
+
rubygems_version: 2.4.3
|
125
126
|
signing_key:
|
126
127
|
specification_version: 4
|
127
|
-
summary: 支付宝支付
|
128
|
+
summary: "支付宝支付"
|
128
129
|
test_files: []
|