payson_api 1.0.1 → 1.0.2

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
  SHA256:
3
- metadata.gz: 66f555c3be4e18baaad0ed1785a94c4c9b248d62aabf7cbb1caeab6c3e55ae17
4
- data.tar.gz: 6d95db7cf0198afa8ebae7fee4d077c87b306982eb70e533f71248fa7fbbbb4a
3
+ metadata.gz: 4542d9a26a029687326f4a3f7f8fbc196b1c7f1c1c176407aea8f45cf1621346
4
+ data.tar.gz: 2d0b654fea59184a93827c87e6f57dde0d6194ae8dd81b3d6e7e541415349f6f
5
5
  SHA512:
6
- metadata.gz: 0dbfff1f59b35aa89efed837854bc9b5afd3c7e6a4dceec2574715e54ceb60bd210b104803ede5f7ab8edf76999d3f037420aee9241789be178067352d37d238
7
- data.tar.gz: cb319533f28f26526b83bffc112a5ebd6ba47ed82b16ff2724066d23032f6dea4ab00a2045ff883b15a3c34570f0bac914e27a491f56267496948c8c7445fa9e
6
+ metadata.gz: 741d52cce371302839ce8ff2f68dd4b92c9312724563c22091fed701f5f06f3110ce0596464df6982121d5eaa1daac50ed71e6a4c8b1e0907275ee5a10558746
7
+ data.tar.gz: ce5ff56b813dbdb555845072de35b872328613ebddc1e5c84204b6999a96cff20c154aa368f53bc464123370c7dcdab61a891c736f94ebd0dfa8bcf88c4578ba
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Payson API
2
2
 
3
- A simple utility to handle requests against the Payson payment gateway API.
3
+ A zero dependency, pure Ruby utility to handle requests against the Payson payment gateway API.
4
4
 
5
5
  ## Supported Ruby versions
6
6
 
@@ -8,7 +8,7 @@ A simple utility to handle requests against the Payson payment gateway API.
8
8
  * 2.7
9
9
  * 3.0
10
10
 
11
- ## Install
11
+ ## Installation
12
12
 
13
13
  Put this line in your Gemfile:
14
14
 
@@ -58,6 +58,10 @@ request.order.items << PaysonAPI::V2::Requests::OrderItem.new.tap do |item|
58
58
  item.quantity = 3
59
59
  item.reference = 'product-1'
60
60
  end
61
+
62
+ checkout = PaysonAPI::V2::Client.create_checkout(request)
63
+
64
+ # Continue by rendering the HTML from checkout.snippet.
61
65
  ```
62
66
 
63
67
  ### Updating a checkout
@@ -116,8 +120,6 @@ payment.return_url = 'http://localhost/payson/success'
116
120
  payment.cancel_url = 'http://localhost/payson/cancel'
117
121
  payment.ipn_url = 'http://localhost/payson/ipn'
118
122
  payment.memo = 'Sample order description'
119
- payment.sender = sender
120
-
121
123
  payment.sender = PaysonAPI::V1::Sender.new.tap do |s|
122
124
  s.email = 'mycustomer@mydomain.com'
123
125
  s.first_name = 'My'
@@ -197,10 +199,10 @@ class Payson < ApplicationController
197
199
  # Create a new IPN request object containing the raw response from above
198
200
  ipn_request = PaysonAPI::V1::Requests::IPN.new(ipn_response.raw)
199
201
 
200
- validate = PaysonAPI::V1::Client.validate_ipn(ipn_request)
202
+ validation = PaysonAPI::V1::Client.validate_ipn(ipn_request)
201
203
 
202
- unless validate.verified?
203
- raise "Something went terribly wrong."
204
+ unless validation.verified?
205
+ raise "Something went terribly wrong"
204
206
  end
205
207
 
206
208
  # Do business transactions, e.g. update the corresponding order:
@@ -213,15 +215,15 @@ end
213
215
 
214
216
  ## Todo
215
217
 
216
- Document the code for the Payson Checkout v2 processes.
218
+ Nothing at the moment.
217
219
 
218
- ## Build Status
220
+ ## Project Status
219
221
 
220
- [![Build Status](https://travis-ci.org/stoffus/payson_api.svg?branch=master)](https://travis-ci.org/stoffus/payson_api)
222
+ [![Build Status](https://travis-ci.org/stoffus/payson_api.svg?branch=master)](https://travis-ci.org/stoffus/payson_api) [![Gem Version](https://badge.fury.io/rb/payson_api.svg)](https://badge.fury.io/rb/payson_api)
221
223
 
222
224
  ## Questions, Feedback
223
225
 
224
- Feel free to message me on Github (stoffus).
226
+ Feel free to message me on [GitHub](https://github.com/stoffus).
225
227
 
226
228
  ## Copyright
227
229
 
@@ -18,13 +18,13 @@ module PaysonAPI
18
18
 
19
19
  def self.create_checkout(request)
20
20
  response = payson_request(Net::HTTP::Post, PAYSON_API_RESOURCES[:checkouts][:create], request)
21
- handle_validation_error(response)
21
+ intercept_validation_errors(response)
22
22
  PaysonAPI::V2::Models::Checkout.from_hash(JSON.parse(response.body))
23
23
  end
24
24
 
25
25
  def self.update_checkout(request)
26
26
  response = payson_request(Net::HTTP::Put, PAYSON_API_RESOURCES[:checkouts][:update] % request.id, request)
27
- handle_validation_error(response)
27
+ intercept_validation_errors(response)
28
28
  PaysonAPI::V2::Models::Checkout.from_hash(JSON.parse(response.body))
29
29
  end
30
30
 
@@ -38,7 +38,7 @@ module PaysonAPI
38
38
  end
39
39
  end
40
40
 
41
- def self.handle_validation_error(response)
41
+ def self.intercept_validation_errors(response)
42
42
  if response.code == '400' || response.code == '500' # rubocop:disable Style/GuardClause
43
43
  raise PaysonAPI::V2::Errors::ValidationError, errors: JSON.parse(response.body)['errors']
44
44
  end
@@ -62,6 +62,8 @@ module PaysonAPI
62
62
 
63
63
  response
64
64
  end
65
+
66
+ private_class_method :intercept_validation_errors, :hash_to_params, :payson_request
65
67
  end
66
68
  end
67
69
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PaysonAPI
4
- VERSION = '1.0.1'
4
+ VERSION = '1.0.2'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: payson_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christopher Svensson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-19 00:00:00.000000000 Z
11
+ date: 2021-05-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake