vsafe-ruby 0.2.4 → 0.2.5

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: 4bb461c8893fc84ffecfe88bfcb4e8214e1fb6b8
4
- data.tar.gz: f69e5b442e90cc57110050243a5fb95f18e993d7
3
+ metadata.gz: caa939a1fa93c52046ee1d940802c9c007c9d98e
4
+ data.tar.gz: abf8c9a62b94fee0bc7bd6f7a6f13a89f26be136
5
5
  SHA512:
6
- metadata.gz: 910cf1504160cbcad1ed41e2ad3b6ddd5f6046b118647eb07e506492eff34f11978d5ed66232ed9a866a96990198ca916b11643bcee1ed2eaed49377bb0f3412
7
- data.tar.gz: 582cbed640f692d515ce09841d005881a87a467473cb11616dcd5e887fb57ddecefb011d19ac3ede373a8c421d8c90e29a857a4706889395b6349f5c8351c6b1
6
+ metadata.gz: 3845e7932d099f3433ad53df820a91ec55230eba1f2202c3f9d9986ef48be3125a70cf627b85a9b5797dd1e5203ac47db044ef95e3ac725681674752457d6312
7
+ data.tar.gz: 88f88efb61a1ecd1a34b81ad1b99d704fb42bfb3cff42cce4115b2114766d5025a0f1f776819af794bfc57c33d686b7ad1faa5e12ac9b192359ae42a62a744d4
data/README.md CHANGED
@@ -224,6 +224,25 @@ response.payment_id
224
224
  response.payment_status
