payson_api 0.3.2 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +16 -17
  3. data/README.md +228 -0
  4. data/lib/payson_api.rb +55 -22
  5. data/lib/payson_api/v1/client.rb +80 -0
  6. data/lib/payson_api/v1/config.rb +63 -0
  7. data/lib/payson_api/v1/envelope.rb +27 -0
  8. data/lib/payson_api/v1/errors/unknown_currency_error.rb +13 -0
  9. data/lib/payson_api/v1/errors/unknown_fees_payer_error.rb +13 -0
  10. data/lib/payson_api/v1/errors/unknown_funding_constraint_error.rb +13 -0
  11. data/lib/payson_api/v1/errors/unknown_guarantee_offering_error.rb +13 -0
  12. data/lib/payson_api/v1/errors/unknown_locale_error.rb +13 -0
  13. data/lib/payson_api/v1/errors/unknown_payment_action_error.rb +13 -0
  14. data/lib/payson_api/v1/funding.rb +38 -0
  15. data/lib/payson_api/v1/order_item.rb +43 -0
  16. data/lib/payson_api/v1/receiver.rb +46 -0
  17. data/lib/payson_api/v1/remote_error.rb +36 -0
  18. data/lib/payson_api/v1/requests/ipn.rb +19 -0
  19. data/lib/payson_api/v1/requests/payment.rb +68 -0
  20. data/lib/payson_api/v1/requests/payment_details.rb +19 -0
  21. data/lib/payson_api/v1/requests/payment_update.rb +27 -0
  22. data/lib/payson_api/v1/responses/ipn.rb +43 -0
  23. data/lib/payson_api/v1/responses/payment.rb +25 -0
  24. data/lib/payson_api/v1/responses/payment_details.rb +50 -0
  25. data/lib/payson_api/v1/responses/payment_update.rb +20 -0
  26. data/lib/payson_api/v1/responses/validate.rb +19 -0
  27. data/lib/payson_api/v1/sender.rb +28 -0
  28. data/lib/payson_api/v1/shipping_address.rb +34 -0
  29. data/lib/payson_api/v2/client.rb +67 -0
  30. data/lib/payson_api/v2/config.rb +51 -0
  31. data/lib/payson_api/v2/errors/unauthorized_error.rb +10 -0
  32. data/lib/payson_api/v2/errors/validation_error.rb +16 -0
  33. data/lib/payson_api/v2/models/account.rb +23 -0
  34. data/lib/payson_api/v2/models/checkout.rb +28 -0
  35. data/lib/payson_api/v2/models/customer.rb +27 -0
  36. data/lib/payson_api/v2/models/merchant.rb +24 -0
  37. data/lib/payson_api/v2/models/order.rb +32 -0
  38. data/lib/payson_api/v2/models/order_item.rb +33 -0
  39. data/lib/payson_api/v2/requests/create_checkout.rb +26 -0
  40. data/lib/payson_api/v2/requests/customer.rb +23 -0
  41. data/lib/payson_api/v2/requests/list_checkouts.rb +23 -0
  42. data/lib/payson_api/v2/requests/merchant.rb +25 -0
  43. data/lib/payson_api/v2/requests/order.rb +22 -0
  44. data/lib/payson_api/v2/requests/order_item.rb +27 -0
  45. data/lib/payson_api/v2/requests/update_checkout.rb +25 -0
  46. data/lib/payson_api/version.rb +3 -1
  47. metadata +78 -67
  48. data/.gitignore +0 -7
  49. data/.travis.yml +0 -6
  50. data/Gemfile +0 -11
  51. data/Guardfile +0 -9
  52. data/README.rdoc +0 -155
  53. data/Rakefile +0 -24
  54. data/lib/payson_api/client.rb +0 -79
  55. data/lib/payson_api/config.rb +0 -50
  56. data/lib/payson_api/envelope.rb +0 -21
  57. data/lib/payson_api/funding.rb +0 -34
  58. data/lib/payson_api/order_item.rb +0 -52
  59. data/lib/payson_api/receiver.rb +0 -52
  60. data/lib/payson_api/remote_error.rb +0 -31
  61. data/lib/payson_api/request/ipn.rb +0 -15
  62. data/lib/payson_api/request/payment.rb +0 -66
  63. data/lib/payson_api/request/payment_details.rb +0 -15
  64. data/lib/payson_api/request/payment_update.rb +0 -22
  65. data/lib/payson_api/response/ipn.rb +0 -36
  66. data/lib/payson_api/response/payment.rb +0 -22
  67. data/lib/payson_api/response/payment_details.rb +0 -43
  68. data/lib/payson_api/response/payment_update.rb +0 -16
  69. data/lib/payson_api/response/validate.rb +0 -15
  70. data/lib/payson_api/sender.rb +0 -29
  71. data/lib/payson_api/shipping_address.rb +0 -36
  72. data/payson_api.gemspec +0 -23
  73. data/test/fixtures/config.yml +0 -2
  74. data/test/fixtures/payment_data.yml +0 -37
  75. data/test/integration/config_test.rb +0 -15
  76. data/test/integration/payment_details_test.rb +0 -21
  77. data/test/integration/payment_test.rb +0 -65
  78. data/test/test_helper.rb +0 -76
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PaysonAPI
4
+ module V2
5
+ module Models
6
+ class Order
7
+ attr_accessor :currency, :total_fee_excluding_tax, :total_fee_including_tax,
8
+ :total_price_excluding_tax, :total_price_including_tax, :total_tax_amount,
9
+ :total_credited_amount, :items
10
+
11
+ def self.from_hash(hash)
12
+ new.tap do |order|
13
+ order.currency = hash['currency']
14
+ order.total_fee_excluding_tax = hash['totalFeeExcludingTax']
15
+ order.total_fee_including_tax = hash['totalFeeIncludingTax']
16
+ order.total_price_excluding_tax = hash['totalPriceIncludingTax']
17
+ order.total_price_including_tax = hash['totalPriceIncludingTax']
18
+ order.total_tax_amount = hash['totalTaxAmount']
19
+ order.total_credited_amount = hash['totalCreditedAmount']
20
+
21
+ if hash['items']
22
+ order.items = []
23
+ hash['items'].each do |item|
24
+ order.items << PaysonAPI::V2::Models::OrderItem.from_hash(item)
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PaysonAPI
4
+ module V2
5
+ module Models
6
+ class OrderItem
7
+ attr_accessor :item_id, :discount_rate, :ean, :image_uri, :name, :quantity,
8
+ :reference, :tax_rate, :total_price_excluding_tax, :total_price_including_tax,
9
+ :total_tax_amount, :credited_amount, :type, :unit_price, :uri
10
+
11
+ def self.from_hash(hash) # rubocop:disable Metrics/AbcSize
12
+ new.tap do |item|
13
+ item.item_id = hash['itemId']
14
+ item.discount_rate = hash['discountRate']
15
+ item.ean = hash['ean']
16
+ item.image_uri = hash['imageUri']
17
+ item.name = hash['name']
18
+ item.quantity = hash['quantity']
19
+ item.reference = hash['reference']
20
+ item.tax_rate = hash['taxRate']
21
+ item.total_price_excluding_tax = hash['totalPriceExcludingTax']
22
+ item.total_price_including_tax = hash['totalPriceIncludingTax']
23
+ item.total_tax_amount = hash['totalTaxAmount']
24
+ item.credited_amount = hash['creditedAmount']
25
+ item.type = hash['type']
26
+ item.unit_price = hash['unitPrice']
27
+ item.uri = hash['uri']
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PaysonAPI
4
+ module V2
5
+ module Requests
6
+ class CreateCheckout
7
+ attr_accessor :expiration_time, :description, :customer, :order, :merchant, :gui
8
+
9
+ def initialize
10
+ @order = PaysonAPI::V2::Requests::Order.new
11
+ @merchant = PaysonAPI::V2::Requests::Merchant.new
12
+ end
13
+
14
+ def to_hash
15
+ {}.tap do |hash|
16
+ hash['order'] = @order.to_hash
17
+ hash['merchant'] = @merchant.to_hash
18
+ hash['description'] = @description unless @description.nil?
19
+ hash['expirationTime'] = @expiration_time unless @expiration_time.nil?
20
+ hash['customer'] = @customer.to_hash unless @customer.nil?
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PaysonAPI
4
+ module V2
5
+ module Requests
6
+ class Customer
7
+ attr_accessor :email, :first_name, :last_name, :city, :zip, :street, :identity_number
8
+
9
+ def to_hash
10
+ {}.tap do |hash|
11
+ hash['email'] = @email
12
+ hash['firstName'] = @first_name
13
+ hash['lastName'] = @last_name
14
+ hash['identityNumber'] = @identity_number
15
+ hash['postalCode'] = @zip
16
+ hash['street'] = @street
17
+ hash['city'] = @city
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PaysonAPI
4
+ module V2
5
+ module Requests
6
+ class ListCheckouts
7
+ attr_accessor :page_size, :page
8
+
9
+ def initialize(page_size = 20, page = 1)
10
+ @page_size = page_size
11
+ @page = page
12
+ end
13
+
14
+ def to_hash
15
+ {}.tap do |hash|
16
+ hash['pageSize'] = @page_size
17
+ hash['page'] = @page
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PaysonAPI
4
+ module V2
5
+ module Requests
6
+ class Merchant
7
+ attr_accessor :checkout_uri, :notification_uri, :terms_uri, :confirmation_uri,
8
+ :partner_id, :validation_uri, :integration_info, :reference
9
+
10
+ def to_hash
11
+ {}.tap do |hash|
12
+ hash['checkoutUri'] = @checkout_uri
13
+ hash['notificationUri'] = @notification_uri
14
+ hash['termsUri'] = @terms_uri
15
+ hash['confirmationUri'] = @confirmation_uri
16
+ hash['partnerId'] = @partner_id unless @partner_id.nil?
17
+ hash['validationUri'] = @validation_uri unless @validation_uri.nil?
18
+ hash['integrationInfo'] = @integration_info unless @integration_info.nil?
19
+ hash['reference'] = @reference unless @reference.nil?
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PaysonAPI
4
+ module V2
5
+ module Requests
6
+ class Order
7
+ attr_accessor :currency, :items
8
+
9
+ def initialize
10
+ @items = []
11
+ end
12
+
13
+ def to_hash
14
+ {}.tap do |hash|
15
+ hash['currency'] = @currency
16
+ hash['items'] = @items.map(&:to_hash)
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PaysonAPI
4
+ module V2
5
+ module Requests
6
+ class OrderItem
7
+ attr_accessor :name, :quantity, :unit_price, :ean, :tax_rate, :reference,
8
+ :discount_rate, :image_uri, :type, :uri
9
+
10
+ def to_hash # rubocop:disable Metrics/CyclomaticComplexity
11
+ {}.tap do |hash|
12
+ hash['name'] = @name
13
+ hash['quantity'] = @quantity
14
+ hash['unitPrice'] = @unit_price
15
+ hash['ean'] = @ean unless @ean.nil?
16
+ hash['taxRate'] = @tax_rate unless @tax_rate.nil?
17
+ hash['reference'] = @reference unless @reference.nil?
18
+ hash['discountRate'] = @discount_rate unless @discount_rate.nil?
19
+ hash['imageUri'] = @image_uri unless @image_uri.nil?
20
+ hash['type'] = @type unless @type.nil?
21
+ hash['uri'] = @uri unless @uri.nil?
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PaysonAPI
4
+ module V2
5
+ module Requests
6
+ class UpdateCheckout
7
+ attr_accessor :id, :status, :locale, :currency, :order, :customer, :merchant, :description
8
+
9
+ def initialize
10
+ @order = PaysonAPI::V2::Requests::Order.new
11
+ @merchant = PaysonAPI::V2::Requests::Merchant.new
12
+ end
13
+
14
+ def to_hash
15
+ {}.tap do |hash|
16
+ hash['id'] = @id
17
+ hash['order'] = @order.to_hash
18
+ hash['status'] = @status
19
+ hash['merchant'] = @merchant.to_hash
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module PaysonAPI
2
- VERSION = "0.3.2"
4
+ VERSION = '1.0.1'
3
5
  end
