allpay_client 1.0.4 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d0dc91e62719b5beef1b386aa488b966aac8f6a4
4
- data.tar.gz: c060ead749df6faa544b73f3771a6fe8cc32da81
3
+ metadata.gz: 5f2ea281442ca99d54d3bc51dc63afd1fce0989b
4
+ data.tar.gz: 31660c2bdb5fcc1aa177ac87e1e9883dad3aa751
5
5
  SHA512:
6
- metadata.gz: e0e1a0ff79f7844ac3cdc6355d685ff1e43e0eaea03e1dfd6f20e6fe672cca9aa96cb026c47336fd28da9e51203f30f8e798a702f5f513e9b31ef9def5d7e63e
7
- data.tar.gz: 8002279de2c2d4fb5fefc69635f55f23d73dd5f59fed8fc3d66339034f7124924e029345660f08084d6b8c8f2c77fa4cd34032561192481500740a63706ca79c
6
+ metadata.gz: c31fc37d54e1759313214f633b7583af1ed4626bef102ab619b0ff545b0e5c61f9bbdb70f006e742633759f289715dbb40db3d55690509ba59627bf5e2751219
7
+ data.tar.gz: 60129cf16cdb2f8a670b28daa42e03d052dc0e5c0c90cc2f1ada4b01c2bc5f582c32acbe90d0fa636827cce553329dbf8b47b4728c14c68bbf93b6a7248bb606
data/lib/allpay/client.rb CHANGED
@@ -31,6 +31,11 @@ module Allpay
31
31
  Digest::MD5.hexdigest(url_encoded).upcase!
32
32
  end
33
33
 
34
+ def verify_mac params = {}
35
+ check_mac_value = params.delete(:CheckMacValue)
36
+ make_mac(params) == check_mac_value
37
+ end
38
+
34
39
  def request path, params = {}
35
40
  params[:MerchantID] = @merchant_id
36
41
  params[:CheckMacValue] = make_mac(params)
@@ -1,3 +1,3 @@
1
1
  module Allpay
2
- VERSION = "1.0.4"
2
+ VERSION = "1.0.5"
3
3
  end
data/spec/allpay_spec.rb CHANGED
@@ -54,4 +54,20 @@ describe Allpay::Client do
54
54
  })
55
55
  expect(mac).to eq '40D9A6C00A4A78A300ED458237071BDA'
56
56
  end
57
+
58
+ it '#verify_mac' do
59
+ result = @client.verify_mac RtnCode: '1',
60
+ PaymentType: 'Credit_CreditCard',
61
+ TradeAmt: '700',
62
+ PaymentTypeChargeFee: '14',
63
+ PaymentDate: '2015/02/07 14:21:00',
64
+ SimulatePaid: '0',
65
+ CheckMacValue: '3AF270CCCFA58CA0349F4FD462E21643',
66
+ TradeDate: '2015/02/07 14:20:47',
67
+ MerchantID: '2000132',
68
+ TradeNo: '1502071420478656',
69
+ RtnMsg: '交易成功',
70
+ MerchantTradeNo: '355313'
71
+ expect(result).to eq true
72
+ end
57
73
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: allpay_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jian Weihang
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-06 00:00:00.000000000 Z
11
+ date: 2015-02-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler