payrex-ruby 0.2.5 → 1.0.1
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/lib/entities/billing_statement.rb +47 -0
- data/lib/entities/billing_statement_line_item.rb +27 -0
- data/lib/entities/checkout_session.rb +20 -22
- data/lib/entities/customer.rb +31 -0
- data/lib/entities/deleted.rb +15 -0
- data/lib/http_client.rb +1 -1
- data/lib/payrex-ruby.rb +7 -2
- data/lib/services/base_service.rb +2 -0
- data/lib/services/billing_statement_line_items_service.rb +43 -0
- data/lib/services/billing_statements_service.rb +85 -0
- data/lib/services/checkout_sessions_service.rb +1 -1
- data/lib/services/customers_service.rb +53 -0
- data/lib/services/webhooks_service.rb +2 -2
- metadata +9 -5
- data/lib/entities/merchant.rb +0 -19
- data/lib/entities/payment_method.rb +0 -23
- data/lib/services/payment_methods_service.rb +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f8f290d52a9d16dfe4cefad802d3e71d2622c9166bf020c4ba7754009dac29d
|
4
|
+
data.tar.gz: 845b87b03f2ee34a3a9e110b344f623beaa5f988cdfa16e102c2b919bd5d2137
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 58d505cd6d6841bb82158c69c62dd8d5036048e99e15e5e2ff1ecfa74dd68f692bb119fb69efb98b52aa8288cde41502a0b693823f657bdfe29910f11ac7076d
|
7
|
+
data.tar.gz: fe924608eb05c145f379bd82a02c2ef7ea063e3c4285b6d6c25bb50f8b9f5f376dc13421fd39e76c02512c70d886dc0f99d2dc1949b94126b9c63bfe6f6a3fda
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Payrex
|
2
|
+
module Entities
|
3
|
+
class BillingStatement
|
4
|
+
attr_reader :id,
|
5
|
+
:amount,
|
6
|
+
:currency,
|
7
|
+
:customer_id,
|
8
|
+
:description,
|
9
|
+
:due_at,
|
10
|
+
:finalized_at,
|
11
|
+
:billing_statement_number,
|
12
|
+
:billing_statement_url,
|
13
|
+
:line_items,
|
14
|
+
:livemode,
|
15
|
+
:metadata,
|
16
|
+
:payment_intent,
|
17
|
+
:status,
|
18
|
+
:payment_settings,
|
19
|
+
:customer,
|
20
|
+
:created_at,
|
21
|
+
:updated_at
|
22
|
+
|
23
|
+
def initialize(api_resource)
|
24
|
+
data = api_resource.data
|
25
|
+
|
26
|
+
@id = data["id"]
|
27
|
+
@amount = data["amount"]
|
28
|
+
@currency = data["currency"]
|
29
|
+
@customer_id = data["customer_id"]
|
30
|
+
@description = data["description"]
|
31
|
+
@due_at = data["due_at"]
|
32
|
+
@finalized_at = data["finalized_at"]
|
33
|
+
@billing_statement_number = data["billing_statement_number"]
|
34
|
+
@billing_statement_url = data["billing_statement_url"]
|
35
|
+
@line_items = data["line_items"]
|
36
|
+
@livemode = data["livemode"]
|
37
|
+
@metadata = data["metadata"]
|
38
|
+
@payment_intent = data["payment_intent"]
|
39
|
+
@status = data["status"]
|
40
|
+
@payment_settings = data["payment_settings"]
|
41
|
+
@customer = data["customer"]
|
42
|
+
@created_at = data["created_at"]
|
43
|
+
@updated_at = data["updated_at"]
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Payrex
|
2
|
+
module Entities
|
3
|
+
class BillingStatementLineItem
|
4
|
+
attr_reader :id,
|
5
|
+
:unit_price,
|
6
|
+
:quantity,
|
7
|
+
:billing_statement_id,
|
8
|
+
:description,
|
9
|
+
:livemode,
|
10
|
+
:created_at,
|
11
|
+
:updated_at
|
12
|
+
|
13
|
+
def initialize(api_resource)
|
14
|
+
data = api_resource.data
|
15
|
+
|
16
|
+
@id = data["id"]
|
17
|
+
@unit_price = data["unit_price"]
|
18
|
+
@quantity = data["quantity"]
|
19
|
+
@billing_statement_id = data["billing_statement_id"]
|
20
|
+
@description = data["description"]
|
21
|
+
@livemode = data["livemode"]
|
22
|
+
@created_at = data["created_at"]
|
23
|
+
@updated_at = data["updated_at"]
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -21,28 +21,26 @@ module Payrex
|
|
21
21
|
:updated_at
|
22
22
|
|
23
23
|
def initialize(api_resource)
|
24
|
-
|
25
|
-
|
26
|
-
@
|
27
|
-
@
|
28
|
-
@
|
29
|
-
@
|
30
|
-
@
|
31
|
-
@
|
32
|
-
@
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
@
|
38
|
-
@
|
39
|
-
@
|
40
|
-
@
|
41
|
-
@
|
42
|
-
@
|
43
|
-
@
|
44
|
-
@created_at = api_resource.data["created_at"]
|
45
|
-
@updated_at = api_resource.data["updated_at"]
|
24
|
+
data = api_resource.data
|
25
|
+
|
26
|
+
@id = data["id"]
|
27
|
+
@customer_reference_id = data["customer_reference_id"]
|
28
|
+
@client_secret = data["client_secret"]
|
29
|
+
@status = data["status"]
|
30
|
+
@currency = data["currency"]
|
31
|
+
@line_items = data["line_items"]
|
32
|
+
@livemode = data["livemode"]
|
33
|
+
@url = data["url"]
|
34
|
+
@payment_intent = data["payment_intent"]
|
35
|
+
@metadata = data["metadata"]
|
36
|
+
@success_url = data["success_url"]
|
37
|
+
@cancel_url = data["cancel_url"]
|
38
|
+
@payment_methods = data["payment_methods"]
|
39
|
+
@description = data["description"]
|
40
|
+
@submit_type = data["submit_type"]
|
41
|
+
@expires_at = data["expires_at"]
|
42
|
+
@created_at = data["created_at"]
|
43
|
+
@updated_at = data["updated_at"]
|
46
44
|
end
|
47
45
|
end
|
48
46
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Payrex
|
2
|
+
module Entities
|
3
|
+
class Customer
|
4
|
+
attr_reader :id,
|
5
|
+
:billing_statement_prefix,
|
6
|
+
:currency,
|
7
|
+
:email,
|
8
|
+
:livemode,
|
9
|
+
:name,
|
10
|
+
:metadata,
|
11
|
+
:next_billing_statement_sequence_number,
|
12
|
+
:created_at,
|
13
|
+
:updated_at
|
14
|
+
|
15
|
+
def initialize(api_resource)
|
16
|
+
data = api_resource.data
|
17
|
+
|
18
|
+
@id = data["id"]
|
19
|
+
@billing_statement_prefix = data["billing_statement_prefix"]
|
20
|
+
@currency = data["currency"]
|
21
|
+
@email = data["email"]
|
22
|
+
@livemode = data["livemode"]
|
23
|
+
@name = data["name"]
|
24
|
+
@metadata = data["metadata"]
|
25
|
+
@next_billing_statement_sequence_number = data["next_billing_statement_sequence_number"]
|
26
|
+
@created_at = data["created_at"]
|
27
|
+
@updated_at = data["updated_at"]
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/http_client.rb
CHANGED
@@ -12,7 +12,7 @@ module Payrex
|
|
12
12
|
|
13
13
|
response = Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == "https") { |http| http.request(request) }
|
14
14
|
|
15
|
-
|
15
|
+
return nil if response.body.nil?
|
16
16
|
|
17
17
|
handle_error(response) if failed?(response)
|
18
18
|
|
data/lib/payrex-ruby.rb
CHANGED
@@ -10,9 +10,12 @@ require_relative "http_client"
|
|
10
10
|
require_relative "payrex_error"
|
11
11
|
require_relative "entities/checkout_session"
|
12
12
|
require_relative "entities/event"
|
13
|
+
require_relative "entities/deleted"
|
14
|
+
require_relative "entities/customer"
|
15
|
+
require_relative "entities/billing_statement"
|
16
|
+
require_relative "entities/billing_statement_line_item"
|
13
17
|
require_relative "entities/listing"
|
14
18
|
require_relative "entities/payment_intent"
|
15
|
-
require_relative "entities/payment_method"
|
16
19
|
require_relative "entities/refund"
|
17
20
|
require_relative "entities/webhook"
|
18
21
|
require_relative "errors/base_error"
|
@@ -23,8 +26,10 @@ require_relative "errors/signature_invalid_error"
|
|
23
26
|
require_relative "errors/value_unexpected_error"
|
24
27
|
require_relative "services/base_service"
|
25
28
|
require_relative "services/checkout_sessions_service"
|
29
|
+
require_relative "services/customers_service"
|
30
|
+
require_relative "services/billing_statements_service"
|
31
|
+
require_relative "services/billing_statement_line_items_service"
|
26
32
|
require_relative "services/payment_intents_service"
|
27
|
-
require_relative "services/payment_methods_service"
|
28
33
|
require_relative "services/refunds_service"
|
29
34
|
require_relative "services/webhooks_service"
|
30
35
|
require_relative "services/service_factory"
|
@@ -18,6 +18,8 @@ module Payrex
|
|
18
18
|
data = api_resource.data["data"].map { |data| object.new(Payrex::ApiResource.new(data)) }
|
19
19
|
|
20
20
|
Payrex::Entities::Listing.new(data: data, has_more: api_resource.data["has_more"])
|
21
|
+
elsif object.nil?
|
22
|
+
nil
|
21
23
|
else
|
22
24
|
object.new(api_resource)
|
23
25
|
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Payrex
|
2
|
+
module Services
|
3
|
+
class BillingStatementLineItemsService < BaseService
|
4
|
+
PATH = "billing_statement_line_items"
|
5
|
+
|
6
|
+
def create(payload)
|
7
|
+
request(
|
8
|
+
method: :post,
|
9
|
+
object: Payrex::Entities::BillingStatementLineItem,
|
10
|
+
path: PATH,
|
11
|
+
payload: payload
|
12
|
+
)
|
13
|
+
end
|
14
|
+
|
15
|
+
def retrieve(id)
|
16
|
+
request(
|
17
|
+
method: :get,
|
18
|
+
object: Payrex::Entities::BillingStatementLineItem,
|
19
|
+
path: "#{PATH}/#{id}",
|
20
|
+
payload: {}
|
21
|
+
)
|
22
|
+
end
|
23
|
+
|
24
|
+
def update(id, payload)
|
25
|
+
request(
|
26
|
+
method: :put,
|
27
|
+
object: Payrex::Entities::BillingStatementLineItem,
|
28
|
+
path: "#{PATH}/#{id}",
|
29
|
+
payload: payload
|
30
|
+
)
|
31
|
+
end
|
32
|
+
|
33
|
+
def delete(id)
|
34
|
+
request(
|
35
|
+
method: :delete,
|
36
|
+
object: Payrex::Entities::Deleted,
|
37
|
+
path: "#{PATH}/#{id}",
|
38
|
+
payload: {}
|
39
|
+
)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
module Payrex
|
2
|
+
module Services
|
3
|
+
class BillingStatementsService < BaseService
|
4
|
+
PATH = "billing_statements"
|
5
|
+
|
6
|
+
def create(payload)
|
7
|
+
request(
|
8
|
+
method: :post,
|
9
|
+
object: Payrex::Entities::BillingStatement,
|
10
|
+
path: PATH,
|
11
|
+
payload: payload
|
12
|
+
)
|
13
|
+
end
|
14
|
+
|
15
|
+
def retrieve(id)
|
16
|
+
request(
|
17
|
+
method: :get,
|
18
|
+
object: Payrex::Entities::BillingStatement,
|
19
|
+
path: "#{PATH}/#{id}",
|
20
|
+
payload: {}
|
21
|
+
)
|
22
|
+
end
|
23
|
+
|
24
|
+
def list(payload = {})
|
25
|
+
request(
|
26
|
+
is_list: true,
|
27
|
+
method: :get,
|
28
|
+
object: Payrex::Entities::BillingStatement,
|
29
|
+
path: PATH,
|
30
|
+
payload: payload
|
31
|
+
)
|
32
|
+
end
|
33
|
+
|
34
|
+
def update(id, payload)
|
35
|
+
request(
|
36
|
+
method: :put,
|
37
|
+
object: Payrex::Entities::BillingStatement,
|
38
|
+
path: "#{PATH}/#{id}",
|
39
|
+
payload: payload
|
40
|
+
)
|
41
|
+
end
|
42
|
+
|
43
|
+
def delete(id)
|
44
|
+
request(
|
45
|
+
method: :delete,
|
46
|
+
object: Payrex::Entities::Deleted,
|
47
|
+
path: "#{PATH}/#{id}",
|
48
|
+
payload: {}
|
49
|
+
)
|
50
|
+
end
|
51
|
+
|
52
|
+
def finalize(id)
|
53
|
+
request(
|
54
|
+
method: :post,
|
55
|
+
object: Payrex::Entities::BillingStatement,
|
56
|
+
path: "#{PATH}/#{id}/finalize"
|
57
|
+
)
|
58
|
+
end
|
59
|
+
|
60
|
+
def send(id)
|
61
|
+
request(
|
62
|
+
method: :post,
|
63
|
+
object: nil,
|
64
|
+
path: "#{PATH}/#{id}/send"
|
65
|
+
)
|
66
|
+
end
|
67
|
+
|
68
|
+
def void(id)
|
69
|
+
request(
|
70
|
+
method: :post,
|
71
|
+
object: Payrex::Entities::BillingStatement,
|
72
|
+
path: "#{PATH}/#{id}/void"
|
73
|
+
)
|
74
|
+
end
|
75
|
+
|
76
|
+
def mark_uncollectible(id)
|
77
|
+
request(
|
78
|
+
method: :post,
|
79
|
+
object: Payrex::Entities::BillingStatement,
|
80
|
+
path: "#{PATH}/#{id}/mark_uncollectible"
|
81
|
+
)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module Payrex
|
2
|
+
module Services
|
3
|
+
class CustomersService < BaseService
|
4
|
+
PATH = "customers"
|
5
|
+
|
6
|
+
def create(payload)
|
7
|
+
request(
|
8
|
+
method: :post,
|
9
|
+
object: Payrex::Entities::Customer,
|
10
|
+
path: PATH,
|
11
|
+
payload: payload
|
12
|
+
)
|
13
|
+
end
|
14
|
+
|
15
|
+
def retrieve(id)
|
16
|
+
request(
|
17
|
+
method: :get,
|
18
|
+
object: Payrex::Entities::Customer,
|
19
|
+
path: "#{PATH}/#{id}",
|
20
|
+
payload: {}
|
21
|
+
)
|
22
|
+
end
|
23
|
+
|
24
|
+
def list(payload = {})
|
25
|
+
request(
|
26
|
+
is_list: true,
|
27
|
+
method: :get,
|
28
|
+
object: Payrex::Entities::Customer,
|
29
|
+
path: PATH,
|
30
|
+
payload: payload
|
31
|
+
)
|
32
|
+
end
|
33
|
+
|
34
|
+
def update(id, payload)
|
35
|
+
request(
|
36
|
+
method: :put,
|
37
|
+
object: Payrex::Entities::Customer,
|
38
|
+
path: "#{PATH}/#{id}",
|
39
|
+
payload: payload
|
40
|
+
)
|
41
|
+
end
|
42
|
+
|
43
|
+
def delete(id)
|
44
|
+
request(
|
45
|
+
method: :delete,
|
46
|
+
object: Payrex::Entities::Deleted,
|
47
|
+
path: "#{PATH}/#{id}",
|
48
|
+
payload: {}
|
49
|
+
)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -47,7 +47,7 @@ module Payrex
|
|
47
47
|
)
|
48
48
|
end
|
49
49
|
|
50
|
-
def list(payload)
|
50
|
+
def list(payload = {})
|
51
51
|
request(
|
52
52
|
is_list: true,
|
53
53
|
method: :get,
|
@@ -87,7 +87,7 @@ module Payrex
|
|
87
87
|
def delete(id)
|
88
88
|
request(
|
89
89
|
method: :delete,
|
90
|
-
object: Payrex::Entities::
|
90
|
+
object: Payrex::Entities::Deleted,
|
91
91
|
path: "#{PATH}/#{id}",
|
92
92
|
payload: {}
|
93
93
|
)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: payrex-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- PayRex
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-10-02 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: PayRex Ruby Library
|
14
14
|
email: support@payrexhq.com
|
@@ -19,12 +19,14 @@ files:
|
|
19
19
|
- lib/api_resource.rb
|
20
20
|
- lib/client.rb
|
21
21
|
- lib/config.rb
|
22
|
+
- lib/entities/billing_statement.rb
|
23
|
+
- lib/entities/billing_statement_line_item.rb
|
22
24
|
- lib/entities/checkout_session.rb
|
25
|
+
- lib/entities/customer.rb
|
26
|
+
- lib/entities/deleted.rb
|
23
27
|
- lib/entities/event.rb
|
24
28
|
- lib/entities/listing.rb
|
25
|
-
- lib/entities/merchant.rb
|
26
29
|
- lib/entities/payment_intent.rb
|
27
|
-
- lib/entities/payment_method.rb
|
28
30
|
- lib/entities/refund.rb
|
29
31
|
- lib/entities/webhook.rb
|
30
32
|
- lib/errors/authentication_invalid_error.rb
|
@@ -37,9 +39,11 @@ files:
|
|
37
39
|
- lib/payrex-ruby.rb
|
38
40
|
- lib/payrex_error.rb
|
39
41
|
- lib/services/base_service.rb
|
42
|
+
- lib/services/billing_statement_line_items_service.rb
|
43
|
+
- lib/services/billing_statements_service.rb
|
40
44
|
- lib/services/checkout_sessions_service.rb
|
45
|
+
- lib/services/customers_service.rb
|
41
46
|
- lib/services/payment_intents_service.rb
|
42
|
-
- lib/services/payment_methods_service.rb
|
43
47
|
- lib/services/refunds_service.rb
|
44
48
|
- lib/services/service_factory.rb
|
45
49
|
- lib/services/webhooks_service.rb
|
data/lib/entities/merchant.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
module Payrex
|
2
|
-
module Entities
|
3
|
-
class Merchant
|
4
|
-
attr_reader :id,
|
5
|
-
:connection_type,
|
6
|
-
:livemode,
|
7
|
-
:created_at,
|
8
|
-
:updated_at
|
9
|
-
|
10
|
-
def initialize(api_resource)
|
11
|
-
@id = api_resource.data["id"]
|
12
|
-
@connection_type = api_resource.data["connection_type"]
|
13
|
-
@livemode = api_resource.data["livemode"]
|
14
|
-
@created_at = api_resource.data["created_at"]
|
15
|
-
@updated_at = api_resource.data["updated_at"]
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
module Payrex
|
2
|
-
module Entities
|
3
|
-
class PaymentMethod
|
4
|
-
attr_reader :id,
|
5
|
-
:type,
|
6
|
-
:billing_details,
|
7
|
-
:livemode,
|
8
|
-
:metadata,
|
9
|
-
:created_at,
|
10
|
-
:updated_at
|
11
|
-
|
12
|
-
def initialize(api_resource)
|
13
|
-
@id = api_resource.data["id"]
|
14
|
-
@type = api_resource.data["type"]
|
15
|
-
@billing_details = api_resource.data["billing_details"]
|
16
|
-
@livemode = api_resource.data["livemode"]
|
17
|
-
@metadata = api_resource.data["metadata"]
|
18
|
-
@created_at = api_resource.data["created_at"]
|
19
|
-
@updated_at = api_resource.data["updated_at"]
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
module Payrex
|
2
|
-
module Services
|
3
|
-
class PaymentMethodsService < BaseService
|
4
|
-
PATH = "payment_methods"
|
5
|
-
|
6
|
-
def create(payload)
|
7
|
-
request(
|
8
|
-
method: :post,
|
9
|
-
object: Payrex::Entities::PaymentMethod,
|
10
|
-
path: PATH,
|
11
|
-
payload: payload
|
12
|
-
)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|