frontgo 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 9b5159138bcd6b1ffa3490df458dffab02fc32fbec40e2d1ca4d649e22750594
4
+ data.tar.gz: 8d4ae77bfd54e8fb53d98396f8232bc098570eb92644bde13bc969fc86b98fb3
5
+ SHA512:
6
+ metadata.gz: 1e7aff04db3ce6ebafbe883178d8b90b19a72f8a005ad41ac18a2fc7271f7fae4ef42516bf46d43d74b6c08cb4e2673b800cf8c4c04edbe3fa93b17772f887fa
7
+ data.tar.gz: 5bb2c17a89beb0e435624276229124dd3975375d296112095045f099fb69f0049368375bb06df5030fd6b65b08e0c961ed600f43f5a8dec1f926576928c309dc
data/.editorconfig ADDED
@@ -0,0 +1,13 @@
1
+ # top-most EditorConfig file
2
+ root = true
3
+
4
+ # Unix-style newlines with a newline ending every file
5
+ # Two spaces for indenting
6
+ [*]
7
+ end_of_line = lf
8
+ insert_final_newline = true
9
+ indent_style = space
10
+ indent_size = 2
11
+ charset = utf-8
12
+ trim_trailing_whitespace = true
13
+ max_line_length = 120
data/.standard.yml ADDED
@@ -0,0 +1,3 @@
1
+ # For available configuration options, see:
2
+ # https://github.com/standardrb/standard
3
+ ruby_version: 3.1
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2025 Stanislav (Stas) Katkov
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,46 @@
1
+ # Frontgo
2
+
3
+ Thin Ruby client for [FrontPayment API](https://docs.frontpayment.no/).
4
+
5
+ ## Installation
6
+
7
+ Add to your Gemfile:
8
+
9
+ ```ruby
10
+ gem 'frontgo'
11
+ ```
12
+
13
+ And then install
14
+ `bundle install`
15
+
16
+ ## Usage
17
+
18
+ ```ruby
19
+ client = Frontgo::Client.new('https://api.frontpayment.no', key: 'your-api-key')
20
+
21
+ # Create payment session
22
+ client.create_session_for_one_time_payment_link({
23
+ products: [{ name: "Product", rate: 1000, tax: 25, amount: 1250 }],
24
+ orderSummary: { subTotal: 1000, totalTax: 250, grandTotal: 1250 },
25
+ customerDetails: { name: "John Doe", email: "john@example.com" },
26
+ submitPayment: { via: "visa", currency: "NOK" },
27
+ callback: { success: "https://example.com/success", failure: "https://example.com/failure" }
28
+ })
29
+
30
+ # Get order status
31
+ client.get_order_status_by_uuid("ODR123456789")
32
+ ```
33
+
34
+ ## Development
35
+
36
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
37
+
38
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
39
+
40
+ ## Contributing
41
+
42
+ Bug reports and pull requests are welcome on GitHub at https://github.com/skatkov/frontgo.
43
+
44
+ ## License
45
+
46
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "minitest/test_task"
5
+
6
+ Minitest::TestTask.create
7
+
8
+ require "standard/rake"
9
+
10
+ task default: %i[test standard]
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Frontgo
4
+ module Connection
5
+ def post(uri, body, headers: {})
6
+ request :post, uri, body, headers
7
+ end
8
+
9
+ def get(uri, params = {}, headers: {})
10
+ response = @connection.get(uri, params, headers)
11
+ response.body
12
+ end
13
+
14
+ def put(uri, body = {}, headers: {})
15
+ request :put, uri, body, headers
16
+ end
17
+
18
+ def delete(uri, headers: {})
19
+ request :delete, uri, nil, headers
20
+ end
21
+
22
+ private
23
+
24
+ def request(method, url, body, headers)
25
+ response = @connection.run_request method, url, body, headers
26
+ response.body
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Frontgo
4
+ # @see https://docs.frontpayment.no/books/fpgo-connect/chapter/credit-check
5
+ module Credit
6
+ # @example Credit check for private customer
7
+ # client.credit_check_private({
8
+ # personalId: "ckFXQWJqeFlieE06ZDU3NGJlNTczMGYx",
9
+ # countryCode: "+47",
10
+ # msisdn: "46567468"
11
+ # })
12
+ # @example Credit check for private customer with minimal data
13
+ # client.credit_check_private({
14
+ # personalId: "ckFXQWJqeFlieE06ZDU3NGJlNTczMGYx"
15
+ # })
16
+ def credit_check_private(params)
17
+ post "api/v1/connect/credit/check/private", params
18
+ end
19
+
20
+ # @example Credit check for corporate customer
21
+ # client.credit_check_corporate({
22
+ # organizationId: "998379342"
23
+ # })
24
+ def credit_check_corporate(params)
25
+ post "api/v1/connect/credit/check/corporate", params
26
+ end
27
+
28
+ # @example Get credit check history list
29
+ # client.get_credit_check_list
30
+ def get_credit_check_list
31
+ get "api/v1/connect/credit/check/list"
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,76 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Frontgo
4
+ # @see https://docs.frontpayment.no/books/fpgo-connect/chapter/customer-management
5
+ module Customers
6
+ # @example Get customer details
7
+ # client.get_customer_details_by_uuid("CSRT1511414842")
8
+ def get_customer_details_by_uuid(uuid)
9
+ get "api/v1/connect/customers/details/#{uuid}"
10
+ end
11
+
12
+ # @example Update private customer
13
+ # client.update_private_customer("CSRT1511414842", {
14
+ # name: "Kari Nordmann",
15
+ # countryCode: "+47",
16
+ # msisdn: "46567468",
17
+ # email: "kari@example.com",
18
+ # preferredLanguage: "en",
19
+ # personalNumber: "12345678901",
20
+ # addresses: {
21
+ # billing: {
22
+ # street: "Luramyrveien 65",
23
+ # zip: "4313",
24
+ # city: "Sandnes",
25
+ # country: "NO"
26
+ # },
27
+ # shipping: {
28
+ # street: "Sjøhusbakken 42",
29
+ # zip: "4313",
30
+ # city: "Stavanger",
31
+ # country: "NO"
32
+ # }
33
+ # }
34
+ # })
35
+ def update_private_customer(uuid, params)
36
+ put "api/v1/connect/customers/update/private/#{uuid}", params
37
+ end
38
+
39
+ # @example Update corporate customer
40
+ # client.update_corporate_customer("CSRT1511414842", {
41
+ # name: "Acme Corporation",
42
+ # organizationId: "192933933",
43
+ # countryCode: "+47",
44
+ # msisdn: "46567468",
45
+ # email: "contact@acme.com",
46
+ # preferredLanguage: "en",
47
+ # addresses: {
48
+ # billing: {
49
+ # street: "Luramyrveien 65",
50
+ # zip: "4313",
51
+ # city: "Sandnes",
52
+ # country: "NO"
53
+ # },
54
+ # shipping: {
55
+ # street: "Sjøhusbakken 42",
56
+ # zip: "4313",
57
+ # city: "Oslo",
58
+ # country: "NO"
59
+ # }
60
+ # },
61
+ # additionalContact: {
62
+ # "0": {
63
+ # name: "John Doe",
64
+ # email: "john@acme.com",
65
+ # designation: "CEO",
66
+ # countryCode: "+47",
67
+ # msisdn: "12345678",
68
+ # note: "Primary contact"
69
+ # }
70
+ # }
71
+ # })
72
+ def update_corporate_customer(uuid, params)
73
+ put "api/v1/connect/customers/update/corporate/#{uuid}", params
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,152 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Frontgo
4
+ # @see https://docs.frontpayment.no/books/fpgo-connect/chapter/order-management
5
+ module Orders
6
+ # @example Create a one-time payment link session
7
+ # client.create_session_for_one_time_payment_link({
8
+ # products: [{ name: "Router", rate: 4500, tax: 12, amount: 4500 }],
9
+ # orderSummary: { subTotal: 4017.86, totalTax: 482.14, grandTotal: 4500.00 },
10
+ # customerDetails: { name: "Kari Nordmann", email: "kari@example.com" },
11
+ # submitPayment: { via: "visa", currency: "NOK" },
12
+ # callback: { success: "https://example.com/success", failure: "https://example.com/failure" }
13
+ # })
14
+ def create_session_for_one_time_payment_link(params)
15
+ post "api/v1/connect/orders/regular/submit", params
16
+ end
17
+
18
+ # @example Create an invoice order session
19
+ # client.create_session_for_invoice_order({
20
+ # products: [{ name: "Router", rate: 4500, tax: 12, amount: 4500 }],
21
+ # orderSummary: { subTotal: 4017.86, totalTax: 482.14, grandTotal: 4500.00 },
22
+ # customerDetails: { name: "Kari Nordmann", email: "kari@example.com" },
23
+ # submitPayment: { via: "invoice", currency: "NOK" },
24
+ # invoiceInterval: 0,
25
+ # separateInvoices: true
26
+ # })
27
+ def create_session_for_invoice_order(params)
28
+ post "api/v1/connect/orders/regular/submit", params
29
+ end
30
+
31
+ # Can be filtered by status type as query (?type=)
32
+ # @example Get all order statuses
33
+ # client.get_all_order_status
34
+ # @example Get only paid orders
35
+ # client.get_all_order_status(type: 'paid')
36
+ # @example Get only invoiced orders
37
+ # client.get_all_order_status(type: 'invoiced')
38
+ def get_all_order_status(params = {})
39
+ get "api/v1/connect/orders/status", params
40
+ end
41
+
42
+ # @example Get order status by UUID
43
+ # client.get_order_status_by_uuid("ODR347888404")
44
+ def get_order_status_by_uuid(uuid)
45
+ get "api/v1/connect/orders/status/#{uuid}"
46
+ end
47
+
48
+ # @example Get detailed order information
49
+ # client.get_order_details_by_uuid("ODR986760186")
50
+ def get_order_details_by_uuid(uuid)
51
+ get "api/v1/connect/orders/details/#{uuid}"
52
+ end
53
+
54
+ # @example Send E-Faktura invoice
55
+ # client.send_e_faktura({
56
+ # products: { "0": { name: "Hair Wash", rate: 51, tax: 0, amount: 51 } },
57
+ # customerDetails: {
58
+ # type: "private",
59
+ # name: "Kari Nordmann",
60
+ # email: "kari@example.com",
61
+ # personalNumber: "12345678901"
62
+ # },
63
+ # orderSummary: { subTotal: 51.00, totalTax: 0.00, grandTotal: 51.00 }
64
+ # })
65
+ def send_e_faktura(params)
66
+ post "api/v1/connect/orders/invoice/create/faktura", params
67
+ end
68
+
69
+ # @example Send EHF invoice for corporate customers
70
+ # client.send_ehf_invoice({
71
+ # products: { "0": { name: "Hair Wash", rate: 51, tax: 0, amount: 51 } },
72
+ # customerDetails: {
73
+ # type: "corporate",
74
+ # name: "Kari Nordmann",
75
+ # email: "kari@example.com",
76
+ # organizationId: "123456789"
77
+ # },
78
+ # orderSummary: { subTotal: 51.00, totalTax: 0.00, grandTotal: 51.00 }
79
+ # })
80
+ def send_ehf_invoice(params)
81
+ post "api/v1/connect/orders/invoice/create/ehf", params
82
+ end
83
+
84
+ # @example Cancel an order
85
+ # client.cancel_order("ODR123456789", {
86
+ # cancellationNote: "Customer requested cancellation"
87
+ # })
88
+ def cancel_order(order_uuid, params)
89
+ post "api/v1/connect/orders/cancel/#{order_uuid}", params
90
+ end
91
+
92
+ # @example Send payment link to customer
93
+ # client.send_payment_link({
94
+ # products: { "0": { name: "Hair Wash", rate: 51, tax: 0, amount: 51 } },
95
+ # customerDetails: {
96
+ # type: "private",
97
+ # name: "Kari Nordmann",
98
+ # email: "kari@example.com"
99
+ # },
100
+ # sendOrderBy: { sms: true, email: false, invoice: false },
101
+ # orderSummary: { subTotal: 51.00, totalTax: 0.00, grandTotal: 51.00 }
102
+ # })
103
+ def send_payment_link(params)
104
+ post "api/v1/connect/orders/payment-link/create", params
105
+ end
106
+
107
+ # @example Send regular invoice
108
+ # client.send_invoice({
109
+ # products: { "0": { name: "Hair Wash", rate: 51, tax: 0, amount: 51 } },
110
+ # customerDetails: {
111
+ # type: "private",
112
+ # name: "Kari Nordmann",
113
+ # email: "kari@example.com"
114
+ # },
115
+ # sendOrderBy: { sms: false, email: false, invoice: true },
116
+ # invoiceInterval: 0,
117
+ # separateInvoices: true
118
+ # })
119
+ def send_invoice(params)
120
+ post "api/v1/connect/orders/invoice/create", params
121
+ end
122
+
123
+ # @example Resend payment link to customer
124
+ # client.resend_payment_link("ODR123456789", {
125
+ # countryCode: "+47",
126
+ # msisdn: "46567468",
127
+ # email: "customer@example.com"
128
+ # })
129
+ def resend_payment_link(uuid, params)
130
+ post "api/v1/connect/orders/resend/#{uuid}", params
131
+ end
132
+
133
+ # @example Refund an order (full or partial)
134
+ # client.refund_order("ODR123456789", {
135
+ # type: "regular",
136
+ # grandTotal: 55,
137
+ # products: [
138
+ # { id: 451, amount: 30 },
139
+ # { id: 452, amount: 25 }
140
+ # ]
141
+ # })
142
+ def refund_order(uuid, params)
143
+ post "api/v1/connect/orders/refund/#{uuid}", params
144
+ end
145
+
146
+ # @example Get invoice number for an order
147
+ # client.get_invoice_number_by_uuid("ODR2005869234")
148
+ def get_invoice_number_by_uuid(uuid)
149
+ get "api/v1/connect/orders/invoice-number/#{uuid}"
150
+ end
151
+ end
152
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Frontgo
4
+ # @see https://docs.frontpayment.no/books/fpgo-connect/chapter/refund-management
5
+ module Refund
6
+ # @example Request refund approval for regular order
7
+ # client.request_refund_approval("ODR123456789", {
8
+ # type: "regular",
9
+ # grandTotal: 55,
10
+ # message: "refundRejectionForWeeklyThresholdExceed",
11
+ # products: [
12
+ # { id: 451, amount: 30 },
13
+ # { id: 452, amount: 25 }
14
+ # ]
15
+ # })
16
+ # @example Request refund approval for reservation
17
+ # client.request_refund_approval("ODR123456789", {
18
+ # type: "reservation",
19
+ # grandTotal: 100,
20
+ # message: "refundRejectionForWeeklyThresholdExceed",
21
+ # products: [
22
+ # { id: 451, amount: 60 },
23
+ # { id: 452, amount: 40 }
24
+ # ],
25
+ # source: "charged",
26
+ # reference: "CHA3852658817"
27
+ # })
28
+ def request_refund_approval(order_uuid, params)
29
+ post "api/v1/orders/refund/request/approval/#{order_uuid}", params
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,130 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Frontgo
4
+ # @see https://docs.frontpayment.no/books/fpgo-connect/chapter/reservation-management
5
+ module Reservations
6
+ # @example Submit a new reservation
7
+ # client.submit_reservation({
8
+ # customerDetails: {
9
+ # type: "private",
10
+ # name: "Kari Nordmann",
11
+ # email: "kari@example.com",
12
+ # countryCode: "+47",
13
+ # msisdn: "46567468"
14
+ # },
15
+ # products: { "0": { name: "Test", rate: 1000, tax: 0, amount: 1000 } },
16
+ # orderSummary: { subTotal: 1000.00, totalTax: 0, grandTotal: 1000.00 },
17
+ # chargeValidity: "55",
18
+ # settings: { isChargePartiallyRefundable: true }
19
+ # })
20
+ def submit_reservation(params)
21
+ post "api/v1/connect/reservations/submit", params
22
+ end
23
+
24
+ # @example Get reservation details by UUID
25
+ # client.get_reservation_details_by_uuid("RES3633019929")
26
+ def get_reservation_details_by_uuid(uuid)
27
+ get "api/v1/connect/reservations/details/#{uuid}"
28
+ end
29
+
30
+ # @example Cancel a reservation
31
+ # client.cancel_reservation("RES123456789", {
32
+ # note: "Customer requested cancellation"
33
+ # })
34
+ def cancel_reservation(uuid, params)
35
+ post "api/v1/connect/reservations/cancel/#{uuid}", params
36
+ end
37
+
38
+ # @example Capture funds from a reservation
39
+ # client.capture_reservation("RES123456789", {
40
+ # products: {
41
+ # "0": { id: 298, amount: 500 },
42
+ # "1": { id: 299, amount: 1500 }
43
+ # },
44
+ # grandTotal: 2000,
45
+ # additionalText: "Capture for services rendered"
46
+ # })
47
+ def capture_reservation(uuid, params)
48
+ post "api/v1/connect/reservations/capture/#{uuid}", params
49
+ end
50
+
51
+ # @example Charge additional amount from reservation
52
+ # client.charge_reservation("RES123456789", {
53
+ # products: {
54
+ # "0": {
55
+ # name: "Additional Service",
56
+ # rate: 1500,
57
+ # tax: 0,
58
+ # amount: 1500
59
+ # }
60
+ # },
61
+ # grandTotal: 1500,
62
+ # additionalText: "Extra service charge"
63
+ # })
64
+ def charge_reservation(uuid, params)
65
+ post "api/v1/connect/reservations/charge/#{uuid}", params
66
+ end
67
+
68
+ # @example Complete a reservation
69
+ # client.complete_reservation("RES123456789", {
70
+ # note: "Service completed successfully"
71
+ # })
72
+ def complete_reservation(uuid, params)
73
+ post "api/v1/connect/reservations/complete/#{uuid}", params
74
+ end
75
+
76
+ # @example Resend reservation payment link
77
+ # client.resend_reservation("RES123456789", {
78
+ # countryCode: "+47",
79
+ # msisdn: "46567468",
80
+ # email: "customer@example.com"
81
+ # })
82
+ def resend_reservation(uuid, params)
83
+ post "api/v1/connect/reservations/resend/#{uuid}", params
84
+ end
85
+
86
+ # @example Refund a reservation (from captured or charged amounts)
87
+ # client.refund_reservation("RES123456789", {
88
+ # type: "reservation",
89
+ # grandTotal: 500,
90
+ # products: [
91
+ # { id: 451, amount: 300 },
92
+ # { id: 452, amount: 200 }
93
+ # ],
94
+ # source: "charged",
95
+ # reference: "CHA3852658817"
96
+ # })
97
+ def refund_reservation(uuid, params)
98
+ post "api/v1/connect/reservations/refund/#{uuid}", params
99
+ end
100
+
101
+ # @example Create reservation session for checkout
102
+ # client.create_session_for_reservation({
103
+ # customerDetails: {
104
+ # type: "private",
105
+ # name: "Kari Nordmann",
106
+ # email: "kari@example.com",
107
+ # countryCode: "+47",
108
+ # msisdn: "46567468"
109
+ # },
110
+ # products: { "0": { name: "Test", rate: 1000, tax: 0, amount: 1000 } },
111
+ # submitPayment: { via: "visa" },
112
+ # callback: {
113
+ # success: "https://example.com/success",
114
+ # failure: "https://example.com/failure"
115
+ # },
116
+ # settings: { isChargePartiallyRefundable: true }
117
+ # })
118
+ def create_session_for_reservation(params)
119
+ post "api/v1/connect/reservations/create", params
120
+ end
121
+
122
+ # @example Get reservation history by time frame
123
+ # client.get_reservation_history_by_time_frame("1706674723", "1706761123")
124
+ # @example Get last 24 hours (when no timestamps provided, defaults to last 24 hours)
125
+ # client.get_reservation_history_by_time_frame("", "")
126
+ def get_reservation_history_by_time_frame(start_timestamp, end_timestamp)
127
+ get "api/v1/connect/reservations/history/#{start_timestamp}/#{end_timestamp}"
128
+ end
129
+ end
130
+ end
@@ -0,0 +1,88 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Frontgo
4
+ # @see https://docs.frontpayment.no/books/fpgo-connect/chapter/subscription-management
5
+ module Subscription
6
+ # @example Create a new subscription
7
+ # client.create_subscription({
8
+ # products: { "0": { name: "Monthly Service", rate: 2000, tax: 0, amount: 2000 } },
9
+ # billingFrequency: "month",
10
+ # numberOfRepeats: 12,
11
+ # customerDetails: { name: "John Doe", email: "john@example.com" }
12
+ # })
13
+ def create_subscription(params)
14
+ post "api/v1/connect/subscription/submit", params
15
+ end
16
+
17
+ # @example Create subscription session for checkout
18
+ # client.create_session_for_subscription_payment({
19
+ # products: { "0": { name: "Premium Plan", rate: 1500, tax: 0, amount: 1500 } },
20
+ # billingFrequency: "month",
21
+ # submitPayment: { via: "visa" },
22
+ # callback: { success: "https://example.com/success", failure: "https://example.com/failure" }
23
+ # })
24
+ def create_session_for_subscription_payment(params)
25
+ post "api/v1/connect/subscription/create", params
26
+ end
27
+
28
+ # @example Get all subscriptions
29
+ # client.get_subscription_list
30
+ # @example Get ongoing subscriptions with pagination
31
+ # client.get_subscription_list('ongoing', { page: 2, customerName: 'John' })
32
+ # @example Filter by phone and date range
33
+ # client.get_subscription_list(nil, { phone: '+47123456789', startDate: '2023-01-01', endDate: '2023-12-31' })
34
+ def get_subscription_list(status = nil, params = {})
35
+ endpoint = status ? "api/v1/connect/subscriptions/list/#{status}" : "api/v1/connect/subscriptions/list"
36
+ get endpoint, params
37
+ end
38
+
39
+ # @example Get all failed payments
40
+ # client.get_failed_payment_list
41
+ # @example Get invoiced failed payments with pagination
42
+ # client.get_failed_payment_list('invoiced', { page: 1, phone: '+47123456789' })
43
+ # @example Filter by subscription UUID
44
+ # client.get_failed_payment_list(nil, { subscriptionUuid: 'SUB123456789' })
45
+ def get_failed_payment_list(status = nil, params = {})
46
+ endpoint = status ? "api/v1/connect/subscriptions/failed/list/#{status}" : "api/v1/connect/subscriptions/failed/list"
47
+ get endpoint, params
48
+ end
49
+
50
+ # @example Get subscription details
51
+ # client.get_subscription_details_by_uuid('SUB123456789')
52
+ def get_subscription_details_by_uuid(uuid)
53
+ get "api/v1/connect/subscriptions/details/#{uuid}"
54
+ end
55
+
56
+ # @example Get failed payment details
57
+ # client.get_failed_payment_details('ODR123456789')
58
+ def get_failed_payment_details(order_uuid)
59
+ get "api/v1/connect/subscriptions/failed/details/#{order_uuid}"
60
+ end
61
+
62
+ # @example Resend subscription payment link
63
+ # client.resend_subscription('SUB123456789', {
64
+ # orderUuid: 'ODR123456789',
65
+ # countryCode: '+47',
66
+ # msisdn: '46567468',
67
+ # email: 'customer@example.com'
68
+ # })
69
+ def resend_subscription(uuid, params)
70
+ post "api/v1/connect/subscriptions/resend/#{uuid}", params
71
+ end
72
+
73
+ # @example Cancel subscription
74
+ # client.cancel_subscription('SUB123456789', { note: 'Customer requested cancellation' })
75
+ def cancel_subscription(uuid, params)
76
+ post "api/v1/connect/subscriptions/cancel/#{uuid}", params
77
+ end
78
+
79
+ # @example Refund specific subscription cycles
80
+ # client.refund_subscription_cycle('SUB123456789', {
81
+ # cycles: ['Cycle 1', 'Cycle 2'],
82
+ # amount: 200.00
83
+ # })
84
+ def refund_subscription_cycle(uuid, params)
85
+ post "api/v1/connect/subscriptions/cycles/refund/#{uuid}", params
86
+ end
87
+ end
88
+ end
@@ -0,0 +1,83 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Frontgo
4
+ # @see https://docs.frontpayment.no/books/fpgo-connect/chapter/terminal-management
5
+ module Terminal
6
+ # @example Get terminal lists for organization
7
+ # client.get_terminal_lists("ORG2074299506")
8
+ def get_terminal_lists(organization_uuid)
9
+ get "api/v1/connect/terminal/lists/#{organization_uuid}"
10
+ end
11
+
12
+ # @example Create terminal order with callback
13
+ # client.create_terminal_order({
14
+ # products: { "0": { name: "Hair Wash", productId: "VFDDF", quantity: 1, rate: 42, tax: 0, amount: 42 } },
15
+ # orderSummary: { subTotal: 42.00, totalTax: 0.00, totalDiscount: 0.00, grandTotal: 42.00 },
16
+ # orderDate: "07 Apr, 2024",
17
+ # terminalUuid: "TRML1216693970",
18
+ # receiptPrint: false,
19
+ # sendOrderBy: { sms: false, email: true },
20
+ # customerDetails: {
21
+ # type: "private",
22
+ # name: "Kari Nordmann",
23
+ # email: "kari@example.com",
24
+ # countryCode: "+47",
25
+ # msisdn: "46567468",
26
+ # preferredLanguage: "en",
27
+ # address: { street: "Luramyrveien 65", zip: "4313", city: "Sandnes", country: "NO" }
28
+ # },
29
+ # callbackUrl: "https://example-callback.com"
30
+ # })
31
+ def create_terminal_order(params)
32
+ post "api/v1/connect/terminal/orders/create", params
33
+ end
34
+
35
+ # @example Cancel terminal order payment
36
+ # client.cancel_terminal_order("ODR123456789", { type: "payment" })
37
+ def cancel_terminal_order(order_uuid, params)
38
+ post "api/v1/connect/terminal/orders/cancel/#{order_uuid}", params
39
+ end
40
+
41
+ # @example Resend terminal order to terminal
42
+ # client.resend_terminal_order("ODR123456789")
43
+ def resend_terminal_order(order_uuid)
44
+ post "api/v1/connect/terminal/orders/resend/#{order_uuid}", {}
45
+ end
46
+
47
+ # @example Check payment status
48
+ # client.get_payment_status("ODR123456789")
49
+ def get_payment_status(order_uuid)
50
+ get "api/v1/connect/terminal/orders/payment-status/#{order_uuid}"
51
+ end
52
+
53
+ # @example Refund terminal order
54
+ # client.refund_terminal_order("ODR123456789", {
55
+ # type: "regular",
56
+ # grandTotal: 42,
57
+ # products: [{ id: 12, amount: 42 }],
58
+ # isReversal: false
59
+ # })
60
+ # @example Reverse terminal payment
61
+ # client.refund_terminal_order("ODR123456789", {
62
+ # type: "regular",
63
+ # grandTotal: 42,
64
+ # products: [{ id: 12, amount: 42 }],
65
+ # isReversal: true
66
+ # })
67
+ def refund_terminal_order(order_uuid, params)
68
+ post "api/v1/connect/terminal/orders/refund/#{order_uuid}", params
69
+ end
70
+
71
+ # @example Check refund status
72
+ # client.get_refund_status("ODR123456789")
73
+ def get_refund_status(order_uuid)
74
+ get "api/v1/connect/terminal/orders/refund-status/#{order_uuid}"
75
+ end
76
+
77
+ # @example Cancel refund request
78
+ # client.cancel_refund_request("ODR123456789", { type: "refund" })
79
+ def cancel_refund_request(order_uuid, params)
80
+ post "api/v1/connect/terminal/orders/cancel/#{order_uuid}", params
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Frontgo
4
+ VERSION = "0.1.0"
5
+ end
data/lib/frontgo.rb ADDED
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "frontgo/version"
4
+ require_relative "frontgo/connection"
5
+ require_relative "frontgo/orders"
6
+ require_relative "frontgo/reservations"
7
+ require_relative "frontgo/subscription"
8
+ require_relative "frontgo/customers"
9
+ require_relative "frontgo/refund"
10
+ require_relative "frontgo/terminal"
11
+ require_relative "frontgo/credit"
12
+ require 'faraday'
13
+
14
+
15
+ module Frontgo
16
+ class Error < StandardError; end
17
+
18
+ class Client
19
+ include Connection
20
+ include Orders
21
+ include Reservations
22
+ include Subscription
23
+ include Customers
24
+ include Refund
25
+ include Terminal
26
+ include Credit
27
+
28
+ def initialize(base_url, key:)
29
+ @connection = Faraday.new(base_url) do |conn|
30
+ conn.headers['Authorization'] = "Bearer #{key}"
31
+ conn.request :json
32
+ conn.response :json
33
+ conn.response :raise_error
34
+ end
35
+ end
36
+ end
37
+ end
data/sig/frontgo.rbs ADDED
@@ -0,0 +1,4 @@
1
+ module Frontgo
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,77 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: frontgo
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Stanislav (Stas) Katkov
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2025-07-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description: A Ruby wrapper for the FrontPayment API supporting orders, customers,
28
+ subscriptions, refunds, and terminal operations.
29
+ email:
30
+ - contact@skatkov.com
31
+ executables: []
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - ".editorconfig"
36
+ - ".standard.yml"
37
+ - LICENSE.txt
38
+ - README.md
39
+ - Rakefile
40
+ - lib/frontgo.rb
41
+ - lib/frontgo/connection.rb
42
+ - lib/frontgo/credit.rb
43
+ - lib/frontgo/customers.rb
44
+ - lib/frontgo/orders.rb
45
+ - lib/frontgo/refund.rb
46
+ - lib/frontgo/reservations.rb
47
+ - lib/frontgo/subscription.rb
48
+ - lib/frontgo/terminal.rb
49
+ - lib/frontgo/version.rb
50
+ - sig/frontgo.rbs
51
+ homepage: https://github.com/skatkov/frontgo
52
+ licenses:
53
+ - MIT
54
+ metadata:
55
+ allowed_push_host: https://rubygems.org
56
+ homepage_uri: https://github.com/skatkov/frontgo
57
+ source_code_uri: https://github.com/skatkov/frontgo
58
+ post_install_message:
59
+ rdoc_options: []
60
+ require_paths:
61
+ - lib
62
+ required_ruby_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: 3.1.0
67
+ required_rubygems_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ requirements: []
73
+ rubygems_version: 3.4.19
74
+ signing_key:
75
+ specification_version: 4
76
+ summary: Ruby client for FrontPayment API
77
+ test_files: []