espago 0.1.2 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 27e99a50c2ebe74762fb3cfbb1d808dfc465fdb9
4
- data.tar.gz: dfeead9293c23e0c4f4d3a7ccc682d21ef327cb1
3
+ metadata.gz: 9c90725a6354df09346f5e47d7a47d89fc7af563
4
+ data.tar.gz: 65649ff9aac8ce18cd04d1623a11fa8c55a40e12
5
5
  SHA512:
6
- metadata.gz: 206a547e448d6cf77996f7d288d9ef563042f7521f6c8d6918dba776fbfdb19708a7939fb8ad51087879035bcbd6273e4f50120691c084f1193d9ed24d492592
7
- data.tar.gz: ac022203b3f4ede07c8ea8e2e7298e70e843456f7aedd7f5c86957c362de0914d234ca9e5996628eb35bddfb2479dbcc6bc9340ad635fe1990d2552a3df93570
6
+ metadata.gz: 518ef7b212cb3e789d4cd24bc992e8515bc01516d0ea5db5c1c97d3f75c43bdb89142220586aff3f92878a9d6508c51205071bcd8cff88e6d1fd1636d07cfaf0
7
+ data.tar.gz: 9da66c2cba20692a5821dd094c0cf30337767b9f3c7fdd17ee818a0e2a8864f3328ff6e7695e5a3ab45b81ac368f0d47c6ba52c0ed0a0def396dabd8cfb71d05
@@ -1,9 +1,8 @@
1
1
  language: ruby
2
2
  rvm:
3
- - "1.9.2"
4
- - "1.9.3"
5
- - "2.0.0"
6
- - "2.1.5"
3
+ - "2.1.10"
4
+ - "2.2.5"
5
+ - "2.3.1"
7
6
 
8
7
  addons:
9
8
  code_climate:
@@ -1,20 +1,51 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- espago (0.1.2)
4
+ espago (0.1.8)
5
5
  facets
6
6
  faraday
7
+ rails
7
8
 
8
9
  GEM
9
10
  remote: https://rubygems.org/
10
11
  specs:
12
+ actionmailer (3.2.22)
13
+ actionpack (= 3.2.22)
14
+ mail (~> 2.5.4)
15
+ actionpack (3.2.22)
16
+ activemodel (= 3.2.22)
17
+ activesupport (= 3.2.22)
18
+ builder (~> 3.0.0)
19
+ erubis (~> 2.7.0)
20
+ journey (~> 1.0.4)
21
+ rack (~> 1.4.5)
22
+ rack-cache (~> 1.2)
23
+ rack-test (~> 0.6.1)
24
+ sprockets (~> 2.2.1)
25
+ activemodel (3.2.22)
26
+ activesupport (= 3.2.22)
27
+ builder (~> 3.0.0)
28
+ activerecord (3.2.22)
29
+ activemodel (= 3.2.22)
30
+ activesupport (= 3.2.22)
31
+ arel (~> 3.0.2)
32
+ tzinfo (~> 0.3.29)
33
+ activeresource (3.2.22)
34
+ activemodel (= 3.2.22)
35
+ activesupport (= 3.2.22)
36
+ activesupport (3.2.22)
37
+ i18n (~> 0.6, >= 0.6.4)
38
+ multi_json (~> 1.0)
11
39
  addressable (2.3.6)
40
+ arel (3.0.3)
41
+ builder (3.0.4)
12
42
  codeclimate-test-reporter (0.4.1)
13
43
  simplecov (>= 0.7.1, < 1.0.0)
14
44
  coderay (1.0.8)
15
45
  crack (0.4.2)
16
46
  safe_yaml (~> 1.0.0)
17
47
  diff-lcs (1.1.3)
48
+ erubis (2.7.0)
18
49
  facets (2.9.3)
19
50
  faraday (0.8.7)
20
51
  multipart-post (~> 1.1)
@@ -30,17 +61,50 @@ GEM
30
61
  guard-rspec (2.3.3)
31
62
  guard (>= 1.1)
32
63
  rspec (~> 2.11)
64
+ hike (1.2.3)
65
+ i18n (0.7.0)
66
+ journey (1.0.4)
67
+ json (1.8.3)
33
68
  listen (0.7.2)
34
69
  lumberjack (1.0.2)
70
+ mail (2.5.4)
71
+ mime-types (~> 1.16)
72
+ treetop (~> 1.4.8)
35
73
  method_source (0.8.1)
74
+ mime-types (1.25.1)
36
75
  multi_json (1.5.0)
37
76
  multipart-post (1.2.0)
77
+ polyglot (0.3.5)
38
78
  pry (0.9.10)
39
79
  coderay (~> 1.0.5)
40
80
  method_source (~> 0.8)
41
81
  slop (~> 3.3.1)
82
+ rack (1.4.7)
83
+ rack-cache (1.2)
84
+ rack (>= 0.4)
85
+ rack-ssl (1.3.4)
86
+ rack
87
+ rack-test (0.6.3)
88
+ rack (>= 1.0)
89
+ rails (3.2.22)
90
+ actionmailer (= 3.2.22)
91
+ actionpack (= 3.2.22)
92
+ activerecord (= 3.2.22)
93
+ activeresource (= 3.2.22)
94
+ activesupport (= 3.2.22)
95
+ bundler (~> 1.0)
96
+ railties (= 3.2.22)
97
+ railties (3.2.22)
98
+ actionpack (= 3.2.22)
99
+ activesupport (= 3.2.22)
100
+ rack-ssl (~> 1.3.2)
101
+ rake (>= 0.8.7)
102
+ rdoc (~> 3.4)
103
+ thor (>= 0.14.6, < 2.0)
42
104
  rake (10.0.2)
43
105
  rb-fsevent (0.9.3)
106
+ rdoc (3.12.2)
107
+ json (~> 1.4)
44
108
  rspec (2.12.0)
45
109
  rspec-core (~> 2.12.0)
46
110
  rspec-expectations (~> 2.12.0)
@@ -57,7 +121,17 @@ GEM
57
121
  simplecov-html (~> 0.7.1)
58
122
  simplecov-html (0.7.1)
59
123
  slop (3.3.3)
124
+ sprockets (2.2.3)
125
+ hike (~> 1.2)
126
+ multi_json (~> 1.0)
127
+ rack (~> 1.0)
128
+ tilt (~> 1.1, != 1.3.0)
60
129
  thor (0.16.0)
130
+ tilt (1.4.1)
131
+ treetop (1.4.15)
132
+ polyglot
133
+ polyglot (>= 0.3.1)
134
+ tzinfo (0.3.44)
61
135
  vcr (2.9.3)
62
136
  webmock (1.20.4)
63
137
  addressable (>= 2.3.6)
