frontgo 0.2.0 → 0.4.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 +4 -4
- data/CHANGELOG.md +13 -3
- data/README.md +22 -1
- data/lib/frontgo/hosted_checkout.rb +27 -0
- data/lib/frontgo/version.rb +1 -1
- data/lib/frontgo.rb +2 -1
- metadata +4 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7f85cddcea75c815e53cc87149dde28a8594e7254f781188e3e5fb594bff897b
|
|
4
|
+
data.tar.gz: 0fd8c5c950e5b753eb3ce33d4620f18be49f3cac8c91112c291205602f782106
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a91d5987ff88a268ec6157bb83166cd29c02395eed18974538ebb3e8c2c1f01e8e0869a062f16c651a6b8c68e4378b9dee3aad8d733e327e9ef208ea1072f3be
|
|
7
|
+
data.tar.gz: dfa1da0242705e3640372e7345bd282aadd4c19de443b95d52377b395025370b9f5261d7961b0df772fab1f7152ce82f11998a5a8f55a18962d54e82fe77930b
|
data/CHANGELOG.md
CHANGED
|
@@ -5,7 +5,17 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
-
## [0.
|
|
8
|
+
## [0.4.0]
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- `HostedCheckout#create_hosted_checkout` to create a hosted checkout payment link (`POST connect/hosted/orders/payment-link/create`)
|
|
12
|
+
|
|
13
|
+
## [0.3.0]
|
|
14
|
+
|
|
15
|
+
### Changed
|
|
16
|
+
- Stop raising on API HTTP errors (4xx/5xx)
|
|
17
|
+
|
|
18
|
+
## [0.2.0]
|
|
9
19
|
|
|
10
20
|
### Added
|
|
11
21
|
- Support for multiple FrontPayment API environments (production and demo)
|
|
@@ -18,7 +28,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
18
28
|
- Default environment is now production (`https://apigo.frontpayment.no/api/v1`)
|
|
19
29
|
- Demo environment available at `https://demo-api.frontpayment.no/api/v1/` when `demo: true` is passed
|
|
20
30
|
|
|
21
|
-
## [0.1.1]
|
|
31
|
+
## [0.1.1]
|
|
22
32
|
|
|
23
33
|
### Added
|
|
24
34
|
- Test coverage for `Order.get_order_status_by_uuid` method
|
|
@@ -27,7 +37,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
27
37
|
- All Standard Ruby style guide violations
|
|
28
38
|
- Class naming conventions - renamed to singular form for better Ruby conventions
|
|
29
39
|
|
|
30
|
-
## [0.1.0]
|
|
40
|
+
## [0.1.0]
|
|
31
41
|
|
|
32
42
|
### Added
|
|
33
43
|
- Initial release of the Frontgo gem
|
data/README.md
CHANGED
|
@@ -27,10 +27,31 @@ client.create_session_for_one_time_payment_link({
|
|
|
27
27
|
callback: { success: "https://example.com/success", failure: "https://example.com/failure" }
|
|
28
28
|
})
|
|
29
29
|
|
|
30
|
+
# Create a hosted checkout payment link
|
|
31
|
+
client.create_hosted_checkout({
|
|
32
|
+
products: [{ name: "Product", rate: 1000, tax: 25, amount: 1250 }],
|
|
33
|
+
orderSummary: { subTotal: 1000, totalTax: 250, grandTotal: 1250 },
|
|
34
|
+
customerDetails: { type: "private", name: "John Doe", email: "john@example.com" },
|
|
35
|
+
callback: { success: "https://example.com/success", failure: "https://example.com/failure" }
|
|
36
|
+
})
|
|
37
|
+
|
|
30
38
|
# Get order status
|
|
31
39
|
client.get_order_status_by_uuid("ODR123456789")
|
|
32
|
-
```
|
|
33
40
|
|
|
41
|
+
# With all the recommended error handling
|
|
42
|
+
begin
|
|
43
|
+
response = client.get_order_status_by_uuid("ODR123")
|
|
44
|
+
if response.success?
|
|
45
|
+
# handle success
|
|
46
|
+
else
|
|
47
|
+
# handle non-2xx response
|
|
48
|
+
end
|
|
49
|
+
rescue Faraday::TimeoutError, Faraday::ConnectionFailed, Faraday::SSLError => e
|
|
50
|
+
warn "Network error: #{e.class}: #{e.message}"
|
|
51
|
+
rescue Faraday::ParsingError => e
|
|
52
|
+
warn "Parsing error: #{e.message}"
|
|
53
|
+
end
|
|
54
|
+
```
|
|
34
55
|
## Development
|
|
35
56
|
|
|
36
57
|
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.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Frontgo
|
|
4
|
+
# @see https://docs.frontpayment.no/books/fpgo-connect/page/hosted-checkout
|
|
5
|
+
module HostedCheckout
|
|
6
|
+
# @example Create a hosted checkout payment link
|
|
7
|
+
# client.create_hosted_checkout({
|
|
8
|
+
# products: [{ name: "Router", quantity: 1, rate: 4500, tax: 12, amount: 4500 }],
|
|
9
|
+
# orderSummary: { subTotal: 4017.86, totalTax: 482.14, grandTotal: 4500.00 },
|
|
10
|
+
# customerDetails: {
|
|
11
|
+
# type: "private",
|
|
12
|
+
# name: "Kari Nordmann",
|
|
13
|
+
# email: "kari@example.com"
|
|
14
|
+
# },
|
|
15
|
+
# callback: {
|
|
16
|
+
# callbackUrl: "https://example.com/callback",
|
|
17
|
+
# success: "https://example.com/success",
|
|
18
|
+
# failure: "https://example.com/failure"
|
|
19
|
+
# }
|
|
20
|
+
# })
|
|
21
|
+
# # => response.body.dig("data", "orderUuid")
|
|
22
|
+
# # => response.body.dig("data", "paymentUrl")
|
|
23
|
+
def create_hosted_checkout(params)
|
|
24
|
+
post "connect/hosted/orders/payment-link/create", params
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
data/lib/frontgo/version.rb
CHANGED
data/lib/frontgo.rb
CHANGED
|
@@ -9,6 +9,7 @@ require_relative "frontgo/customer"
|
|
|
9
9
|
require_relative "frontgo/refund"
|
|
10
10
|
require_relative "frontgo/terminal"
|
|
11
11
|
require_relative "frontgo/credit"
|
|
12
|
+
require_relative "frontgo/hosted_checkout"
|
|
12
13
|
require "faraday"
|
|
13
14
|
|
|
14
15
|
module Frontgo
|
|
@@ -23,6 +24,7 @@ module Frontgo
|
|
|
23
24
|
include Refund
|
|
24
25
|
include Terminal
|
|
25
26
|
include Credit
|
|
27
|
+
include HostedCheckout
|
|
26
28
|
|
|
27
29
|
# Initializes the client.
|
|
28
30
|
#
|
|
@@ -37,7 +39,6 @@ module Frontgo
|
|
|
37
39
|
conn.headers["Authorization"] = "Bearer #{key}"
|
|
38
40
|
conn.request :json
|
|
39
41
|
conn.response :json
|
|
40
|
-
conn.response :raise_error
|
|
41
42
|
end
|
|
42
43
|
end
|
|
43
44
|
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: frontgo
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Stanislav (Stas) Katkov
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: exe
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: faraday
|
|
@@ -42,6 +41,7 @@ files:
|
|
|
42
41
|
- lib/frontgo/connection.rb
|
|
43
42
|
- lib/frontgo/credit.rb
|
|
44
43
|
- lib/frontgo/customer.rb
|
|
44
|
+
- lib/frontgo/hosted_checkout.rb
|
|
45
45
|
- lib/frontgo/order.rb
|
|
46
46
|
- lib/frontgo/refund.rb
|
|
47
47
|
- lib/frontgo/reservation.rb
|
|
@@ -57,7 +57,6 @@ metadata:
|
|
|
57
57
|
homepage_uri: https://github.com/skatkov/frontgo
|
|
58
58
|
source_code_uri: https://github.com/skatkov/frontgo
|
|
59
59
|
changelog_uri: https://github.com/skatkov/frontgo/blob/master/CHANGELOG.md
|
|
60
|
-
post_install_message:
|
|
61
60
|
rdoc_options: []
|
|
62
61
|
require_paths:
|
|
63
62
|
- lib
|
|
@@ -72,8 +71,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
72
71
|
- !ruby/object:Gem::Version
|
|
73
72
|
version: '0'
|
|
74
73
|
requirements: []
|
|
75
|
-
rubygems_version:
|
|
76
|
-
signing_key:
|
|
74
|
+
rubygems_version: 4.0.11
|
|
77
75
|
specification_version: 4
|
|
78
76
|
summary: Ruby client for FrontPayment API
|
|
79
77
|
test_files: []
|