alipay_global 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 277cdcc60f0660b3047710c99eee24fea1b81ca4
4
+ data.tar.gz: d7e43f4ffa4e124f2c4c4dbc7c1819be4133506d
5
+ SHA512:
6
+ metadata.gz: bfdb330a01eb4220f22242d2e6d6842cad17afe8a0298e2777f0f7ad00a7d68cc85109773117a268132b740788d62910df953d52a5f660126f8ba1351c67bab3
7
+ data.tar.gz: 6e6d3adfd70c7888b5289c15237199ca55bb21d6e58979ed9329158f2a1bf1badf42dbc2c0d2f4dd219b99ff5103561c6c99933325f73602b91d01ba18681c06
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Gem dependencies in alipay_global.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Melvrick
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
data/README.md ADDED
@@ -0,0 +1,250 @@
1
+ # alipay-global
2
+ Unofficial gem for linking up to global.alipay for remote payment
3
+
4
+ Development of this gem is largely influenced by the [unofficial alipay gem](https://github.com/chloerei/alipay). Code structure has been replicated from here in some areas.
5
+
6
+ You can find the docs for global.alipay's Cross Border Payment service [here](http://global.alipay.com/product/mobilepayments.htm)
7
+
8
+ ## Configuration
9
+
10
+ If you're using MD5, the api_secret_key needs to be initialized. If RSA is used, the private_key_location needs to be initialized. DSA is currently not supported.
11
+
12
+ ```ruby
13
+ AlipayGlobal.api_partner_id = 'YOUR_PID'
14
+ AlipayGlobal.api_secret_key = 'YOUR_KEY'
15
+
16
+ #AlipayGlobal.private_key_location = 'YOUR PRIVATE KEY LOCATION' #Your .pem file location
17
+
18
+ #AlipayGlobal.sign_type = 'MD5' # Available values: MD5, RSA. Default is MD5
19
+ #AlipayGlobal.debug_mode = true # Enable parameter check. Default is true.
20
+ ```
21
+
22
+ ## Warning
23
+
24
+ ### Still in testing phase. Gem is not yet ready for production use and is prone to failures/ bugs. Use at your own peril. Full functionality hasn't been achieved yet too
25
+
26
+ ## Usage
27
+
28
+ ### Service
29
+
30
+ #### Service::Trade
31
+
32
+ ```ruby
33
+ create
34
+ ```
35
+
36
+ #### Definition
37
+
38
+ ```ruby
39
+ AlipayGlobal::Service::Trade.create({ARGUMENTS})
40
+ ```
41
+
42
+ #### Issues (awaiting resolution)
43
+
44
+ 1. create_forex_trade
45
+ 1. rmb_fee issues with MD5 Signature (awaiting Alipay tech response)
46
+ 2. RSA integration: User needs to work with Alipay team to exchange RSA public keys to properly test the content
47
+ 2. testing environment
48
+ 1. Alipay mobile site for testing is down. works in production.
49
+
50
+ #### Example
51
+
52
+ ```ruby
53
+ AlipayGlobal::Service::Trade.create(
54
+ out_trade_no: '20150401000-0001',
55
+ subject: 'Subject',
56
+ currency: 'USD',
57
+ total_fee: '10.00',
58
+ notify_url: 'https://example.com/orders/20150401000-0001/notify'
59
+ )
60
+ # => 'https://mapi.alipay.com/gateway.do?service=create_forex_trade...' #for production
61
+ ```
62
+
63
+ #### ARGUMENTS
64
+
65
+ | Key | Requirement | Data Type | Description |
66
+ | --- | ----------- | --------- | ----------- |
67
+ | mobile | optional **(unique to this gem)** | boolean | true/false boolean value. Tells the gem whether you want to direct the user to Alipay's mobile friendly site |
68
+ | out_trade_no | required | string | Order number in your application. (Unique inside the partner system) |
69
+ | subject | required | string | The name of the goods. Cannot contain special symbols |
70
+ | currency | required | string | The settlement currency merchant named in contract. Refer to abbreviation of currencies |
71
+ | total_fee | required * | float | A floating number ranging 0.01~1000000.00 If use the rmb_fee, don’t use the total_fee |
72
+ | notify_url | required | string | The URL for receiving notifications after the payment process |
73
+ | rmb_fee | optional | float | 0.01~1000000.00 Use this parameter to replace total_fee if partner wish to price their product in RMB. If use the total_fee, don’t use the rmb_fee. |
74
+ | return_url | optional | string | After the payment transaction is done, the result is returned via the URL (only suitable for interfaces with directly returned results). |
75
+ | body | optional | string | A detailed description of the goods. Cannot contain special symbols |
76
+ | order_gmt_create | optional | string | YYYY-MM-DD HH:MM:SS please use China local time in order to sync with Alipay sustem, this parameter can only be used with order_valid_time together in order to control the valid time from redirect to login |
77
+ | order_valid_time | optional | string | Maximum is 21600,unit is second,this parameter can only be used with order_gmt_create together in order to control the valid time from redirection to login |
78
+ | timeout_rule | optional | string | Options: 5m 10m 15m 30m 1h 2h 3h 5h 10h 12h. default is 12h. this parameter control the valid time from login to completion, please contact Alipay technical service if you want to enable this param |
79
+ | auth_token | optional | string | The secure token from accessing express login API Mandatory for express login |
80
+ | supplier | optional | string | seller name shown in the cashier |
81
+ | seller_id | optional* | string | For PSG only The unique ID for PSG to identify a sub-merchant. |
82
+ | seller_name | optional* | string | For PSG only. The name of sub-merchant who initiate the request. |
83
+ | seller_industry | optional* | string | For PSG only The industry type of sub-merchant who initiate the request. |
84
+
85
+ \* Normal Mechant: optional. FOR PSG: compulsory
86
+
87
+ \*\*\* Attention1:In the case a merchant wish to price their products in RMB, the merchant shall not change the value of the currency parameter, instead he shall just replace the total_fee with rmb_fee, and then his trade will appears in RMB in front of user.
88
+
89
+ \*\*\* Attention2:The request parameters can only be accepted by the Alipay system if they are signed according to the signature mechanism specified in this document.The parameter “timeout_rule”, the default value is 12h. If you want to use this parameter to change timing, you need to contact Alipay technical. Otherwise you will have an error.
90
+
91
+
92
+ #### Service::Exchange
93
+
94
+ ```ruby
95
+ current_rates
96
+ ```
97
+
98
+ #### Definition
99
+
100
+ ```ruby
101
+ AlipayGlobal::Service::Exchange.current_rates()
102
+ ```
103
+
104
+ #### Example
105
+
106
+ ```ruby
107
+ AlipayGlobal::Service::Exchange.current_rates()
108
+
109
+ # Results: hash with following content
110
+ # => {"AUD"=>{:time=>#<DateTime: 2012-03-30T11:25:37+00:00 ((2456017j,41137s,0n),+0s,2299161j)>, :rate=>6.4485}, "CAD"=>{:time=>#<DateTime: 2012-03-30T11:25:37+00:00 ((2456017j,41137s,0n),+0s,2299161j)>, :rate=>6.6682}, "CHF"=>{:time=>#<DateTime: 2012-04-24T11:25:37+00:00 ((2456042j,41137s,0n),+0s,2299161j)>, :rate=>6.829}, "DKK"=>{:time=>#<DateTime: 2012-04-24T11:25:37+00:00 ((2456042j,41137s,0n),+0s,2299161j)>, :rate=>2.0}, "EUR"=>{:time=>#<DateTime: 2012-04-24T11:25:37+00:00 ((2456042j,41137s,0n),+0s,2299161j)>, :rate=>8.3364}, "GBP"=>{:time=>#<DateTime: 2013-07-01T11:06:35+00:00 ((2456475j,39995s,0n),+0s,2299161j)>, :rate=>10.6744}, "HKD"=>{:time=>#<DateTime: 2012-02-27T12:55:00+00:00 ((2455985j,46500s,0n),+0s,2299161j)>, :rate=>0.8145}, "JPY"=>{:time=>#<DateTime: 2012-12-24T17:43:59+00:00 ((2456286j,63839s,0n),+0s,2299161j)>, :rate=>0.05638}, "KRW"=>{:time=>#<DateTime: 2012-10-18T14:07:10+00:00 ((2456219j,50830s,0n),+0s,2299161j)>, :rate=>0.001111}, "SEK"=>{:time=>#<DateTime: 2012-02-27T12:55:00+00:00 ((2455985j,46500s,0n),+0s,2299161j)>, :rate=>0.9375}, "SGD"=>{:time=>#<DateTime: 2012-02-27T12:55:00+00:00 ((2455985j,46500s,0n),+0s,2299161j)>, :rate=>4.938}, "USD"=>{:time=>#<DateTime: 2013-11-22T11:25:37+00:00 ((2456619j,41137s,0n),+0s,2299161j)>, :rate=>6.5487}}
111
+ ```
112
+
113
+ #### Results
114
+
115
+ Hash contains objects representing each currency. Each object is represented by it's named currency code.
116
+
117
+ | Attribute | Data Type | Description |
118
+ | --------- | --------- | ----------- |
119
+ | time | DateTime | When Alipay retrieved the date and time of this currency rate |
120
+ | rate | float | Rate for 1 FOREX Unit : Units of RMB/CNY |
121
+
122
+
123
+ #### Service::Notification
124
+
125
+ It is necessary for the partner system to verify the integrity and correctness of Alipay’snotification. Intheinterestofsystem’shealthiness,itisstrongly recommended that the partner system apply such verification mechanism.
126
+
127
+ In order to guarantee the interface will be used legally, the partner system can only verify the notifications within the last 1 minute (this configuration is subject to change, and such change will not be notified).
128
+
129
+ ```ruby
130
+ check
131
+ ```
132
+
133
+ #### Definition
134
+
135
+ ```ruby
136
+ AlipayGlobal::Service::Notification.check({
137
+ notify_id: 'your_notification_id_received'
138
+ })
139
+ ```
140
+
141
+ #### Example
142
+
143
+ ```ruby
144
+ AlipayGlobal::Service::Notification.check({
145
+ notify_id: 'your_notification_id_received'
146
+ })
147
+
148
+ # Results: Alipay will respond with whether this notification is valid or not?
149
+ # => "false"
150
+ ```
151
+
152
+ #### Parameters
153
+
154
+ | Key | Requirement | Description |
155
+ | --- | ----------- | ----------- |
156
+ | notify_id | required | The ID of Alipay system’s notification. |
157
+
158
+ \* Provided: provisioned by setting these environment variables from the start
159
+
160
+ #### Results
161
+
162
+ Notification verification output result list:
163
+
164
+ | Result | Description |
165
+ | ------ | ----------- |
166
+ | invalid | The input parameter is invalid. |
167
+ | true | Authentication passed. |
168
+ | false | Authentication failed. |
169
+
170
+ #### Service::Reconciliation
171
+
172
+ After certain period of time, the oversea merchant partner needs to verify the past transaction details in order to make sure the correctness and integrity of transaction records. This can be performed by using the reconciliation file downloading interface. The starting and end dates should be provided within a 10-day interval. Same-day transaction details cannot be accessed by this interface.
173
+
174
+ ```ruby
175
+ check
176
+ ```
177
+
178
+ #### Definition
179
+
180
+ ```ruby
181
+ AlipayGlobal::Service::Reconciliation.request({
182
+ 'start_date'=> '20120202',
183
+ 'end_date'=> '20120205'
184
+ })
185
+ ```
186
+
187
+ #### Parameters
188
+
189
+ | Key | Requirement | Description |
190
+ | --- | ----------- | ----------- |
191
+ | start_date | required | The start date of the reconciliation period, formatted as YYYYMMDD |
192
+ | end_date | required | The end date of the reconciliation period, formatted as YYYYMMDD |
193
+
194
+ #### Example
195
+
196
+ ```ruby
197
+ AlipayGlobal::Service::Reconciliation.request({
198
+ 'start_date'=> '20120202',
199
+ 'end_date'=> '20120205'
200
+ })
201
+
202
+ # Results: Alipay will respond with either the file's array of results, false, or throw an ArgumentError?
203
+ # => "false"
204
+ ```
205
+
206
+
207
+
208
+ #### Results
209
+
210
+ **Failure Case 1** : No transactions found
211
+ ```ruby
212
+ AlipayGlobal::Service::Reconciliation.request(params)
213
+
214
+ # Results: If no transaction records found
215
+ # => "false"
216
+ ```
217
+
218
+ **Failure Case 2** : Errors in arguments
219
+ Argument Error with the following messages will be thrown
220
+
221
+ | Error Message | Description |
222
+ | ------------- | ----------- |
223
+ | File download failed:Over 10 days to Date period | The supplied date range exceeds 10 days |
224
+ | <?xml version=\"1.0\" encoding=\"GBK\"?>\n<alipay><is_success>F</is_success><error>ILLEGAL_PARTNER</error></alipay> | Partner id that is set does not exist in Alipay's system/ or isn't active in the production/testing environment yet |
225
+ | File download failed:Finish date ahead of begin date | Invalid date types supplied |
226
+ | File download failed:Illegal Date period! | No date/ Invalid date data |
227
+ | File download failed:Finish date not ahead of today | Dates supplied for reconciliations should be before current date (Alipay's probably) |
228
+
229
+ **Untested Cases**
230
+ The following cases have yet to be tested
231
+
232
+ | Errors | Description |
233
+ | ------ | ----------- |
234
+ | Date format incorrect YYYYMMDD | Unable to recreate scenario |
235
+ | System exception | |
236
+ | Internet connected exception ,please try later | |
237
+
238
+ **Success Case** : Array containing the results of transactions in these periods.
239
+
240
+ ```ruby
241
+ AlipayGlobal::Service::Reconciliation.request(params)
242
+
243
+ # Results: If no transaction records found
244
+ # => [
245
+ {:partner_transaction_id=>"20131219-144657-234", :amount=>"0.11", :currency=>"EUR", :transaction_time=>#<DateTime: 2013-12-19T21:52:28+00:00 ((2456646j,78748s,0n),+0s,2299161j)>, :settlement_time=>"", :transaction_type=>"P", :service_charge=>"0.00", :status=>"P", :remarks=>"Test"},
246
+ {:partner_transaction_id=>"1326557", :amount=>"2125.25", :currency=>"HKD", :transaction_time=>#<DateTime: 2013-12-19T17:58:40+00:00 ((2456646j,64720s,0n),+0s,2299161j)>, :settlement_time=>"", :transaction_type=>"P", :service_charge=>"21.25", :status=>"P", :remarks=>"Grey Hours Limited (Testing)"},
247
+ {:partner_transaction_id=>"1326555", :amount=>"2125.25", :currency=>"HKD", :transaction_time=>#<DateTime: 2013-12-19T17:56:37+00:00 ((2456646j,64597s,0n),+0s,2299161j)>, :settlement_time=>"", :transaction_type=>"P", :service_charge=>"21.25", :status=>"P", :remarks=>"Grey Hours Limited (Testing)"},
248
+ {:partner_transaction_id=>"1326244", :amount=>"0.01", :currency=>"HKD", :transaction_time=>#<DateTime: 2013-12-19T16:11:26+00:00 ((2456646j,58286s,0n),+0s,2299161j)>, :settlement_time=>"", :transaction_type=>"P", :service_charge=>"0.00", :status=>"P", :remarks=>"MICROS-Fidelio Information Systems Co. Limited (Testing)"}
249
+ ]
250
+ ```
data/Rakefile ADDED
@@ -0,0 +1,9 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new do |t|
5
+ t.libs << "test"
6
+ t.test_files = FileList['test/**/*_test.rb']
7
+ end
8
+
9
+ task :default => :test
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'alipay_global/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "alipay_global"
8
+ spec.version = AlipayGlobal::VERSION
9
+ spec.authors = ["Melvrick Goh, Ng Junyang, Grzegorz Witek"]
10
+ spec.email = ["melvrickgoh@kaligo.com"]
11
+ spec.description = %q{An unofficial simple global.alipay gem}
12
+ spec.summary = %q{An unofficial simple global.alipay gem}
13
+ spec.homepage = "https://github.com/Kaligo/alipay-global.git"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "minitest"
24
+ spec.add_development_dependency "rspec"
25
+ spec.add_development_dependency "fakeweb"
26
+ spec.add_development_dependency "nokogiri"
27
+ end
@@ -0,0 +1,6 @@
1
+ -----BEGIN PUBLIC KEY-----
2
+ MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCnxj/9qwVfgoUh/y2W89L6BkRA
3
+ FljhNhgPdyPuBV64bfQNN1PjbCzkIM6qRdKBoLPXmKKMiFYnkd6rAoprih3/PrQE
4
+ B/VsW8OoM8fxn67UDYuyBTqA23MML9q1+ilIZwBC2AQ2UBVOrFXfFl75p6/B5Ksi
5
+ NG9zpgmLCUYuLkxpLQIDAQAB
6
+ -----END PUBLIC KEY-----
@@ -0,0 +1,27 @@
1
+ -----BEGIN RSA PRIVATE KEY-----
2
+ MIIEpAIBAAKCAQEAxF1vOOysBibP9gquwCqjCigUBI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FBvW9pTbOCOM
8
+ IwIDAQAB
9
+ -----END PUBLIC KEY-----
@@ -0,0 +1,32 @@
1
+ require 'alipay_global/sign'
2
+ require 'alipay_global/sign/md5'
3
+ require 'alipay_global/sign/rsa'
4
+ require 'alipay_global/sign/dsa'
5
+
6
+ require 'alipay_global/utils'
7
+
8
+ require 'alipay_global/service'
9
+ require 'alipay_global/service/trade'
10
+ require 'alipay_global/service/exchange'
11
+ require 'alipay_global/service/notification'
12
+ require 'alipay_global/service/reconciliation'
13
+
14
+ module AlipayGlobal
15
+
16
+ @debug_mode = true
17
+ @sign_type = "MD5"
18
+ @environment = "TEST"
19
+
20
+ #default alipay test credentials
21
+ @api_partner_id = "2088101122136241"
22
+ @api_secret_key = "760bdzec6y9goq7ctyx96ezkz78287de"
23
+
24
+ class << self
25
+ attr_accessor :api_partner_id, :api_secret_key, :sign_type, :debug_mode, :private_key_location, :environment
26
+
27
+ def debug_mode?
28
+ !!@debug_mode
29
+ end
30
+
31
+ end
32
+ end
@@ -0,0 +1,35 @@
1
+ module AlipayGlobal
2
+ module Service
3
+ def self.gateway_url
4
+ AlipayGlobal.environment == "PRODUCTION" ? "https://mapi.alipay.com/gateway.do?" : "https://mapi.alipay.net/gateway.do?"
5
+ end
6
+
7
+ def self.request_uri(params, sign = true)
8
+ uri = URI(gateway_url)
9
+ processed_params = sign ? sign_params(params) : params
10
+ uri.query = URI.encode_www_form(processed_params)
11
+ uri
12
+ end
13
+
14
+ def self.sign_params(params)
15
+ params.merge(
16
+ 'sign_type' => AlipayGlobal.sign_type.upcase,
17
+ 'sign' => AlipayGlobal::Sign.generate(params)
18
+ )
19
+ end
20
+
21
+ def self.check_required_params(params, names)
22
+ return if !AlipayGlobal.debug_mode?
23
+
24
+ names.each do |name|
25
+ warn("AlipayGlobal Warn: missing required option: #{name}") unless params.has_key?(name)
26
+ end
27
+ end
28
+
29
+ def self.check_optional_params(params, names)
30
+ return if !AlipayGlobal.debug_mode?
31
+
32
+ warn("AlipayGlobal Warn: must specify either #{names.join(' or ')}") if names.all? {|name| params[name].nil? }
33
+ end
34
+ end
35
+ end