payson_api 0.4.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 +5 -5
  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 +70 -53
  48. data/.gitignore +0 -7
  49. data/.travis.yml +0 -5
  50. data/Gemfile +0 -2
  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 -68
  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.4.2'
4
+ VERSION = '1.0.1'
3
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: 0.4.2
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christopher Svensson
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-16 00:00:00.000000000 Z
11
+ date: 2021-05-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -16,74 +16,98 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '13'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: '13'
27
27
  - !ruby/object:Gem::Dependency
28
- name: guard-test
28
+ name: rubocop
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '1.15'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- 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'
41
55
  description: Client that enables access to the Payson payment gateway API.
42
- email:
43
- - stoffus@stoffus.com
56
+ email: stoffus@stoffus.com
44
57
  executables: []
45
58
  extensions: []
46
59
  extra_rdoc_files: []
47
60
  files:
48
- - ".gitignore"
49
- - ".travis.yml"
50
- - Gemfile
51
- - Guardfile
52
61
  - MIT-LICENSE
53
- - README.rdoc
54
- - Rakefile
62
+ - README.md
55
63
  - lib/payson_api.rb
56
- - lib/payson_api/client.rb
57
- - lib/payson_api/config.rb
58
- - lib/payson_api/envelope.rb
59
- - lib/payson_api/funding.rb
60
- - lib/payson_api/order_item.rb
61
- - lib/payson_api/receiver.rb
62
- - lib/payson_api/remote_error.rb
63
- - lib/payson_api/request/ipn.rb
64
- - lib/payson_api/request/payment.rb
65
- - lib/payson_api/request/payment_details.rb
66
- - lib/payson_api/request/payment_update.rb
67
- - lib/payson_api/response/ipn.rb
68
- - lib/payson_api/response/payment.rb
69
- - lib/payson_api/response/payment_details.rb
70
- - lib/payson_api/response/payment_update.rb
71
- - lib/payson_api/response/validate.rb
72
- - lib/payson_api/sender.rb
73
- - 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
74
105
  - lib/payson_api/version.rb
75
- - payson_api.gemspec
76
- - test/fixtures/config.yml
77
- - test/fixtures/payment_data.yml
78
- - test/integration/config_test.rb
79
- - test/integration/payment_details_test.rb
80
- - test/integration/payment_test.rb
81
- - test/test_helper.rb
82
106
  homepage: https://github.com/stoffus/payson_api
83
107
  licenses:
84
108
  - MIT
85
109
  metadata: {}
86
- post_install_message:
110
+ post_install_message:
87
111
  rdoc_options: []
88
112
  require_paths:
89
113
  - lib
@@ -91,22 +115,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
91
115
  requirements:
92
116
  - - ">="
93
117
  - !ruby/object:Gem::Version
94
- version: '0'
118
+ version: 2.6.0
95
119
  required_rubygems_version: !ruby/object:Gem::Requirement
96
120
  requirements:
97
121
  - - ">="
98
122
  - !ruby/object:Gem::Version
99
123
  version: '0'
100
124
  requirements: []
101
- rubyforge_project:
102
- rubygems_version: 2.4.5
103
- signing_key:
125
+ rubygems_version: 3.0.6
126
+ signing_key:
104
127
  specification_version: 4
105
128
  summary: Client for Payson API
106
- test_files:
107
- - test/fixtures/config.yml
108
- - test/fixtures/payment_data.yml
109
- - test/integration/config_test.rb
110
- - test/integration/payment_details_test.rb
111
- - test/integration/payment_test.rb
112
- - test/test_helper.rb
129
+ test_files: []
data/.gitignore DELETED
@@ -1,7 +0,0 @@
1
- .DS_Store
2
- *.gem
3
- .bundle
4
- Gemfile.lock
5
- pkg/*.gem
6
- .rvmrc
7
- doc