metadata CHANGED
@@ -1,118 +1,129 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: payson_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
5
- prerelease:
4
+ version: 1.0.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Christopher Svensson
9
- autorequire:
8
+ autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-09-08 00:00:00.000000000 Z
11
+ date: 2021-05-19 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rake
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
- version: '0'
19
+ version: '13'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - "~>"
28
25
  - !ruby/object:Gem::Version
29
- version: '0'
26
+ version: '13'
30
27
  - !ruby/object:Gem::Dependency
31
- name: guard-test
28
+ name: rubocop
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - "~>"
36
32
  - !ruby/object:Gem::Version
37
- version: '0'
33
+ version: '1.15'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - "~>"
44
39
  - !ruby/object:Gem::Version
45
- version: '0'
40
+ version: '1.15'
41
+ - !ruby/object:Gem::Dependency
42
+ name: test-unit
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.4'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.4'
46
55
  description: Client that enables access to the Payson payment gateway API.
47
- email:
48
- - stoffus@stoffus.com
56
+ email: stoffus@stoffus.com
49
57
  executables: []
50
58
  extensions: []
51
59
  extra_rdoc_files: []
52
60
  files:
53
- - .gitignore
54
- - .travis.yml
55
- - Gemfile
56
- - Guardfile
57
61
  - MIT-LICENSE
