cash_app_pay 0.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 +7 -0
- data/lib/cash_app_pay/api_operations/create.rb +16 -0
- data/lib/cash_app_pay/api_operations/delete.rb +27 -0
- data/lib/cash_app_pay/api_operations/list.rb +17 -0
- data/lib/cash_app_pay/api_operations/request.rb +45 -0
- data/lib/cash_app_pay/api_operations/retrieve.rb +24 -0
- data/lib/cash_app_pay/api_operations/save.rb +16 -0
- data/lib/cash_app_pay/api_operations/update.rb +31 -0
- data/lib/cash_app_pay/api_operations/upsert.rb +22 -0
- data/lib/cash_app_pay/api_resource.rb +58 -0
- data/lib/cash_app_pay/cash_app_pay_client.rb +117 -0
- data/lib/cash_app_pay/cash_app_pay_configuration.rb +19 -0
- data/lib/cash_app_pay/cash_app_pay_object.rb +77 -0
- data/lib/cash_app_pay/cash_app_pay_response.rb +17 -0
- data/lib/cash_app_pay/connection_manager.rb +79 -0
- data/lib/cash_app_pay/endpoint.rb +8 -0
- data/lib/cash_app_pay/error_object.rb +6 -0
- data/lib/cash_app_pay/errors.rb +45 -0
- data/lib/cash_app_pay/helpers/symbolize.rb +31 -0
- data/lib/cash_app_pay/list_object.rb +64 -0
- data/lib/cash_app_pay/persistent_http_client.rb +48 -0
- data/lib/cash_app_pay/resources/api_key.rb +19 -0
- data/lib/cash_app_pay/resources/brand.rb +20 -0
- data/lib/cash_app_pay/resources/customer.rb +56 -0
- data/lib/cash_app_pay/resources/customer_request.rb +18 -0
- data/lib/cash_app_pay/resources/dispute.rb +142 -0
- data/lib/cash_app_pay/resources/dispute_evidence.rb +9 -0
- data/lib/cash_app_pay/resources/fee_plan.rb +16 -0
- data/lib/cash_app_pay/resources/grant.rb +13 -0
- data/lib/cash_app_pay/resources/merchant.rb +20 -0
- data/lib/cash_app_pay/resources/payment.rb +63 -0
- data/lib/cash_app_pay/resources/refund.rb +62 -0
- data/lib/cash_app_pay/resources/webhook.rb +20 -0
- data/lib/cash_app_pay/resources/webhook_event.rb +15 -0
- data/lib/cash_app_pay/version.rb +5 -0
- data/lib/cash_app_pay.rb +69 -0
- metadata +85 -0
@@ -0,0 +1,64 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CashAppPay
|
4
|
+
# TODO: - I can make this a sublcass of CashAppPay::APIResource
|
5
|
+
class ListObject
|
6
|
+
include Enumerable
|
7
|
+
|
8
|
+
attr_accessor :data, :cursor, :opts, :klass, :filters
|
9
|
+
|
10
|
+
def self.empty_list(klass, opts = {}, cursor = nil, filters = {})
|
11
|
+
ListObject.new(klass, [], cursor, opts, filters)
|
12
|
+
end
|
13
|
+
|
14
|
+
def initialize(klass, data, cursor, opts, filters)
|
15
|
+
self.klass = klass
|
16
|
+
self.data = data
|
17
|
+
self.cursor = cursor
|
18
|
+
self.opts = opts
|
19
|
+
self.filters = filters
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.initialize_from_response(klass, response, opts, filters)
|
23
|
+
key = "#{klass.object_name}s".to_sym
|
24
|
+
list_data = response.data
|
25
|
+
entries = list_data[key]&.map { |entry| klass.new(entry, opts) } || []
|
26
|
+
cursor = list_data[:cursor]
|
27
|
+
new(klass, entries, cursor, opts, filters)
|
28
|
+
end
|
29
|
+
|
30
|
+
def inspect
|
31
|
+
"#<#{self.class}:0x#{object_id.to_s(16)}> JSON: " +
|
32
|
+
JSON.pretty_generate({ filters: filters, data: data, cursor: cursor })
|
33
|
+
end
|
34
|
+
|
35
|
+
def [](key)
|
36
|
+
data[key]
|
37
|
+
end
|
38
|
+
|
39
|
+
def each(&blk)
|
40
|
+
data.each(&blk)
|
41
|
+
end
|
42
|
+
|
43
|
+
def empty?
|
44
|
+
data.empty?
|
45
|
+
end
|
46
|
+
|
47
|
+
def auto_paging_each(&blk)
|
48
|
+
page = self
|
49
|
+
loop do
|
50
|
+
page.each(&blk)
|
51
|
+
page = page.next_page
|
52
|
+
break if page.empty?
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def next_page(params = {}, opts = {})
|
57
|
+
return self.class.empty_list(klass, opts, nil, filters) if cursor.nil?
|
58
|
+
|
59
|
+
params = filters.merge(cursor: cursor).merge(params)
|
60
|
+
|
61
|
+
klass.list(params, opts)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CashAppPay
|
4
|
+
class PersistentHttpClient
|
5
|
+
class << self
|
6
|
+
# url: URI / String
|
7
|
+
# options: any options that Net::HTTP.new accepts
|
8
|
+
def get(url, options = {})
|
9
|
+
uri = url.is_a?(URI) ? url : URI(url)
|
10
|
+
connection_manager.get_client(uri, options)
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
# each thread gets its own connection manager
|
16
|
+
def connection_manager
|
17
|
+
# before getting a connection manager
|
18
|
+
# we first clear all old ones
|
19
|
+
remove_old_managers
|
20
|
+
Thread.current[:cash_app_pay_client__internal_use_only] ||= new_manager
|
21
|
+
end
|
22
|
+
|
23
|
+
def new_manager
|
24
|
+
# create a new connection manager in a thread safe way
|
25
|
+
mutex.synchronize do
|
26
|
+
manager = ConnectionManager.new
|
27
|
+
connection_managers << manager
|
28
|
+
manager
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def remove_old_managers
|
33
|
+
mutex.synchronize do
|
34
|
+
removed = connection_managers.reject!(&:stale?)
|
35
|
+
(removed || []).each(&:close_connections!)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def mutex
|
40
|
+
@mutex ||= Mutex.new
|
41
|
+
end
|
42
|
+
|
43
|
+
def connection_managers
|
44
|
+
@connection_managers ||= []
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CashAppPay
|
4
|
+
class APIKey < APIResource
|
5
|
+
extend CashAppPay::APIOperations::Create
|
6
|
+
include CashAppPay::APIOperations::Save
|
7
|
+
extend CashAppPay::APIOperations::List
|
8
|
+
include CashAppPay::APIOperations::Retrieve
|
9
|
+
include CashAppPay::APIOperations::Delete
|
10
|
+
|
11
|
+
def self.resource_url
|
12
|
+
'/management/v1/api-keys'
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.object_name
|
16
|
+
:api_key
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CashAppPay
|
4
|
+
class Brand < APIResource
|
5
|
+
extend CashAppPay::APIOperations::Create
|
6
|
+
include CashAppPay::APIOperations::Save
|
7
|
+
extend CashAppPay::APIOperations::List
|
8
|
+
include CashAppPay::APIOperations::Retrieve
|
9
|
+
include CashAppPay::APIOperations::Update
|
10
|
+
include CashAppPay::APIOperations::Upsert
|
11
|
+
|
12
|
+
def self.resource_url
|
13
|
+
'/network/v1/brands'
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.object_name
|
17
|
+
:brand
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CashAppPay
|
4
|
+
class Customer < APIResource
|
5
|
+
extend CashAppPay::APIOperations::List
|
6
|
+
include CashAppPay::APIOperations::Retrieve
|
7
|
+
|
8
|
+
def self.resource_url
|
9
|
+
'/network/v1/customers'
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.object_name
|
13
|
+
:customer
|
14
|
+
end
|
15
|
+
|
16
|
+
def retrieve_grant(grant, opts = {})
|
17
|
+
CashAppPay::Grant.request_cash_app_pay_object(
|
18
|
+
method: :get,
|
19
|
+
path: format('/network/v1/customers/%<customer>s/grants/%<grant>s',
|
20
|
+
{ customer: CGI.escape(self), grant: CGI.escape(grant) }),
|
21
|
+
params: nil,
|
22
|
+
opts: opts
|
23
|
+
)
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.retrieve_grant(customer, grant, opts = {})
|
27
|
+
CashAppPay::Grant.request_cash_app_pay_object(
|
28
|
+
method: :get,
|
29
|
+
path: format('/network/v1/customers/%<customer>s/grants/%<grant>s',
|
30
|
+
{ customer: CGI.escape(customer), grant: CGI.escape(grant) }),
|
31
|
+
params: nil,
|
32
|
+
opts: opts
|
33
|
+
)
|
34
|
+
end
|
35
|
+
|
36
|
+
def revoke_grant(grant, opts = {})
|
37
|
+
CashAppPay::Grant.request_cash_app_pay_object(
|
38
|
+
method: :post,
|
39
|
+
path: format('/network/v1/customers/%<customer>s/grants/%<grant>s/revoke',
|
40
|
+
{ customer: CGI.escape(self), grant: CGI.escape(grant) }),
|
41
|
+
params: nil,
|
42
|
+
opts: opts
|
43
|
+
)
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.revoke_grant(customer, grant, opts = {})
|
47
|
+
CashAppPay::Grant.request_cash_app_pay_object(
|
48
|
+
method: :post,
|
49
|
+
path: format('/network/v1/customers/%<customer>s/grants/%<grant>s/revoke',
|
50
|
+
{ customer: CGI.escape(customer), grant: CGI.escape(grant) }),
|
51
|
+
params: nil,
|
52
|
+
opts: opts
|
53
|
+
)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CashAppPay
|
4
|
+
class CustomerRequest < APIResource
|
5
|
+
extend CashAppPay::APIOperations::Create
|
6
|
+
include CashAppPay::APIOperations::Save
|
7
|
+
include CashAppPay::APIOperations::Update
|
8
|
+
include CashAppPay::APIOperations::Retrieve
|
9
|
+
|
10
|
+
def self.resource_url
|
11
|
+
'/customer-request/v1/requests'
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.object_name
|
15
|
+
:request
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,142 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CashAppPay
|
4
|
+
class Dispute < APIResource
|
5
|
+
extend CashAppPay::APIOperations::List
|
6
|
+
include CashAppPay::APIOperations::Retrieve
|
7
|
+
|
8
|
+
def self.resource_url
|
9
|
+
'/network/v1/disputes'
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.object_name
|
13
|
+
:dispute
|
14
|
+
end
|
15
|
+
|
16
|
+
def accept(opts = {})
|
17
|
+
request_cash_app_pay_object(
|
18
|
+
method: :post,
|
19
|
+
path: format('/network/v1/disputes/%<dispute>s/accept', { dispute: CGI.escape(self) }),
|
20
|
+
params: nil,
|
21
|
+
opts: opts
|
22
|
+
)
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.accept(dispute, opts = {})
|
26
|
+
request_cash_app_pay_object(
|
27
|
+
method: :post,
|
28
|
+
path: format('/network/v1/disputes/%<dispute>s/accept', { dispute: CGI.escape(dispute) }),
|
29
|
+
params: nil,
|
30
|
+
opts: opts
|
31
|
+
)
|
32
|
+
end
|
33
|
+
|
34
|
+
def challenge(opts = {})
|
35
|
+
request_cash_app_pay_object(
|
36
|
+
method: :post,
|
37
|
+
path: format('/network/v1/disputes/%<dispute>s/challenge', { dispute: CGI.escape(self) }),
|
38
|
+
params: nil,
|
39
|
+
opts: opts
|
40
|
+
)
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.challenge(dispute, opts = {})
|
44
|
+
request_cash_app_pay_object(
|
45
|
+
method: :post,
|
46
|
+
path: format('/network/v1/disputes/%<dispute>s/challenge', { dispute: CGI.escape(dispute) }),
|
47
|
+
params: nil,
|
48
|
+
opts: opts
|
49
|
+
)
|
50
|
+
end
|
51
|
+
|
52
|
+
# def list_dispute_evidence(opts = {})
|
53
|
+
# request_cash_app_pay_object(
|
54
|
+
# method: :post,
|
55
|
+
# path: format('/network/v1/disputes/%<dispute>s/challenge', { dispute: CGI.escape(self) }),
|
56
|
+
# params: nil,
|
57
|
+
# opts: opts
|
58
|
+
# )
|
59
|
+
# end
|
60
|
+
|
61
|
+
# def self.list_dispute_evidence(dispute, opts = {})
|
62
|
+
# equest_cash_app_pay_object(
|
63
|
+
# method: :post,
|
64
|
+
# path: format('/network/v1/disputes/%<dispute>s/challenge', { dispute: CGI.escape(dispute) }),
|
65
|
+
# params: nil,
|
66
|
+
# opts: opts
|
67
|
+
# )
|
68
|
+
# end
|
69
|
+
|
70
|
+
def create_dispute_evidence_text(params = {}, opts = {})
|
71
|
+
CashAppPay::DisputeEvidence.request_cash_app_pay_object(
|
72
|
+
method: :post,
|
73
|
+
path: format('/network/v1/disputes/%<dispute>s/evidence-text', { dispute: CGI.escape(self) }),
|
74
|
+
params: params,
|
75
|
+
opts: opts
|
76
|
+
)
|
77
|
+
end
|
78
|
+
|
79
|
+
def self.create_dispute_evidence_text(dispute, params = {}, opts = {})
|
80
|
+
CashAppPay::DisputeEvidence.request_cash_app_pay_object(
|
81
|
+
method: :post,
|
82
|
+
path: format('/network/v1/disputes/%<dispute>s/evidence-text', { dispute: CGI.escape(dispute) }),
|
83
|
+
params: params,
|
84
|
+
opts: opts
|
85
|
+
)
|
86
|
+
end
|
87
|
+
|
88
|
+
# def create_dispute_evidence_file(params = {}, opts = {})
|
89
|
+
# CashAppPay::DisputeEvidence.request_cash_app_pay_object(
|
90
|
+
# method: :post,
|
91
|
+
# path: format('/network/v1/disputes/%<dispute>s/evidence-text', { dispute: CGI.escape(self) }),
|
92
|
+
# params: params,
|
93
|
+
# opts: opts
|
94
|
+
# )
|
95
|
+
# end
|
96
|
+
|
97
|
+
# def self.create_dispute_evidence_file(dispute, opts = {})
|
98
|
+
# CashAppPay::DisputeEvidence.request_cash_app_pay_object(
|
99
|
+
# method: :post,
|
100
|
+
# path: format('/network/v1/disputes/%<dispute>s/evidence-text', { dispute: CGI.escape(self) }),
|
101
|
+
# params: params,
|
102
|
+
# opts: opts
|
103
|
+
# )
|
104
|
+
# end
|
105
|
+
|
106
|
+
def delete_dispute_evidence(evidence, opts = {})
|
107
|
+
delete_cash_app_pay_object(
|
108
|
+
path: format('/network/v1/disputes/%<dispute>s/evidence/%<evidence>s',
|
109
|
+
{ dispute: CGI.escape(self), evidence: CGI.escape(evidence) }),
|
110
|
+
opts: opts
|
111
|
+
)
|
112
|
+
end
|
113
|
+
|
114
|
+
def self.delete_dispute_evidence(dispute, evidence, opts = {})
|
115
|
+
delete_cash_app_pay_object(
|
116
|
+
path: format('/mocks/cashapp-pay/api/109478393/disputes/%<dispute>s/evidence/%<evidence>s',
|
117
|
+
{ dispute: CGI.escape(dispute), evidence: CGI.escape(evidence) }),
|
118
|
+
opts: opts
|
119
|
+
)
|
120
|
+
end
|
121
|
+
|
122
|
+
def retrieve_dispute_evidence(evidence, opts = {})
|
123
|
+
CashAppPay::DisputeEvidence.request_cash_app_pay_object(
|
124
|
+
method: :get,
|
125
|
+
path: format('/network/v1/disputes/%<dispute>s/evidence/%<evidence>s',
|
126
|
+
{ dispute: CGI.escape(self), evidence: CGI.escape(evidence) }),
|
127
|
+
params: nil,
|
128
|
+
opts: opts
|
129
|
+
)
|
130
|
+
end
|
131
|
+
|
132
|
+
def self.retrieve_dispute_evidence(dispute, evidence, opts = {})
|
133
|
+
CashAppPay::DisputeEvidence.request_cash_app_pay_object(
|
134
|
+
method: :get,
|
135
|
+
path: format('/network/v1/disputes/%<dispute>s/evidence/%<evidence>s',
|
136
|
+
{ dispute: CGI.escape(dispute), evidence: CGI.escape(evidence) }),
|
137
|
+
params: nil,
|
138
|
+
opts: opts
|
139
|
+
)
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CashAppPay
|
4
|
+
class FeePlan < APIResource
|
5
|
+
extend CashAppPay::APIOperations::List
|
6
|
+
include CashAppPay::APIOperations::Retrieve
|
7
|
+
|
8
|
+
def self.resource_url
|
9
|
+
'/network/v1/fee-plans'
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.object_name
|
13
|
+
:fee_plan
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CashAppPay
|
4
|
+
class Merchant < APIResource
|
5
|
+
extend CashAppPay::APIOperations::Create
|
6
|
+
include CashAppPay::APIOperations::Save
|
7
|
+
extend CashAppPay::APIOperations::List
|
8
|
+
include CashAppPay::APIOperations::Retrieve
|
9
|
+
include CashAppPay::APIOperations::Update
|
10
|
+
include CashAppPay::APIOperations::Upsert
|
11
|
+
|
12
|
+
def self.resource_url
|
13
|
+
'/network/v1/merchants'
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.object_name
|
17
|
+
:merchant
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CashAppPay
|
4
|
+
class Payment < APIResource
|
5
|
+
extend CashAppPay::APIOperations::Create
|
6
|
+
include CashAppPay::APIOperations::Save
|
7
|
+
extend CashAppPay::APIOperations::List
|
8
|
+
include CashAppPay::APIOperations::Retrieve
|
9
|
+
|
10
|
+
def self.resource_url
|
11
|
+
'/network/v1/payments'
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.object_name
|
15
|
+
:payment
|
16
|
+
end
|
17
|
+
|
18
|
+
def capture(params = {}, opts = {})
|
19
|
+
request_cash_app_pay_object(
|
20
|
+
method: :post,
|
21
|
+
path: format('/network/v1/payments/%<payment>s/capture', { payment: CGI.escape(self) }),
|
22
|
+
params: params,
|
23
|
+
opts: opts
|
24
|
+
)
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.capture(payment, params = {}, opts = {})
|
28
|
+
request_cash_app_pay_object(
|
29
|
+
method: :post,
|
30
|
+
path: format('/network/v1/payments/%<payment>s/capture', { payment: CGI.escape(payment) }),
|
31
|
+
params: params,
|
32
|
+
opts: opts
|
33
|
+
)
|
34
|
+
end
|
35
|
+
|
36
|
+
def void(opts = {})
|
37
|
+
request_cash_app_pay_object(
|
38
|
+
method: :post,
|
39
|
+
path: format('/network/v1/payments/%<payment>s/void', { payment: CGI.escape(self) }),
|
40
|
+
params: nil,
|
41
|
+
opts: opts
|
42
|
+
)
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.void(payment, opts = {})
|
46
|
+
request_cash_app_pay_object(
|
47
|
+
method: :post,
|
48
|
+
path: format('/network/v1/payments/%<payment>s/void', { payment: CGI.escape(payment) }),
|
49
|
+
params: nil,
|
50
|
+
opts: opts
|
51
|
+
)
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.void_by_idempotency_key(params = {}, opts = {})
|
55
|
+
request_cash_app_pay_object(
|
56
|
+
method: :post,
|
57
|
+
path: '/network/v1/payments/void-by-idempotency-key',
|
58
|
+
params: params,
|
59
|
+
opts: opts
|
60
|
+
)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CashAppPay
|
4
|
+
class Refund < APIResource
|
5
|
+
extend CashAppPay::APIOperations::Create
|
6
|
+
extend CashAppPay::APIOperations::List
|
7
|
+
include CashAppPay::APIOperations::Retrieve
|
8
|
+
|
9
|
+
def self.resource_url
|
10
|
+
'/network/v1/refunds'
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.object_name
|
14
|
+
:refund
|
15
|
+
end
|
16
|
+
|
17
|
+
def capture(params = {}, opts = {})
|
18
|
+
request_cash_app_pay_object(
|
19
|
+
method: :post,
|
20
|
+
path: format('/network/v1/refunds/%<refund>s/capture', { refund: CGI.escape(self) }),
|
21
|
+
params: params,
|
22
|
+
opts: opts
|
23
|
+
)
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.capture(refund, params = {}, opts = {})
|
27
|
+
request_cash_app_pay_object(
|
28
|
+
method: :post,
|
29
|
+
path: format('/network/v1/refunds/%<refund>s/capture', { refund: CGI.escape(refund) }),
|
30
|
+
params: params,
|
31
|
+
opts: opts
|
32
|
+
)
|
33
|
+
end
|
34
|
+
|
35
|
+
def void(opts = {})
|
36
|
+
request_cash_app_pay_object(
|
37
|
+
method: :post,
|
38
|
+
path: format('/network/v1/refunds/%<refund>s/void', { refund: CGI.escape(self) }),
|
39
|
+
params: nil,
|
40
|
+
opts: opts
|
41
|
+
)
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.void(refund, opts = {})
|
45
|
+
request_cash_app_pay_object(
|
46
|
+
method: :post,
|
47
|
+
path: format('/network/v1/refunds/%<refund>s/void', { refund: CGI.escape(refund) }),
|
48
|
+
params: nil,
|
49
|
+
opts: opts
|
50
|
+
)
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.void_by_idempotency_key(params = {}, opts = {})
|
54
|
+
request_cash_app_pay_object(
|
55
|
+
method: :post,
|
56
|
+
path: '/network/v1/refunds/void-by-idempotency-key',
|
57
|
+
params: params,
|
58
|
+
opts: opts
|
59
|
+
)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CashAppPay
|
4
|
+
class Webhook < APIResource
|
5
|
+
extend CashAppPay::APIOperations::Create
|
6
|
+
include CashAppPay::APIOperations::Save
|
7
|
+
include CashAppPay::APIOperations::Update
|
8
|
+
extend CashAppPay::APIOperations::List
|
9
|
+
include CashAppPay::APIOperations::Retrieve
|
10
|
+
include CashAppPay::APIOperations::Delete
|
11
|
+
|
12
|
+
def self.resource_url
|
13
|
+
'/management/v1/webhook-endpoints'
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.object_name
|
17
|
+
:webhook_endpoint
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CashAppPay
|
4
|
+
class WebhookEvent < APIResource
|
5
|
+
extend CashAppPay::APIOperations::List
|
6
|
+
|
7
|
+
def self.resource_url
|
8
|
+
'/management/v1/webhook-events'
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.object_name
|
12
|
+
:webhook_event
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/cash_app_pay.rb
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'json'
|
4
|
+
require 'cgi'
|
5
|
+
require 'forwardable'
|
6
|
+
require 'uri'
|
7
|
+
require 'net/http'
|
8
|
+
require 'byebug'
|
9
|
+
require 'securerandom'
|
10
|
+
require 'time'
|
11
|
+
|
12
|
+
# Version
|
13
|
+
require 'cash_app_pay/version'
|
14
|
+
|
15
|
+
# Helpers
|
16
|
+
require 'cash_app_pay/helpers/symbolize'
|
17
|
+
|
18
|
+
# API operations
|
19
|
+
require 'cash_app_pay/api_operations/create'
|
20
|
+
require 'cash_app_pay/api_operations/list'
|
21
|
+
require 'cash_app_pay/api_operations/request'
|
22
|
+
require 'cash_app_pay/api_operations/update'
|
23
|
+
require 'cash_app_pay/api_operations/save'
|
24
|
+
require 'cash_app_pay/api_operations/retrieve'
|
25
|
+
require 'cash_app_pay/api_operations/upsert'
|
26
|
+
require 'cash_app_pay/api_operations/delete'
|
27
|
+
|
28
|
+
require 'cash_app_pay/errors'
|
29
|
+
require 'cash_app_pay/endpoint'
|
30
|
+
require 'cash_app_pay/connection_manager'
|
31
|
+
require 'cash_app_pay/persistent_http_client'
|
32
|
+
require 'cash_app_pay/cash_app_pay_client'
|
33
|
+
require 'cash_app_pay/cash_app_pay_object'
|
34
|
+
require 'cash_app_pay/cash_app_pay_response'
|
35
|
+
require 'cash_app_pay/list_object'
|
36
|
+
require 'cash_app_pay/api_resource'
|
37
|
+
require 'cash_app_pay/cash_app_pay_configuration'
|
38
|
+
require 'cash_app_pay/error_object'
|
39
|
+
|
40
|
+
# Named API resources
|
41
|
+
require 'cash_app_pay/resources/customer_request'
|
42
|
+
require 'cash_app_pay/resources/payment'
|
43
|
+
require 'cash_app_pay/resources/webhook'
|
44
|
+
require 'cash_app_pay/resources/webhook_event'
|
45
|
+
require 'cash_app_pay/resources/fee_plan'
|
46
|
+
require 'cash_app_pay/resources/customer'
|
47
|
+
require 'cash_app_pay/resources/grant'
|
48
|
+
require 'cash_app_pay/resources/brand'
|
49
|
+
require 'cash_app_pay/resources/dispute'
|
50
|
+
require 'cash_app_pay/resources/dispute_evidence'
|
51
|
+
require 'cash_app_pay/resources/merchant'
|
52
|
+
require 'cash_app_pay/resources/refund'
|
53
|
+
require 'cash_app_pay/resources/api_key'
|
54
|
+
|
55
|
+
module CashAppPay
|
56
|
+
@config = CashAppPay::CashAppPayConfiguration.setup
|
57
|
+
|
58
|
+
class << self
|
59
|
+
extend Forwardable
|
60
|
+
|
61
|
+
attr_accessor :config
|
62
|
+
|
63
|
+
def_delegators :@config, :api_base, :api_base=
|
64
|
+
def_delegators :@config, :client_id, :client_id=
|
65
|
+
def_delegators :@config, :region, :region=
|
66
|
+
def_delegators :@config, :signature, :signature=
|
67
|
+
def_delegators :@config, :api_key, :api_key=
|
68
|
+
end
|
69
|
+
end
|