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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 807c908b4b165b45e3c4c8aefede47feeb33f9ab
4
- data.tar.gz: 0d30726a6980abf6501298c864205bab91a04ac1
3
+ metadata.gz: cdf97785085e8e57fe1637e2397ebfcdd9ed2dae
4
+ data.tar.gz: 5f14266cd1992ec98e279839e27a29921c575826
5
5
  SHA512:
6
- metadata.gz: 2c55f2e3f6fea97418c7b1116badfef9599acb9847e7aa8e5736e41509597cfb7be4caf083c3f48122a158fef9d78b6603de216db2b9c045a8e10846285bcf6c
7
- data.tar.gz: f6d30dec227ea60d20bc07fafc389c7bf120c9605d12d0a5045bf0c2d858665943cf01f16986823d47e4bb910a6f6feb3d415ea80fa7badcacee13722fbec57f
6
+ metadata.gz: 16c239e41a1e87763c7d0d73bc163f44e2c3a502dab5ceb27731898d6796cae8eb8e0901e31d9c3bfdbf9f7d408395563211255a6fc7b06f0758ec9f6e1d6b45
7
+ data.tar.gz: 451e505339b82c154f1dfbe3f26142c245d710bb5a88164afb5b2525efb43a4612a23b99d8dc4c6cbe68e33bf1ec8c0ba0e9c9869665fd6de221a2cce7df97d1
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
5
+ - 2.1.0
6
+ - 2.2.0
7
+ script: bundle exec rspec
data/Gemfile CHANGED
@@ -1,5 +1,8 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'simplecov', require: false, group: :test
3
+ group :test do
4
+ gem 'simplecov', require: false
5
+ gem "codeclimate-test-reporter", require: nil
6
+ end
4
7
 
5
8
  gemspec
data/README.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # aurfy
2
2
 
3
+ [![Build Status](https://travis-ci.org/camelmasa/aurfy.png)](https://travis-ci.org/camelmasa/aurfy)
4
+ [![Code Climate](https://codeclimate.com/github/camelmasa/aurfy/badges/gpa.svg)](https://codeclimate.com/github/camelmasa/aurfy)
5
+ [![Test Coverage](https://codeclimate.com/github/camelmasa/aurfy/badges/coverage.svg)](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
- client = Aurfy::Client.new("M000000000", "D0123456789012345678901234567890")
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 ? API_URL : TEST_API_URL
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
@@ -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)] }.delete_if do
38
- |k, _| k == :trade_certificate
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.to_h.each_with_object({}) { |(k, v), a| a[k.to_s.to_sym] = v }
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
@@ -1,7 +1,7 @@
1
1
  module Aurfy
2
2
  class Response
3
- attr_reader :result, :merchantid, :orderamount, :ordercurrency, :orderid, :ordertime, :respcode, :respmsg, :signature, :signmethod,
4
- :txnid, :txnremark1, :txnremark2, :txnstatus, :txntime
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
@@ -1,6 +1,6 @@
1
1
  module Aurfy
2
2
  MAJOR = 0
3
3
  MINOR = 1
4
- PATCH = 0
4
+ PATCH = 1
5
5
  VERSION = [MAJOR, MINOR, PATCH].join('.').freeze
6
6
  end
@@ -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
@@ -1,5 +1,8 @@
1
1
  $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
2
 
3
+ require "codeclimate-test-reporter"
4
+ CodeClimate::TestReporter.start
5
+
3
6
  require 'simplecov'
4
7
  SimpleCov.start do
5
8
  add_filter "spec"
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.0
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-04-30 00:00:00.000000000 Z
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