58
- - README.rdoc
59
- - Rakefile
62
+ - README.md
60
63
  - lib/payson_api.rb
61
- - lib/payson_api/client.rb
62
- - lib/payson_api/config.rb
63
- - lib/payson_api/envelope.rb
64
- - lib/payson_api/funding.rb
65
- - lib/payson_api/order_item.rb
66
- - lib/payson_api/receiver.rb
67
- - lib/payson_api/remote_error.rb
68
- - lib/payson_api/request/ipn.rb
69
- - lib/payson_api/request/payment.rb
70
- - lib/payson_api/request/payment_details.rb
71
- - lib/payson_api/request/payment_update.rb
72
- - lib/payson_api/response/ipn.rb
73
- - lib/payson_api/response/payment.rb
74
- - lib/payson_api/response/payment_details.rb
75
- - lib/payson_api/response/payment_update.rb
76
- - lib/payson_api/response/validate.rb
77
- - lib/payson_api/sender.rb
78
- - lib/payson_api/shipping_address.rb
64
+ - lib/payson_api/v1/client.rb
65
+ - lib/payson_api/v1/config.rb
66
+ - lib/payson_api/v1/envelope.rb
67
+ - lib/payson_api/v1/errors/unknown_currency_error.rb
68
+ - lib/payson_api/v1/errors/unknown_fees_payer_error.rb
69
+ - lib/payson_api/v1/errors/unknown_funding_constraint_error.rb
70
+ - lib/payson_api/v1/errors/unknown_guarantee_offering_error.rb
71
+ - lib/payson_api/v1/errors/unknown_locale_error.rb
72
+ - lib/payson_api/v1/errors/unknown_payment_action_error.rb
73
+ - lib/payson_api/v1/funding.rb
74
+ - lib/payson_api/v1/order_item.rb
75
+ - lib/payson_api/v1/receiver.rb
76
+ - lib/payson_api/v1/remote_error.rb
77
+ - lib/payson_api/v1/requests/ipn.rb
78
+ - lib/payson_api/v1/requests/payment.rb
79
+ - lib/payson_api/v1/requests/payment_details.rb
80
+ - lib/payson_api/v1/requests/payment_update.rb
81
+ - lib/payson_api/v1/responses/ipn.rb
82
+ - lib/payson_api/v1/responses/payment.rb
83
+ - lib/payson_api/v1/responses/payment_details.rb
84
+ - lib/payson_api/v1/responses/payment_update.rb
85
+ - lib/payson_api/v1/responses/validate.rb
86
+ - lib/payson_api/v1/sender.rb
87
+ - lib/payson_api/v1/shipping_address.rb
88
+ - lib/payson_api/v2/client.rb
89
+ - lib/payson_api/v2/config.rb
90
+ - lib/payson_api/v2/errors/unauthorized_error.rb
91
+ - lib/payson_api/v2/errors/validation_error.rb
92
+ - lib/payson_api/v2/models/account.rb
93
+ - lib/payson_api/v2/models/checkout.rb
94
+ - lib/payson_api/v2/models/customer.rb
95
+ - lib/payson_api/v2/models/merchant.rb
96
+ - lib/payson_api/v2/models/order.rb
97
+ - lib/payson_api/v2/models/order_item.rb
98
+ - lib/payson_api/v2/requests/create_checkout.rb
99
+ - lib/payson_api/v2/requests/customer.rb
100
+ - lib/payson_api/v2/requests/list_checkouts.rb
101
+ - lib/payson_api/v2/requests/merchant.rb
102
+ - lib/payson_api/v2/requests/order.rb
103
+ - lib/payson_api/v2/requests/order_item.rb
104
+ - lib/payson_api/v2/requests/update_checkout.rb
79
105
  - lib/payson_api/version.rb