@@ -0,0 +1,13 @@
1
+ module Espago::MasterpassHelper
2
+ def espago_masterpass_button(data)
3
+ render :partial => 'espago_masterpass/masterpass_button', :locals => { :data => Espago::Masterpass.prepare_form(data)}
4
+ end
5
+
6
+ def espago_masterpass_pairing_button(data)
7
+ render :partial => 'espago_masterpass/masterpass_pairing_button', :locals => { :data => Espago::Masterpass.prepare_pairing_form(data)}
8
+ end
9
+
10
+ def espago_masterpass_precheckout_button(data)
11
+ render :partial => 'espago_masterpass/masterpass_precheckout_button', :locals => { :data => Espago::Masterpass.prepare_precheckout_form(data)}
12
+ end
13
+ end
@@ -0,0 +1,5 @@
1
+ module Espago::SecureWebPageHelper
2
+ def espago_secure_web_page_form(data)
3
+ render :partial => 'espago_secure_web_page/form', :locals => { :data => Espago::SecureWebPage.prepare_form(data)}
4
+ end
5
+ end
@@ -0,0 +1,20 @@
1
+ = form_tag '',authenticity_token: false, id: :masterpass_espago_form do
2
+ = hidden_field_tag 'masterpass_action', data[:masterpass_action]
3
+ = hidden_field_tag 'app_id', data[:app_id]
4
+ = hidden_field_tag 'session_id', data[:session_id]
5
+ = hidden_field_tag 'amount', data[:amount]
6
+ = hidden_field_tag 'currency', data[:currency]
7
+ = hidden_field_tag 'description', data[:description]
8
+ = hidden_field_tag 'api_version', data[:api_version]
9
+ = hidden_field_tag 'checksum', data[:checksum]
10
+ - data[:shopping_cart_items].each_with_index do |shopping_cart_item,index|
11
+ = hidden_field_tag "shopping_cart_items[#{index}][description]", shopping_cart_item[:description]
12
+ = hidden_field_tag "shopping_cart_items[#{index}][quantity]", shopping_cart_item[:quantity]
13
+ = hidden_field_tag "shopping_cart_items[#{index}][value]", shopping_cart_item[:value]
14
+ = hidden_field_tag "shopping_cart_items[#{index}][image_url]", shopping_cart_item[:image_url]
15
+
16
+ .button
17
+ = button_tag( t("activerecord.models.espago.masterpass.buy"), style:'float:left')
18
+ #espagoloading{style:"display:none;float:left"}
19
+ %img{src:'https://sandbox.masterpass.com/lightbox/version90/Switch/assets/img/spinner.gif', style:'margin-left:10px;width:30px'}
20
+
@@ -0,0 +1,11 @@
1
+ = form_tag '',authenticity_token: false, id: :masterpass_espago_form do
2
+ = hidden_field_tag 'masterpass_action', data[:masterpass_action]
3
+ = hidden_field_tag 'app_id', data[:app_id]
4
+ = hidden_field_tag 'session_id', data[:session_id]
5
+ = hidden_field_tag 'user_id', data[:user_id]
6
+ = hidden_field_tag 'api_version', data[:api_version]
7
+ = hidden_field_tag 'checksum', data[:checksum]
8
+ .button
9
+ = button_tag( t("activerecord.models.espago.masterpass.pairing"), style:'float:left')
10
+ #espagoloading{style:"display:none;float:left"}
11
+ %img{src:'https://sandbox.masterpass.com/lightbox/version90/Switch/assets/img/spinner.gif', style:'margin-left:10px;width:30px'}
@@ -0,0 +1,21 @@
1
+ = form_tag '',authenticity_token: false, id: :masterpass_espago_form do
2
+ = hidden_field_tag 'masterpass_action', data[:masterpass_action]
3
+ = hidden_field_tag 'client_id', data[:client_id]
4
+ = hidden_field_tag 'app_id', data[:app_id]
5
+ = hidden_field_tag 'session_id', data[:session_id]
6
+ = hidden_field_tag 'amount', data[:amount]
7
+ = hidden_field_tag 'currency', data[:currency]
8
+ = hidden_field_tag 'description', data[:description]
9
+ = hidden_field_tag 'api_version', data[:api_version]
10
+ = hidden_field_tag 'checksum', data[:checksum]
11
+ - data[:shopping_cart_items].each_with_index do |shopping_cart_item,index|
12
+ = hidden_field_tag "shopping_cart_items[#{index}][description]", shopping_cart_item[:description]
13
+ = hidden_field_tag "shopping_cart_items[#{index}][quantity]", shopping_cart_item[:quantity]
14
+ = hidden_field_tag "shopping_cart_items[#{index}][value]", shopping_cart_item[:value]
15
+ = hidden_field_tag "shopping_cart_items[#{index}][image_url]", shopping_cart_item[:image_url]
16
+
17
+ / .button
18
+ / = button_tag( t("activerecord.models.espago.masterpass.buy"), style:'float:left')
19
+ #espagoloading{style:"display:none;float:left"}
20
+ %img{src:'https://sandbox.masterpass.com/lightbox/version90/Switch/assets/img/spinner.gif', style:'margin-left:10px;width:30px'}
21
+
@@ -0,0 +1,25 @@
1
+ = form_tag Espago::SecureWebPage.form_post, authenticity_token: false, id: :espago_secure_web_page do
2
+ = hidden_field_tag 'api_version', data[:api_version]
3
+ = hidden_field_tag 'app_id', data[:app_id]
4
+ = hidden_field_tag 'kind', data[:kind]
5
+
6
+ = hidden_field_tag 'session_id', data[:session_id]
7
+ = hidden_field_tag 'amount', data[:amount]
8
+ = hidden_field_tag 'currency', data[:currency]
9
+ = hidden_field_tag 'title', data[:title]
10
+
11
+ = hidden_field_tag 'description', data[:description]
12
+ = hidden_field_tag 'email', data[:email]
13
+ = hidden_field_tag 'positive_url', data[:positive_url]
14
+ = hidden_field_tag 'negative_url', data[:negative_url]
15
+
16
+ = hidden_field_tag 'ts', data[:ts]
17
+ = hidden_field_tag 'checksum', data[:checksum]
18
+ - data[:shopping_cart_items].each_with_index do |shopping_cart_item,index|
19
+ = hidden_field_tag "shopping_cart_items[#{index}][description]", shopping_cart_item[:description]
20
+ = hidden_field_tag "shopping_cart_items[#{index}][quantity]", shopping_cart_item[:quantity]
21
+ = hidden_field_tag "shopping_cart_items[#{index}][value]", shopping_cart_item[:value]
22
+ = hidden_field_tag "shopping_cart_items[#{index}][image_url]", shopping_cart_item[:image_url]
23
+
24
+ .button
25
+ = button_tag( t("activerecord.models.espago.secure_web_page.buy"), style:'float:left')
@@ -19,6 +19,7 @@ Gem::Specification.new do |gem|
19
19
 
20
20
  gem.add_dependency "faraday"
21
21
  gem.add_dependency "facets"