225
225
  ```
226
226
 
227
+ ##### Get Payment Status
228
+
229
+ Get the payment status by the partner transaction ID or Vesta Payment ID.
230
+
231
+ ```ruby
232
+ params = {
233
+ PartnerTransactionID: '333c1b85-c5db-4648-a946-ba408582fc1c'
234
+ }
235
+ response = client.get_payment_status(params) # => #<VSafe::Responses::GetPaymentStatus ...>
236
+
237
+ # Response attributes
238
+ response.amount
239
+ response.payment_id
240
+ response.payment_status
241
+ response.response_code
242
+ response.transaction_id
243
+ ```
244
+
245
+ Note: If transaction does not exist on Vesta, result of `response.success?` will be false.
227
246
 
228
247
  ## Contributing
229
248
 
@@ -8,6 +8,7 @@ require "vsafe/responses/reverse_payment"
8
8
  require "vsafe/responses/charge_account_to_temporary_token"
9
9
  require "vsafe/responses/charge_sale"
10
10
  require "vsafe/responses/validate_charge_account"
11
+ require "vsafe/responses/get_payment_status"
11
12
  require "securerandom"
12
13
  require "uri"
13
14
 
@@ -58,6 +59,10 @@ module VSafe
58
59
  VSafe::Responses::ValidateChargeAccount.new(request(service_url("ValidateChargeAccount"), params))
59
60
  end
60
61
 
62
+ def get_payment_status(params)
63
+ VSafe::Responses::GetPaymentStatus.new(request(service_url("GetPaymentStatus"), params))
64
+ end
65
+
61
66
  def service_url(endpoint = nil, jsonp = false)
62
67
  base_uri = jsonp ? config.jsonp_url : config.url
63
68
  endpoint.nil? ? base_uri : File.join(base_uri, endpoint)
@@ -89,7 +94,7 @@ module VSafe
89
94
  options[:ssl_version] = :TLSv1
90
95
  end
91
96
 
92
- response = HTTParty.post(url, options)
97
+ HTTParty.post(url, options)
93
98
  end
94
99
  end
95
100
  end
@@ -0,0 +1,13 @@
1
+ require "vsafe/response"
2
+
3
+ module VSafe
4
+ module Responses
5
+ class GetPaymentStatus < Response
6
+ define_attribute_mapping(:amount, "Amount")
7
+ define_attribute_mapping(:payment_id, "PaymentID")
8
+ define_attribute_mapping(:payment_status, "PaymentStatus", PaymentStatus)
9
+ define_attribute_mapping(:response_code, "ResponseCode")
10
+ define_attribute_mapping(:transaction_id, "TransactionID")
11
+ end
12
+ end
13
+ end
@@ -1,3 +1,3 @@
1
1
  module VSafe
2
- VERSION = "0.2.4"
2
+ VERSION = "0.2.5"
3
3
  end
@@ -130,6 +130,16 @@ RSpec.describe VSafe::Client do
130
130
  end
131
131
  end
132
132
 
133
+ describe "#get_payment_status" do
134
+ it "returns response" do
135
+ stub_vsafe_request("GetPaymentStatus")
136
+ response = client.get_payment_status(params)
137
+
138
+ expect(response).to be_a(VSafe::Responses::GetPaymentStatus)
139
+ expect(response).to be_success
140
+ end
141
+ end
142
+
133
143
  describe "#service_url" do
134
144
  shared_examples_for "returns url" do |jsonp|
135
145
  context "when endpoint defined" do
@@ -0,0 +1,24 @@
1
+ require "spec_helper"
2
+ require "vsafe/responses/get_session_tags"
3
+
4
+ RSpec.describe VSafe::Responses::GetPaymentStatus do
5
+ let(:success_body) {
6
+ {
7
+ "ResponseCode" => "0",
8
+ "Amount" => "5.0000",
9
+ "PaymentID" => "1234",
10
+ "PaymentStatus" => "3",
11
+ "TransactionID" => "23",
12
+ }
13
+ }
14
+ let(:http_response) { double(:response, success?: true, parsed_response: success_body) }
15
+ subject(:response) { VSafe::Responses::GetPaymentStatus.new(http_response) }
16
+
17
+ it { is_expected.to have_attributes(response_code: '0') }
18
+ it { is_expected.to have_attributes(amount: '5.0000') }
19
+ it { is_expected.to have_attributes(payment_id: '1234') }
20
+ it { is_expected.to have_attributes(transaction_id: '23') }
21
+ it 'should have correct payment status code' do
22
+ expect(response.payment_status.code).to eq(3)
23
+ end
24
+ end
@@ -7,7 +7,7 @@ RSpec.describe VSafe::Responses::GetSessionTags do
7
7
  let(:success_body) {
8
8
  {
9
9
  "OrgID" => org_id,
10
- "WebSessionID" => "test_web_session_id"
10
+ "WebSessionID" => web_session_id
11
11
  }
12
12
  }
13
13
  let(:http_response) { double(:response, success?: true, parsed_response: success_body) }
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.4
4
+ version: 0.2.5
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: 2017-01-19 00:00:00.000000000 Z
13
+ date: 2017-08-30 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: httparty
@@ -124,6 +124,7 @@ files:
124
124
  - lib/vsafe/responses/charge_authorize.rb
125
125
  - lib/vsafe/responses/charge_confirm.rb
126
126
  - lib/vsafe/responses/charge_sale.rb
127
+ - lib/vsafe/responses/get_payment_status.rb
127
128
  - lib/vsafe/responses/get_session_tags.rb
128
129
  - lib/vsafe/responses/reverse_payment.rb
129
130
  - lib/vsafe/responses/validate_charge_account.rb
@@ -144,6 +145,7 @@ files:
144
145
  - spec/vsafe/responses/charge_authorize_spec.rb
145
146
  - spec/vsafe/responses/charge_confirm_spec.rb
146
147
  - spec/vsafe/responses/charge_sale_spec.rb
148
+ - spec/vsafe/responses/get_payment_status_spec.rb
147
149
  - spec/vsafe/responses/get_session_tags_spec.rb
148
150
  - spec/vsafe/responses/reverse_payment_spec.rb
149
151
  - spec/vsafe/responses/validate_charge_account.rb