aurfy 0.1.0 → 0.1.1
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 +4 -4
- data/.travis.yml +7 -0
- data/Gemfile +4 -1
- data/README.md +10 -1
- data/lib/aurfy/client.rb +6 -6
- data/lib/aurfy/configure.rb +4 -5
- data/lib/aurfy/parser.rb +1 -1
- data/lib/aurfy/response.rb +2 -2
- data/lib/aurfy/version.rb +1 -1
- data/spec/aurfy/client_spec.rb +18 -0
- data/spec/spec_helper.rb +3 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cdf97785085e8e57fe1637e2397ebfcdd9ed2dae
|
4
|
+
data.tar.gz: 5f14266cd1992ec98e279839e27a29921c575826
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 16c239e41a1e87763c7d0d73bc163f44e2c3a502dab5ceb27731898d6796cae8eb8e0901e31d9c3bfdbf9f7d408395563211255a6fc7b06f0758ec9f6e1d6b45
|
7
|
+
data.tar.gz: 451e505339b82c154f1dfbe3f26142c245d710bb5a88164afb5b2525efb43a4612a23b99d8dc4c6cbe68e33bf1ec8c0ba0e9c9869665fd6de221a2cce7df97d1
|
data/.travis.yml
ADDED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# aurfy
|
2
2
|
|
3
|
+
[](https://travis-ci.org/camelmasa/aurfy)
|
4
|
+
[](https://codeclimate.com/github/camelmasa/aurfy)
|
5
|
+
[](https://codeclimate.com/github/camelmasa/aurfy)
|
6
|
+
|
3
7
|
Ruby client for [Aurfy](http://www.aurfy.com/)
|
4
8
|
|
5
9
|
Instration
|
@@ -21,7 +25,12 @@ Usage
|
|
21
25
|
-----
|
22
26
|
|
23
27
|
```rb
|
24
|
-
|
28
|
+
require "aurfy"
|
29
|
+
|
30
|
+
merchant_id = "M000000000"
|
31
|
+
trade_certificate = "D0123456789012345678901234567890"
|
32
|
+
|
33
|
+
client = Aurfy::Client.new(merchant_id, trade_certificate)
|
25
34
|
|
26
35
|
client.request(
|
27
36
|
cardnumber: "0123456789012345",
|
data/lib/aurfy/client.rb
CHANGED
@@ -2,22 +2,22 @@ module Aurfy
|
|
2
2
|
API_URL = "https://pgw.aurfy.com/v2/api/purchase/express"
|
3
3
|
TEST_API_URL = "http://test-pgw.comconnpay.com/v2/api/purchase/express"
|
4
4
|
|
5
|
-
attr_reader :api_url
|
6
|
-
|
7
5
|
class Client
|
6
|
+
attr_reader :api_url, :merchantid, :trade_certificate
|
7
|
+
|
8
8
|
def initialize(merchantid, trade_certificate, test = false)
|
9
|
-
@api_url = test ?
|
9
|
+
@api_url = test ? TEST_API_URL : API_URL
|
10
|
+
@merchantid = merchantid
|
11
|
+
@trade_certificate = trade_certificate
|
10
12
|
end
|
11
13
|
|
12
14
|
def request(options = {})
|
13
|
-
configure.options = options
|
15
|
+
configure.options = options.merge(merchantid: merchantid, trade_certificate: trade_certificate)
|
14
16
|
|
15
17
|
result = Faraday.post @api_url, configure.params
|
16
18
|
Response.new(result)
|
17
19
|
end
|
18
20
|
|
19
|
-
private
|
20
|
-
|
21
21
|
def configure
|
22
22
|
@configure ||= Configure.new
|
23
23
|
end
|
data/lib/aurfy/configure.rb
CHANGED
@@ -9,10 +9,10 @@ module Aurfy
|
|
9
9
|
def initialize
|
10
10
|
@cardtype = "UP"
|
11
11
|
@charset = "UTF-8"
|
12
|
-
@ordertime = DateTime.now.strftime("%Y%m%d%H%M%S")
|
13
|
-
@orderid = DateTime.now.strftime("%Y%m%d%H%M%S%N")
|
14
12
|
@ordercurrency = "USD"
|
15
13
|
@orderdescription = ""
|
14
|
+
@orderid = DateTime.now.strftime("%Y%m%d%H%M%S%N")
|
15
|
+
@ordertime = DateTime.now.strftime("%Y%m%d%H%M%S")
|
16
16
|
@signmethod = "MD5"
|
17
17
|
@transtype = "PURCHASE"
|
18
18
|
@txnremark1 = ""
|
@@ -34,9 +34,8 @@ module Aurfy
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def sorted_variables
|
37
|
-
instance_variables.map { |v| [v.to_s.sub("@", "").to_sym, instance_variable_get(v)] }
|
38
|
-
|
39
|
-
end.sort.to_h
|
37
|
+
variables = instance_variables.map { |v| [v.to_s.sub("@", "").to_sym, instance_variable_get(v)] }
|
38
|
+
Hash[variables.delete_if { |k, _| k == :trade_certificate }.sort]
|
40
39
|
end
|
41
40
|
|
42
41
|
def signature_key
|
data/lib/aurfy/parser.rb
CHANGED
@@ -9,7 +9,7 @@ module Aurfy
|
|
9
9
|
def parse
|
10
10
|
params = body.split("&").map { |p| p.split("=") }
|
11
11
|
params = params.map { |p| p.length >= 2 ? p : p.push("") }
|
12
|
-
params.
|
12
|
+
Hash[params].each_with_object({}) { |(k, v), a| a[k.to_s.to_sym] = v }
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
data/lib/aurfy/response.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Aurfy
|
2
2
|
class Response
|
3
|
-
attr_reader :result, :merchantid, :orderamount, :ordercurrency, :orderid, :ordertime, :respcode, :respmsg,
|
4
|
-
|
3
|
+
attr_reader :result, :merchantid, :orderamount, :ordercurrency, :orderid, :ordertime, :respcode, :respmsg,
|
4
|
+
:signature, :signmethod, :txnid, :txnremark1, :txnremark2, :txnstatus, :txntime
|
5
5
|
|
6
6
|
def self.keys
|
7
7
|
[:merchantid, :orderamount, :ordercurrency, :orderid, :ordertime, :respcode, :respmsg, :signature, :signmethod,
|
data/lib/aurfy/version.rb
CHANGED
data/spec/aurfy/client_spec.rb
CHANGED
@@ -3,6 +3,24 @@ require 'spec_helper'
|
|
3
3
|
describe Aurfy::Client do
|
4
4
|
subject { described_class.new("merchant_id", "trade_certificate") }
|
5
5
|
|
6
|
+
describe "#initialize" do
|
7
|
+
it "assigns parameters for payment" do
|
8
|
+
expect(subject.merchantid).to eq "merchant_id"
|
9
|
+
expect(subject.trade_certificate).to eq "trade_certificate"
|
10
|
+
expect(subject.api_url).to eq Aurfy::API_URL
|
11
|
+
end
|
12
|
+
|
13
|
+
context "with test argumaent" do
|
14
|
+
subject { described_class.new("merchant_id", "trade_certificate", true) }
|
15
|
+
|
16
|
+
it "assigns parameters for payment" do
|
17
|
+
expect(subject.merchantid).to eq "merchant_id"
|
18
|
+
expect(subject.trade_certificate).to eq "trade_certificate"
|
19
|
+
expect(subject.api_url).to eq Aurfy::TEST_API_URL
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
6
24
|
describe "#request" do
|
7
25
|
context "with valid credit card" do
|
8
26
|
it "returns successful Aurfy::Response instance" do
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aurfy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masahiro Saito
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-05-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -67,6 +67,7 @@ extra_rdoc_files: []
|
|
67
67
|
files:
|
68
68
|
- ".gitignore"
|
69
69
|
- ".rspec"
|
70
|
+
- ".travis.yml"
|
70
71
|
- Gemfile
|
71
72
|
- README.md
|
72
73
|
- aurfy.gemspec
|