22
+ gem.add_dependency "rails"
22
23
 
23
24
  gem.add_development_dependency "rspec"
24
25
  gem.add_development_dependency "pry"
@@ -2,6 +2,9 @@ require "espago/version"
2
2
  require "espago/client"
3
3
  require "espago/router"
4
4
  require "espago/back_request"
5
+ require "espago/masterpass"
6
+ require "espago/secure_web_page"
7
+ require "espago/engine"
5
8
  require 'forwardable'
6
9
 
7
10
  module Espago
@@ -9,8 +12,8 @@ module Espago
9
12
  class << self
10
13
  extend Forwardable
11
14
 
12
- def_delegators :default_client, :public_key, :app_id, :app_password, :api_version, :send_request, :production
13
- def_delegators :default_client, :public_key= , :app_id= , :app_password=, :api_version=, :production=
15
+ def_delegators :default_client, :public_key, :app_id, :app_password, :api_version, :send_request, :production, :checksum_key
16
+ def_delegators :default_client, :public_key= , :app_id= , :app_password=, :api_version=, :production=,:checksum_key=
14
17
 
15
18
  def method_missing(method, *args, &block)
16
19
  if Router.new(method, args[0]).path_exists?
@@ -20,6 +23,10 @@ module Espago
20
23
  end
21
24
  end
22
25
 
26
+ def self.setup
27
+ yield self
28
+ end
29
+
23
30
  private
24
31
  def default_client
25
32
  @default_client ||= Espago::Client.new
@@ -0,0 +1,9 @@
1
+ module Espago
2
+ class ApiConnection
3
+ class DccDecisionPost < Api
4
+ def request(params = {})
5
+ @connection.post "charges/#{params[:charge_id]}/dcc_decision", params
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module Espago
2
+ class ApiConnection
3
+ class MasterpassPost < ApiPost
4
+ def request(params = {})
5
+ super("masterpass", params)
6
+ end
7
+ end
8
+ end
9
+ end
@@ -3,18 +3,24 @@ require "espago/response"
3
3
 
4
4
  module Espago
5
5
  class Client
6
- attr_accessor :public_key, :app_id, :app_password, :api_version, :production
6
+ attr_accessor :public_key, :app_id, :app_password, :api_version, :production, :checksum_key
7
7
  NotAuthenticated = Class.new(StandardError)
8
8
 
9
9
  def initialize(options = {})
10
- @public_key, @app_id, @app_password, @api_version = options.values_at( :public_key, :app_id, :app_password, :api_version)
10
+ @public_key, @app_id, @app_password, @api_version, @checksum_key = options.values_at( :public_key, :app_id, :app_password, :api_version, :checksum_key)
11
11
  @connection = options[:connection] || ApiConnection
12
12
  end
13
13
 
14
14
  def send_request(path, method, params = {})
15
- raise NotAuthenticated unless valid?
16
- connection = @connection.new(enviroment,api_version_header)
17
- connection.authenticate(@app_id, @app_password)
15
+
16
+ app_id = params[:app_id].present? ? params.delete(:app_id) : @app_id
17
+ app_password = params[:app_password].present? ? params.delete(:app_password) : @app_password
18
+ production_param = !params[:production].nil? ? params.delete(:production) : production
19
+
20
+ raise NotAuthenticated unless valid?(app_id, app_password)
21
+
22
+ connection = @connection.new(enviroment(production_param),api_version_header)
23
+ connection.authenticate(app_id, app_password)
18
24
  connection.create(path, method, params)
19
25
  end
20
26
 
@@ -23,21 +29,21 @@ module Espago
23
29
  end
24
30
 
25
31
  private
26
- def enviroment
27
- production ? "https://secure.espago.com/api" : "https://sandbox.espago.com/api"
32
+ def enviroment(production_param)
33
+ # "http://127.0.0.1:3007/api"
34
+ production_param ? "https://secure.espago.com/api" : "https://sandbox.espago.com/api"
28
35
  end
29
36
 
30
37
  def api_version_header
31
- if @api_version.to_s == '3'
38
+ if @api_version.to_f.to_s == '3.0'
32
39
  {'Accept' => "application/vnd.espago.v3+json"}
33
40
  else
34
41
  {'Accept' => "application/vnd.espago.v2+json"}
35
42
  end
36
43
  end
37
44
 
38
-
39
- def valid?
40
- @app_id && @app_password
45
+ def valid?(app_id, app_password)
46
+ app_id && app_password
41
47
  end
42
48
  end
43
49
  end
