vsafe-ruby 0.2.2 → 0.2.3

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: 9554215e285634ed75d2a15ee084aee48fd4dc21
4
- data.tar.gz: fc340a8c12c446ec0e6c168b9fcb777e3a7dd819
3
+ metadata.gz: 42ca5c86cc1aae19ac162345d5c41e9ab5a2ff13
4
+ data.tar.gz: 35e6a7bd5d93ca41f493ab25c44570c9190e105c
5
5
  SHA512:
6
- metadata.gz: 15a2f77685b3c972eba40a1c1db35112f0ca56706048c6632889b0be2685bdbf3635307948177c407247b4b95712188cc62b169ae23513d3e78add18c1661c1e
7
- data.tar.gz: 6668a08b8e4c50006814118e5ce1f8de165f7fc9eec840e84bbe3cb251255a3f6b0d41c29016564a43a67e0fd43c6bd3e5f26bfc9f6bfc3b29ac0f9bc65e9abf
6
+ metadata.gz: e7e79ed77717746c8a6a87da802cd4a88926a86da6d093d1b1c59674651e9734a4d3c9f4f8d3c651e453e7188a36cb553c22ec16f14bf6120ee36f825c89f51b
7
+ data.tar.gz: 2c64494c69dbb7e78c6e2571d5bead80f4dcc2d828d88d55927a92f6c395d6a8257868857c13731c53b80adb4c03bc49ab09ba57d7443dd7d9af8c718f689e69
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  # VSafe
2
-
2
+ [![Build Status](https://travis-ci.org/listia/vsafe-ruby.svg?branch=master)](https://travis-ci.org/listia/vsafe-ruby)
3
+ [![Gem Version](https://badge.fury.io/rb/vsafe-ruby.svg)](http://badge.fury.io/rb/vsafe-ruby)
3
4
 
4
5
  ## Installation
5
6
 
@@ -46,13 +47,18 @@ client = VSafe::Client.new
46
47
  ```
47
48
 
48
49
  ##### Heartbeat request
50
+
51
+ Check if VSafe API is up or not.
52
+
49
53
  ```ruby
50
- # Check if VSafe API is up or not
51
54
  client.heartbeat.success?
52
55
 
53
56
  ```
54
57
 
55
58
  ##### Get vesta session tags
59
+
60
+ Get web session id for `WEB` charge source.
61
+
56
62
  ```ruby
57
63
  response = client.get_session_tags # => #<VSafe::Responses::GetSessionTags ...>
58
64
 
@@ -61,42 +67,6 @@ response.org_id
61
67
  response.web_session_id
62
68
  ```
63
69
 
64
- ##### Authorize charge
65
- ```ruby
66
- auth_params = {
67
- TransactionID: "...",
68
- ChargeAccountNumberToken: "...",
69
- ChargeAmount: 10,
70
- WebSessionID: "100_000000000", # Fingerprint generated by get_session_tags as part of ChargeSource::WEB transaction
71
- PaymentDescriptor: "...",
72
- ChargeSource: VSafe::ChargeSource::WEB, # Or VSafe::ChargeSource::PPD/VSafe::ChargeSource::TEL
73
- RiskInformation: "...", # XML string for the transaction
74
- IsTempToken: false,
75
- CardHolderFirstName: "Foo",
76
- CardHolderLastName: "Bar",
77
- CardHolderAddressLine1: "...",
78
- CardHolderAddressLine2: "...",
79
- CardHolderCity: "...",
80
- CardHolderRegion: "...",
81
- CardHolderPostalCode: "...",
82
- CardHolderCountryCode: "...",
83
- ChargeCVN: 123, # Card's CVV
84
- ChargeExpirationMMYY: "1221", # Card's expiration date in MMYY format
85
- StoreCard: true # Get a permanent token or not
86
- }
87
-
88
- client.charge_authorize(params) # => #<VSafe::Responses::ChargeAuthorize ...>
89
-
90
- # Response attributes
91
- response.avs_result
92
- response.auth_result
93
- response.cvn_result
94
- response.charge_permanent_token
95
- response.payment_acquirer_name
96
- response.payment_id
97
- response.payment_status
98
- ```
99
-
100
70
  ##### Authorize charge
101
71
 
102
72
  Authorize a credit card charge attempt for later confirm usage.
@@ -15,9 +15,6 @@ module VSafe
15
15
  class Client
16
16
  SANDBOX_FINGERPRINT_PATH = "ThreatMetrixUIRedirector".freeze
17
17
  FINGERPRINT_PATH = "PaySafeUIRedirector".freeze
18
- # We should only use JSONP_SERVICE_PATH for charge_acct_to_tempory_token call in web js.
19
- JSONP_SERVICE_PATH = "GatewayProxyJSON/Service".freeze
20
- SERVICE_PATH = "GatewayProxy/Service".freeze
21
18
  REQUEST_CONTENT_TYPE = "application/json; charset=utf-8".freeze
22
19
 
23
20
  attr_reader :config
@@ -64,7 +61,7 @@ module VSafe
64
61
  def service_url(endpoint = nil, jsonp = false)
65
62
  parts = [
66
63
  config.url,
67
- jsonp ? JSONP_SERVICE_PATH : SERVICE_PATH
64
+ jsonp ? config.jsonp_service_path : config.service_path
68
65
  ]
69
66
  parts << endpoint if endpoint
70
67
 
@@ -3,20 +3,30 @@ module VSafe
3
3
  DEFAULT_REQUEST_TIMEOUT = 20 # seconds
4
4
  DEFAULT_SANDBOX_URL = "https://paysafesandbox.ecustomersupport.com".freeze
5
5
  DEFAULT_PRODUCTION_URL = "https://paysafe.ecustomerpayments.com".freeze
6
+ DEFAULT_JSONP_SERVICE_PATH = "GatewayProxyJSON/Service".freeze
7
+ DEFAULT_SERVICE_PATH = "GatewayProxy/Service".freeze
6
8
 
7
- attr_accessor :sandbox,
9
+ attr_accessor :sandbox_url,
10
+ :production_url,
11
+ :sandbox,
8
12
  :account_name,
9
13
  :password,
14
+ :service_path,
15
+ :jsonp_service_path,
10
16
  :request_timeout
11
17
 
12
18
  def initialize
13
19
  # Set sandbox to true by default
14
20
  @sandbox = true
21
+ @service_path = DEFAULT_SERVICE_PATH
22
+ @jsonp_service_path = DEFAULT_JSONP_SERVICE_PATH
15
23
  @request_timeout = DEFAULT_REQUEST_TIMEOUT
24
+ @sandbox_url = DEFAULT_SANDBOX_URL
25
+ @production_url = DEFAULT_PRODUCTION_URL
16
26
  end
17
27
 
18
28
  def url
19
- sandbox ? DEFAULT_SANDBOX_URL : DEFAULT_PRODUCTION_URL
29
+ sandbox ? @sandbox_url : @production_url
20
30
  end
21
31
  end
22
32
  end
@@ -1,3 +1,3 @@
1
1
  module VSafe
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
@@ -150,13 +150,35 @@ RSpec.describe VSafe::Client do
150
150
  end
151
151
 
152
152
  context "when jsonp is false" do
153
- let(:service_path) { VSafe::Client::SERVICE_PATH }
153
+ let(:service_path) { VSafe::Config::DEFAULT_SERVICE_PATH }
154
154
 
155
155
  it_behaves_like "returns url"
156
156
  end
157
157
 
158
158
  context "when jsonp is true" do
159
- let(:service_path) { VSafe::Client::JSONP_SERVICE_PATH }
159
+ let(:service_path) { VSafe::Config::DEFAULT_JSONP_SERVICE_PATH }
160
+
161
+ it_behaves_like "returns url", true
162
+ end
163
+
164
+ context "when custom service_path is set" do
165
+ let(:service_path) { "__custom_service" }
166
+ let(:client) {
167
+ VSafe::Client.new do |config|
168
+ config.service_path = "__custom_service"
169
+ end
170
+ }
171
+
172
+ it_behaves_like "returns url"
173
+ end
174
+
175
+ context "when custom jsonp_service_path is set" do
176
+ let(:service_path) { "__custom_jsonp" }
177
+ let(:client) {
178
+ VSafe::Client.new do |config|
179
+ config.jsonp_service_path = "__custom_jsonp"
180
+ end
181
+ }
160
182
 
161
183
  it_behaves_like "returns url", true
162
184
  end
@@ -2,13 +2,41 @@ require "spec_helper"
2
2
  require "vsafe/config"
3
3
 
4
4
  RSpec.describe VSafe::Config do
5
+ let (:config) { VSafe::Config.new }
6
+
5
7
  describe ".new" do
6
8
  it "sets default configs" do
7
- config = VSafe::Config.new
8
-
9
9
  expect(config.sandbox).to eq(true)
10
10
  expect(config.request_timeout).to be_a(Fixnum)
11
11
  expect(config.url).not_to be_empty
12
12
  end
13
13
  end
14
+
15
+ describe "#url" do
16
+ context "sandbox is true" do
17
+ it "uses default sandbox_url" do
18
+ expect(config.url).to eq(VSafe::Config::DEFAULT_SANDBOX_URL)
19
+ end
20
+
21
+ it "uses custom sandbox_url when sandbox" do
22
+ config.sandbox_url = "https://www.google.com"
23
+ expect(config.url).to eq("https://www.google.com")
24
+ end
25
+ end
26
+
27
+ context "sandbox is not true" do
28
+ before do
29
+ config.sandbox = false
30
+ end
31
+
32
+ it "uses default production_url when not sandbox" do
33
+ expect(config.url).to eq(VSafe::Config::DEFAULT_PRODUCTION_URL)
34
+ end
35
+
36
+ it "uses custom production_url when not sandbox" do
37
+ config.production_url = "https://www.google.com"
38
+ expect(config.url).to eq("https://www.google.com")
39
+ end
40
+ end
41
+ end
14
42
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vsafe-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Xiaoming Lu
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2016-06-30 00:00:00.000000000 Z
13
+ date: 2016-12-12 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: httparty