80
- - payson_api.gemspec
81
- - test/fixtures/config.yml
82
- - test/fixtures/payment_data.yml
83
- - test/integration/config_test.rb
84
- - test/integration/payment_details_test.rb
85
- - test/integration/payment_test.rb
86
- - test/test_helper.rb
87
106
  homepage: https://github.com/stoffus/payson_api
88
107
  licenses:
89
108
  - MIT
90
- post_install_message:
109
+ metadata: {}
110
+ post_install_message:
91
111
  rdoc_options: []
92
112
  require_paths:
93
113
  - lib
94
114
  required_ruby_version: !ruby/object:Gem::Requirement
95
- none: false
96
115
  requirements:
97
- - - ! '>='
116
+ - - ">="
98
117
  - !ruby/object:Gem::Version
99
- version: '0'
118
+ version: 2.6.0
100
119
  required_rubygems_version: !ruby/object:Gem::Requirement
101
- none: false
102
120
  requirements:
103
- - - ! '>='
121
+ - - ">="
104
122
  - !ruby/object:Gem::Version
105
123
  version: '0'
106
124
  requirements: []
107
- rubyforge_project:
108
- rubygems_version: 1.8.25
109
- signing_key:
110
- specification_version: 3
125
+ rubygems_version: 3.0.6
126
+ signing_key:
127
+ specification_version: 4
111
128
  summary: Client for Payson API
112
- test_files:
113
- - test/fixtures/config.yml
114
- - test/fixtures/payment_data.yml
115
- - test/integration/config_test.rb
116
- - test/integration/payment_details_test.rb
117
- - test/integration/payment_test.rb
118
- - test/test_helper.rb
129
+ test_files: []