@@ -0,0 +1,5 @@
1
+ require 'rails'
2
+ module Espago
3
+ class Engine < Rails::Engine
4
+ end
5
+ end
@@ -0,0 +1,52 @@
1
+ module Espago
2
+ class Masterpass
3
+ def self.friendly_token
4
+ SecureRandom.base64(15).tr('+/=lIO0', 'aqrsxyz')
5
+ end
6
+
7
+ def self.calculate(string)
8
+ Digest::MD5.hexdigest(string)
9
+ end
10
+
11
+ def self.calculate_checksum(app_id, session_id, amount, currency, checksum_key)
12
+ calculate [app_id.to_s, session_id.to_s, amount.to_s, currency.to_s, checksum_key.to_s].join('|')
13
+ end
14
+
15
+ def self.calculate_checksum_pairing(app_id, session_id, user_id, checksum_key)
16
+ calculate [app_id.to_s, session_id.to_s, user_id.to_s, checksum_key.to_s].join('|')
17
+ end
18
+
19
+ def self.masterpass_post(api_v=nil)
20
+ end
21
+
22
+ def self.make_currency(data_currency)
23
+ (data_currency || Espago.currency).upcase
24
+ end
25
+
26
+ def self.prepare_form(data)
27
+ data[:masterpass_action] ||= 'checkout'
28
+ data[:app_id] ||= Espago.app_id
29
+ data[:api_version] ||= Espago.api_version
30
+ data[:amount] = format('%.2f', data[:amount])
31
+ data[:checksum] = calculate_checksum(data[:app_id],data[:session_id],data[:amount],data[:currency],data[:checksum_key]|| Espago.checksum_key)
32
+ data
33
+ end
34
+
35
+ def self.prepare_pairing_form(data)
36
+ data[:masterpass_action] ||= 'pairing'
37
+ data[:app_id] ||= Espago.app_id
38
+ data[:api_version] ||= Espago.api_version
39
+ data[:checksum] = calculate_checksum_pairing(data[:app_id],data[:session_id],data[:user_id],data[:checksum_key]|| Espago.checksum_key)
40
+ data
41
+ end
42
+ def self.prepare_precheckout_form(data)
43
+ data[:masterpass_action] ||= 'precheckout'
44
+ data[:app_id] ||= Espago.app_id
45
+ data[:api_version] ||= Espago.api_version
46
+ data[:amount] = format('%.2f', data[:amount])
47
+ data[:checksum] = calculate_checksum(data[:app_id],data[:session_id],data[:amount],data[:currency],data[:checksum_key]|| Espago.checksum_key)
48
+ data
49
+ end
50
+
51
+ end
52
+ end
@@ -0,0 +1,28 @@
1
+ require "forwardable"
2
+ module Espago
3
+ class SecureWebPage
4
+ attr_accessor :production
5
+
6
+ def self.calculate_checksum(app_id, kind, session_id,amount,currency,ts,checksum_key)
7
+ Digest::MD5.hexdigest(
8
+ [app_id.to_s, kind, session_id.to_s, amount.to_s, currency.to_s, ts.to_s, checksum_key.to_s].join('|')
9
+ )
10
+ end
11
+
12
+ def self.form_post(api_v=nil)
13
+ Espago.production ? "https://secure.espago.com/secure_web_page" : "https://sandbox.espago.com/secure_web_page"
14
+ end
15
+
16
+ def self.prepare_form(data)
17
+ data[:kind] ||= 'sale'
18
+ data[:ts] ||= Time.now.to_i
19
+ data[:app_id] ||= Espago.app_id
20
+ data[:api_version] ||= Espago.api_version
21
+ data[:amount] = format('%.2f', data[:amount])
22
+ data[:checksum] = calculate_checksum(data[:app_id],data[:kind],data[:session_id],data[:amount],data[:currency],data[:ts],data[:checksum_key]|| Espago.checksum_key)
23
+ data
24
+ end
25
+
26
+
27
+ end
28
+ end
@@ -1,3 +1,3 @@
1
1
  module Espago
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.8"
3
3
  end
@@ -0,0 +1,20 @@
1
+ require 'securerandom'
2
+
3
+ module Espago
4
+ module Generators
5
+ class InstallGenerator < Rails::Generators::Base
6
+ source_root File.expand_path("../templates", __FILE__)
7
+
8
+ desc "Creates a Espago initializer"
9
+
10
+ def copy_initializer
11
+ template "espago.rb", "config/initializers/espago.rb"
12
+ end
13
+
14
+ def show_readme
15
+ readme "README" if behavior == :invoke
16
+ end
17
+
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,10 @@
1
+ ===============================================================================
2
+
3
+ You need to do some manual setup to get Espago working:
4
+
5
+ 1. Review settings in new config/initializers/espago.rb and update where
6
+ neccessary.
7
+
8
+ 2. Restart app
9
+
10
+ ===============================================================================
@@ -0,0 +1,6 @@
1
+ Espago.app_id = espago_app_id
2
+ Espago.app_password = espago_app_password
3
+ Espago.public_key = espago_public_key
4
+ Espago.production = espago_production
5
+ Espago.api_version = espago_api_version
6
+ Espago.checksum_key = espago_checksum_key
@@ -38,6 +38,18 @@ describe Espago::Client do
38
38
  end
39
39
  end
40
40
 
41
+ context "#send_request_with_app_id_and_password" do
42
+ subject { Espago::Client.new(connection: stubbed_api_connection, api_version: 2) }
43
+ let(:method) { :get }
44
+ let(:path) { :new_client }
45
+ let(:params) { { name: "Jan Kowalski", app_id: 'app_id_test', app_password: 'secret'} }
46
+
47
+ it "should create an api request" do
48
+ subject.send_request(path, method, params).should eq('returned api data')
49
+ end
50
+
51
+ end
52
+
41
53
  context "#parse_response" do
42
54
  subject { Espago::Client.new }
43
55
 
@@ -0,0 +1,89 @@
1
+
2
+ require "spec_helper"
3
+
4
+ describe 'Espago.charges_with_params' do
5
+
6
+ before :each do
7
+ Espago.app_id = ''
8
+ Espago.app_password = ''
9
+ Espago.public_key = ''
10
+ Espago.production = true
11
+ end
12
+
13
+ it "should get list of charges" do
14
+ VCR.use_cassette('charges get') do
15
+ response = Espago.charges :get,{app_id: 'app_id_test', app_password: 'app_password_test', production: false}
16
+ response.count.should eq(589)
17
+ end
18
+ end
19
+
20
+ it "should get info abount charges" do
21
+ VCR.use_cassette('charges get pay_mTOngouLTJWZ0w') do
22
+ response = Espago.charges :get,{charge_id:'pay_mTOngouLTJWZ0w', app_id: 'app_id_test', app_password: 'app_password_test', production: false}
23
+ response.status.should eq(200)
24
+ response.channel.should eq('elavon')
25
+ response.state.should eq('executed')
26
+ response.currency.should eq('PLN')
27
+ response.description.should eq('Test12345')
28
+ response.client.should eq('cli_YM5tKz6-IfhN7T')
29
+ response.created_at.should eq Time.at(1416917311)
30
+ end
31
+ end
32
+
33
+ it "should get params from new charge" do
34
+ VCR.use_cassette('charges post') do
35
+ response = Espago.charges :post, {
36
+ app_id: 'app_id_test',
37
+ app_password: 'app_password_test',
38
+ production: false,
39
+ amount:'49.99',
40
+ currency:'PLN',
41
+ description:'Test12345',
42
+ card: {
43
+ first_name: 'Jan',
44
+ last_name: 'Kowalski',
45
+ number: '4242424242424242',
46
+ verification_value: '123',
47
+ year:'2015',
48
+ month:'2'
49
+ },
50
+ }
51
+ response.status.should eq(201)
52
+ response.channel.should eq('elavon')
53
+ response.state.should eq('executed')
54
+ response.currency.should eq('PLN')
55
+ response.description.should eq('Test12345')
56
+ response.client.should eq('cli_YM5tKz6-IfhN7T')
57
+ response.created_at.should eq Time.at(1416917311)
58
+ end
59
+ end
60
+
61
+ it "should get 204 status after destroy charge" do
62
+ VCR.use_cassette('charges destroy') do
63
+ response = Espago.charges :delete,{charge_id:'pay_kQmS_3RTfm4eix', app_id: 'app_id_test', app_password: 'app_password_test', production: false}
64
+ response.state.should eq('reversed')
65
+ end
66
+ end
67
+
68
+ it "should get refunded status after refund charge" do
69
+ VCR.use_cassette('charges refund') do
70
+ response = Espago.charges_refund :post,{charge_id:'pay_lQGyIon5qG59O5', app_id: 'app_id_test', app_password: 'app_password_test', production: false}
71
+ response.state.should eq('refunded')
72
+ end
73
+ end
74
+
75
+ it "should get params from complete charge" do
76
+ VCR.use_cassette('charges complete') do
77
+ response = Espago.charges_complete :post,{charge_id:'pay_kQmS_3RTfm4eix', app_id: 'app_id_test', app_password: 'app_password_test', production: false}
78
+ response.state.should eq('executed')
79
+ end
80
+ end
81
+
82
+ it "should get params from complete charge (deprecated)" do
83
+ VCR.use_cassette('charges complete deprecation') do
84
+ response = Espago.complete :post,{charge_id:'pay_Wmu3hmXJIG4jsg', app_id: 'app_id_test', app_password: 'app_password_test', production: false}
85
+ response.state.should eq('executed')
86
+ end
87
+ end
88
+
89
+ end
@@ -0,0 +1,20 @@
1
+
2
+ require "spec_helper"
3
+
4
+ describe 'Espago.dcc_decision' do
5
+
6
+ it "should get params from new charge" do
7
+ VCR.use_cassette('dcc_decision post') do
8
+ response = Espago.dcc_decision :post, {charge_id:'pay_mTOngouLTJWZ0w', decision:'Y'}
9
+ response.status.should eq(201)
10
+ response.channel.should eq('elavon')
11
+ response.state.should eq('executed')
12
+ response.currency.should eq('PLN')
13
+ response.description.should eq('Test12345')
14
+ response.client.should eq('cli_YM5tKz6-IfhN7T')
15
+ response.created_at.should eq Time.at(1416917311)
16
+ end
17
+ end
18
+
19
+
20
+ end
@@ -0,0 +1,48 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://app_id_test:app_password_test@sandbox.espago.com/api/charges/pay_mTOngouLTJWZ0w/dcc_decision
6
+ body:
7
+ encoding: US-ASCII
8
+ string: decision=Y
9
+ headers:
10
+ Accept:
11
+ - application/vnd.espago.v2+json
12
+ Content-Type:
13
+ - application/x-www-form-urlencoded
14
+ Accept-Encoding:
15
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
16
+ User-Agent:
17
+ - Ruby
18
+ response:
19
+ status:
20
+ code: 201
21
+ message: Created
22
+ headers:
23
+ Content-Type:
24
+ - application/json; charset=utf-8
25
+ X-Meta-Request-Version:
26
+ - 0.2.2
27
+ X-Ua-Compatible:
28
+ - IE=Edge
29
+ Etag:
30
+ - '"972a1a29ea0e1d4a67e169d8b84b506a"'
31
+ Cache-Control:
32
+ - max-age=0, private, must-revalidate
33
+ Set-Cookie:
34
+ - _session_id=d98575dab0f9a2cbdc9c8c91fab16247; path=/; HttpOnly
35
+ X-Request-Id:
36
+ - 2f00526303e5645e1c0a69f02d9a0afb
37
+ X-Runtime:
38
+ - '1.214083'
39
+ Connection:
40
+ - close
41
+ Server:
42
+ - thin 1.5.0 codename Knife
43
+ body:
44
+ encoding: UTF-8
45
+ string: '{"id":"pay_mTOngouLTJWZ0w","description":"Test12345","channel":"elavon","amount":"49.99","currency":"PLN","state":"executed","client":"cli_YM5tKz6-IfhN7T","created_at":1416917311,"card":{"company":"VI","last4":"4242","year":2015,"month":2,"first_name":"Jan","last_name":"Kowalski","authorized":null,"created_at":1416917311},"issuer_response_code":"00","reversable":true,"transaction_id":"tn_5puLXUWDf"}'
46
+ http_version:
47
+ recorded_at: Tue, 25 Nov 2014 12:08:32 GMT
48
+ recorded_with: VCR 2.9.3
@@ -7,6 +7,7 @@
7
7
  require 'simplecov'
8
8
  SimpleCov.start
9
9
 
10
+
10
11
  require "codeclimate-test-reporter"
11
12
  CodeClimate::TestReporter.start
12
13
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: espago
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piotrek
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-12-29 00:00:00.000000000 Z
13
+ date: 2016-08-17 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: faraday
@@ -40,6 +40,20 @@ dependencies:
40
40
  - - ">="
41
41
  - !ruby/object:Gem::Version
42
42
  version: '0'
43
+ - !ruby/object:Gem::Dependency
44
+ name: rails
45
+ requirement: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ type: :runtime
51
+ prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
43
57
  - !ruby/object:Gem::Dependency
44
58
  name: rspec
45
59
  requirement: !ruby/object:Gem::Requirement
@@ -195,6 +209,12 @@ files:
195
209
  - LICENSE.txt
196
210
  - README.md
197
211
  - Rakefile
212
+ - app/helpers/espago/masterpass_helper.rb
213
+ - app/helpers/espago/secure_web_page_helper.rb
214
+ - app/views/espago_masterpass/_masterpass_button.html.haml
215
+ - app/views/espago_masterpass/_masterpass_pairing_button.html.haml
216
+ - app/views/espago_masterpass/_masterpass_precheckout_button.html.haml
217
+ - app/views/espago_secure_web_page/_form.html.haml
198
218
  - espago.gemspec
199
219
  - lib/espago.rb
200
220
  - lib/espago/api_connection.rb
@@ -216,11 +236,13 @@ files:
216
236
  - lib/espago/api_connection/clients_put.rb
217
237
  - lib/espago/api_connection/clients_subscriptions_get.rb
218
238
  - lib/espago/api_connection/complete_post.rb
239
+ - lib/espago/api_connection/dcc_decision_post.rb
219
240
  - lib/espago/api_connection/invoice_items_delete.rb
220
241
  - lib/espago/api_connection/invoice_items_get.rb
221
242
  - lib/espago/api_connection/invoice_items_post.rb
222
243
  - lib/espago/api_connection/invoices_get.rb
223
244
  - lib/espago/api_connection/line_items_get.rb
245
+ - lib/espago/api_connection/masterpass_post.rb
224
246
  - lib/espago/api_connection/plans_delete.rb
225
247
  - lib/espago/api_connection/plans_get.rb
226
248
  - lib/espago/api_connection/plans_post.rb
@@ -232,13 +254,19 @@ files:
232
254
  - lib/espago/api_connection/tokens_post.rb
233
255
  - lib/espago/back_request.rb
234
256
  - lib/espago/client.rb
257
+ - lib/espago/engine.rb
235
258
  - lib/espago/error.rb
236
259
  - lib/espago/error/api_error.rb
237
260
  - lib/espago/error/authentication_error.rb
238
261
  - lib/espago/error/invalid_request_error.rb
262
+ - lib/espago/masterpass.rb
239
263
  - lib/espago/response.rb
240
264
  - lib/espago/router.rb
265
+ - lib/espago/secure_web_page.rb
241
266
  - lib/espago/version.rb
267
+ - lib/generators/espago/install_generator.rb
268
+ - lib/generators/espago/templates/README
269
+ - lib/generators/espago/templates/espago.rb
242
270
  - spec/espago/api_connection_spec.rb
243
271
  - spec/espago/back_request_spec.rb
244
272
  - spec/espago/client_spec.rb
@@ -247,7 +275,9 @@ files:
247
275
  - spec/espago/router_spec.rb
248
276
  - spec/features/apis_spec.rb
249
277
  - spec/features/charges_spec.rb
278
+ - spec/features/charges_spec_with_params_spec.rb
250
279
  - spec/features/clients_spec.rb
280
+ - spec/features/dcc_decision_spec.rb
251
281
  - spec/features/error_spec.rb
252
282
  - spec/features/invoice_items_spec.rb
253
283
  - spec/features/invoices_spec.rb
@@ -272,6 +302,7 @@ files:
272
302
  - spec/fixtures/cassettes/clients_post.yml
273
303
  - spec/fixtures/cassettes/clients_put.yml
274
304
  - spec/fixtures/cassettes/clients_subscriptions.yml
305
+ - spec/fixtures/cassettes/dcc_decision_post.yml
275
306
  - spec/fixtures/cassettes/error_400.yml
276
307
  - spec/fixtures/cassettes/error_401.yml
277
308
  - spec/fixtures/cassettes/error_500.yml
@@ -313,7 +344,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
313
344
  version: '0'
314
345
  requirements: []
315
346
  rubyforge_project:
316
- rubygems_version: 2.4.4
347
+ rubygems_version: 2.4.6
317
348
  signing_key:
318
349
  specification_version: 4
319
350
  summary: Espago api wrapper
@@ -326,7 +357,9 @@ test_files:
326
357
  - spec/espago/router_spec.rb
327
358
  - spec/features/apis_spec.rb
328
359
  - spec/features/charges_spec.rb
360
+ - spec/features/charges_spec_with_params_spec.rb
329
361
  - spec/features/clients_spec.rb
362
+ - spec/features/dcc_decision_spec.rb
330
363
  - spec/features/error_spec.rb
331
364
  - spec/features/invoice_items_spec.rb
332
365
  - spec/features/invoices_spec.rb
@@ -351,6 +384,7 @@ test_files:
351
384
  - spec/fixtures/cassettes/clients_post.yml
352
385
  - spec/fixtures/cassettes/clients_put.yml
353
386
  - spec/fixtures/cassettes/clients_subscriptions.yml
387
+ - spec/fixtures/cassettes/dcc_decision_post.yml
354
388
  - spec/fixtures/cassettes/error_400.yml
355
389
  - spec/fixtures/cassettes/error_401.yml
356
390
  - spec/fixtures/cassettes/error_500.yml