starkinfra 0.0.3 → 0.2.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/lib/brcodepreview/brcodepreview.rb +121 -0
- data/lib/cardmethod/cardmethod.rb +56 -0
- data/lib/creditnote/creditnote.rb +58 -341
- data/lib/creditnote/invoice/description.rb +51 -0
- data/lib/creditnote/invoice/discount.rb +49 -0
- data/lib/creditnote/invoice/invoice.rb +123 -0
- data/lib/creditnote/log.rb +2 -2
- data/lib/creditnote/transfer.rb +90 -0
- data/lib/creditpreview/creditnotepreview.rb +85 -0
- data/lib/creditpreview/creditpreview.rb +83 -0
- data/lib/creditsigner/creditsigner.rb +57 -0
- data/lib/dynamicbrcode/dynamicbrcode.rb +350 -0
- data/lib/event/attempt.rb +4 -3
- data/lib/event/event.rb +10 -10
- data/lib/issuingbalance/issuingbalance.rb +4 -4
- data/lib/issuingcard/issuingcard.rb +40 -36
- data/lib/issuingcard/log.rb +3 -3
- data/lib/issuingholder/issuingholder.rb +14 -9
- data/lib/issuingholder/log.rb +3 -3
- data/lib/issuinginvoice/issuinginvoice.rb +24 -10
- data/lib/issuinginvoice/log.rb +3 -3
- data/lib/issuingproduct/issuingproduct.rb +86 -0
- data/lib/issuingpurchase/issuingpurchase.rb +100 -24
- data/lib/issuingpurchase/log.rb +2 -2
- data/lib/issuingrule/issuingrule.rb +74 -30
- data/lib/issuingtransaction/issuingtransaction.rb +6 -8
- data/lib/issuingwithdrawal/issuingwithdrawal.rb +11 -7
- data/lib/merchantcategory/merchantcategory.rb +63 -0
- data/lib/merchantcountry/merchantcountry.rb +59 -0
- data/lib/pixbalance/pixbalance.rb +5 -5
- data/lib/pixchargeback/log.rb +3 -3
- data/lib/pixchargeback/pixchargeback.rb +32 -20
- data/lib/pixclaim/log.rb +8 -11
- data/lib/pixclaim/pixclaim.rb +43 -32
- data/lib/pixdirector/pixdirector.rb +9 -11
- data/lib/pixdomain/certificate.rb +1 -1
- data/lib/pixdomain/pixdomain.rb +4 -4
- data/lib/pixinfraction/log.rb +2 -2
- data/lib/pixinfraction/pixinfraction.rb +21 -13
- data/lib/pixkey/log.rb +5 -5
- data/lib/pixkey/pixkey.rb +12 -10
- data/lib/pixrequest/log.rb +2 -2
- data/lib/pixrequest/pixrequest.rb +51 -21
- data/lib/pixreversal/log.rb +2 -2
- data/lib/pixreversal/pixreversal.rb +48 -20
- data/lib/pixstatement/pixstatement.rb +12 -7
- data/lib/starkinfra.rb +27 -15
- data/lib/staticbrcode/staticbrcode.rb +164 -0
- data/lib/user/project.rb +1 -1
- data/lib/utils/api.rb +1 -0
- data/lib/utils/parse.rb +7 -3
- data/lib/utils/request.rb +1 -1
- data/lib/utils/resource.rb +1 -1
- data/lib/utils/rest.rb +1 -2
- data/lib/utils/sub_resource.rb +21 -22
- data/lib/webhook/webhook.rb +3 -3
- metadata +16 -4
- data/lib/issuingauthorization/issuingauthorization.rb +0 -141
- data/lib/issuingbin/issuingbin.rb +0 -89
@@ -1,14 +1,18 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative('../utils/resource')
|
4
3
|
require_relative('../utils/rest')
|
5
4
|
require_relative('../utils/checks')
|
5
|
+
require_relative('../utils/resource')
|
6
6
|
|
7
7
|
module StarkInfra
|
8
8
|
# # IssuingHolder object
|
9
9
|
#
|
10
10
|
# The IssuingHolder describes a card holder that may group several cards.
|
11
11
|
#
|
12
|
+
# When you initialize a IssuingHolder, the entity will not be automatically
|
13
|
+
# created in the Stark Infra API. The 'create' function sends the objects
|
14
|
+
# to the Stark Infra API and returns the created object.
|
15
|
+
#
|
12
16
|
# ## Parameters (required):
|
13
17
|
# - name [string]: card holder name.
|
14
18
|
# - tax_id [string]: card holder tax ID
|
@@ -16,7 +20,7 @@ module StarkInfra
|
|
16
20
|
#
|
17
21
|
# ## Parameters (optional):
|
18
22
|
# - rules [list of IssuingRule objects, default nil]: [EXPANDABLE] list of holder spending rules.
|
19
|
-
# - tags [list of strings, default
|
23
|
+
# - tags [list of strings, default nil]: list of strings for tagging. ex: ['travel', 'food']
|
20
24
|
#
|
21
25
|
# ## Attributes (return-only):
|
22
26
|
# - id [string]: unique id returned when IssuingHolder is created. ex: '5656565656565656'
|
@@ -24,17 +28,17 @@ module StarkInfra
|
|
24
28
|
# - updated [DateTime]: latest update datetime for the IssuingHolder. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
25
29
|
# - created [DateTime]: creation datetime for the log. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
26
30
|
class IssuingHolder < StarkInfra::Utils::Resource
|
27
|
-
attr_reader :id, :name, :tax_id, :external_id, :
|
31
|
+
attr_reader :id, :name, :tax_id, :external_id, :rules, :tags, :status, :updated, :created
|
28
32
|
def initialize(
|
29
|
-
name:, tax_id:, external_id:,
|
33
|
+
name:, tax_id:, external_id:, rules: nil, tags: nil, id: nil, status: nil, updated: nil, created: nil
|
30
34
|
)
|
31
35
|
super(id)
|
32
36
|
@name = name
|
33
37
|
@tax_id = tax_id
|
34
38
|
@external_id = external_id
|
35
|
-
@status = status
|
36
39
|
@rules = StarkInfra::IssuingRule.parse_rules(rules)
|
37
40
|
@tags = tags
|
41
|
+
@status = status
|
38
42
|
@created = StarkInfra::Utils::Checks.check_datetime(created)
|
39
43
|
@updated = StarkInfra::Utils::Checks.check_datetime(updated)
|
40
44
|
end
|
@@ -47,12 +51,13 @@ module StarkInfra
|
|
47
51
|
# - holders [list of IssuingHolder objects]: list of IssuingHolder objects to be created in the API
|
48
52
|
#
|
49
53
|
# ## Parameters (optional):
|
54
|
+
# - expand [list of strings, default nil]: fields to expand information. Options: ['rules']
|
50
55
|
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
51
56
|
#
|
52
57
|
# ## Return:
|
53
58
|
# - list of IssuingHolder objects with updated attributes
|
54
|
-
def self.create(holders:, user: nil)
|
55
|
-
StarkInfra::Utils::Rest.post(entities: holders, user: user, **resource)
|
59
|
+
def self.create(holders:, expand: nil, user: nil)
|
60
|
+
StarkInfra::Utils::Rest.post(entities: holders, expand: expand, user: user, **resource)
|
56
61
|
end
|
57
62
|
|
58
63
|
# # Retrieve a specific IssuingHolder
|
@@ -110,7 +115,7 @@ module StarkInfra
|
|
110
115
|
#
|
111
116
|
# ## Parameters (optional):
|
112
117
|
# - cursor [string, default nil]: cursor returned on the previous page function call.
|
113
|
-
# - limit [integer, default
|
118
|
+
# - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex: 35
|
114
119
|
# - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
115
120
|
# - after [Date or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
116
121
|
# - before [Date or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
@@ -193,9 +198,9 @@ module StarkInfra
|
|
193
198
|
name: json['name'],
|
194
199
|
tax_id: json['tax_id'],
|
195
200
|
external_id: json['external_id'],
|
196
|
-
status: json['status'],
|
197
201
|
rules: json['rules'],
|
198
202
|
tags: json['tags'],
|
203
|
+
status: json['status'],
|
199
204
|
updated: json['updated'],
|
200
205
|
created: json['created']
|
201
206
|
)
|
data/lib/issuingholder/log.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative('
|
3
|
+
require_relative('issuingholder')
|
4
4
|
require_relative('../utils/rest')
|
5
5
|
require_relative('../utils/checks')
|
6
|
-
require_relative('
|
6
|
+
require_relative('../utils/resource')
|
7
7
|
|
8
8
|
module StarkInfra
|
9
9
|
class IssuingHolder
|
@@ -78,7 +78,7 @@ module StarkInfra
|
|
78
78
|
#
|
79
79
|
# ## Parameters (optional):
|
80
80
|
# - cursor [string, default nil]: cursor returned on the previous page function call
|
81
|
-
# - limit [integer, default
|
81
|
+
# - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex: 35
|
82
82
|
# - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
83
83
|
# - after [Date or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
84
84
|
# - before [Date or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
@@ -1,42 +1,53 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative('../utils/resource')
|
4
3
|
require_relative('../utils/rest')
|
5
4
|
require_relative('../utils/checks')
|
5
|
+
require_relative('../utils/resource')
|
6
6
|
|
7
7
|
module StarkInfra
|
8
8
|
# # IssuingInvoice object
|
9
9
|
#
|
10
10
|
# The IssuingInvoice objects created in your Workspace load your Issuing balance when paid.
|
11
11
|
#
|
12
|
+
# When you initialize a IssuingInvoice, the entity will not be automatically
|
13
|
+
# created in the Stark Infra API. The 'create' function sends the objects
|
14
|
+
# to the Stark Infra API and returns the created object.
|
15
|
+
#
|
12
16
|
# ## Parameters (required):
|
13
17
|
# - amount [integer]: IssuingInvoice value in cents. ex: 1234 (= R$ 12.34)
|
14
18
|
#
|
15
19
|
# ## Parameters (optional):
|
16
20
|
# - tax_id [string, default sub-issuer tax ID]: payer tax ID (CPF or CNPJ) with or without formatting. ex: '01234567890' or '20.018.183/0001-80'
|
17
21
|
# - name [string, default sub-issuer name]: payer name. ex: 'Iron Bank S.A.'
|
18
|
-
# - tags [list of strings, default
|
22
|
+
# - tags [list of strings, default nil]: list of strings for tagging. ex: ['travel', 'food']
|
19
23
|
#
|
20
24
|
# ## Attributes (return-only):
|
21
25
|
# - id [string]: unique id returned when IssuingInvoice is created. ex: '5656565656565656'
|
26
|
+
# - brcode [string]: BR Code for the Invoice payment. ex: '00020101021226930014br.gov.bcb.pix2571brcode-h.development.starkinfra.com/v2/d7f6546e194d4c64a153e8f79f1c41ac5204000053039865802BR5925Stark Bank S.A. - Institu6009Sao Paulo62070503***63042109'
|
27
|
+
# - due [DateTime, Date or string]: Invoice due and expiration date in UTC ISO format. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0), Date.new(2020, 3, 10) or '2020-03-10T10:30:00.000000+00:00'
|
28
|
+
# - link [string]: public Invoice webpage URL. ex: 'https://starkbank-card-issuer.development.starkbank.com/invoicelink/d7f6546e194d4c64a153e8f79f1c41ac'
|
22
29
|
# - status [string]: current IssuingInvoice status. ex: 'created', 'expired', 'overdue', 'paid'
|
23
30
|
# - issuing_transaction_id [string]: ledger transaction ids linked to this IssuingInvoice. ex: 'issuing-invoice/5656565656565656'
|
24
31
|
# - updated [DateTime]: latest update datetime for the IssuingInvoice. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
25
32
|
# - created [DateTime]: creation datetime for the IssuingInvoice. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
26
33
|
class IssuingInvoice < StarkInfra::Utils::Resource
|
27
|
-
attr_reader :amount, :
|
34
|
+
attr_reader :id, :amount, :tax_id, :name, :tags, :brcode, :due, :link, :status, :issuing_transaction_id, :updated, :created
|
28
35
|
def initialize(
|
29
|
-
amount:, id: nil, name: nil,
|
36
|
+
amount:, id: nil, tax_id: nil, name: nil, tags: nil, brcode: nil, due: nil, link: nil, status: nil, issuing_transaction_id: nil,
|
37
|
+
updated: nil, created: nil
|
30
38
|
)
|
31
39
|
super(id)
|
32
40
|
@amount = amount
|
33
|
-
@name = name
|
34
41
|
@tax_id = tax_id
|
42
|
+
@name = name
|
43
|
+
@tags = tags
|
44
|
+
@brcode = brcode
|
45
|
+
@due = due
|
46
|
+
@link = link
|
35
47
|
@status = status
|
36
48
|
@issuing_transaction_id = issuing_transaction_id
|
37
|
-
@tags = tags
|
38
|
-
@created = StarkInfra::Utils::Checks.check_datetime(created)
|
39
49
|
@updated = StarkInfra::Utils::Checks.check_datetime(updated)
|
50
|
+
@created = StarkInfra::Utils::Checks.check_datetime(created)
|
40
51
|
end
|
41
52
|
|
42
53
|
# # Create an IssuingInvoice
|
@@ -105,7 +116,7 @@ module StarkInfra
|
|
105
116
|
#
|
106
117
|
# ## Parameters (optional):
|
107
118
|
# - cursor [string, default nil]: cursor returned on the previous page function call.
|
108
|
-
# - limit [integer, default
|
119
|
+
# - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex: 35
|
109
120
|
# - after [Date or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
110
121
|
# - before [Date or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
111
122
|
# - status [list of strings, default nil]: filter for status of retrieved objects. ex: ['created', 'expired', 'overdue', 'paid']
|
@@ -137,11 +148,14 @@ module StarkInfra
|
|
137
148
|
IssuingInvoice.new(
|
138
149
|
id: json['id'],
|
139
150
|
amount: json['amount'],
|
140
|
-
name: json['name'],
|
141
151
|
tax_id: json['tax_id'],
|
152
|
+
name: json['name'],
|
153
|
+
tags: json['tags'],
|
154
|
+
brcode: json['brcode'],
|
155
|
+
due: json['due'],
|
156
|
+
link: json['link'],
|
142
157
|
status: json['status'],
|
143
158
|
issuing_transaction_id: json['issuing_transaction_id'],
|
144
|
-
tags: json['tags'],
|
145
159
|
updated: json['updated'],
|
146
160
|
created: json['created']
|
147
161
|
)
|
data/lib/issuinginvoice/log.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative('../utils/resource')
|
4
3
|
require_relative('../utils/rest')
|
5
|
-
require_relative('../utils/checks')
|
6
4
|
require_relative('issuinginvoice')
|
5
|
+
require_relative('../utils/checks')
|
6
|
+
require_relative('../utils/resource')
|
7
7
|
|
8
8
|
module StarkInfra
|
9
9
|
class IssuingInvoice
|
@@ -78,7 +78,7 @@ module StarkInfra
|
|
78
78
|
# ## Parameters (optional):
|
79
79
|
# - cursor [string, default nil]: cursor returned on the previous page function call
|
80
80
|
# - ids [list of strings, default nil]: list of IssuingInvoice ids to filter logs. ex: ['5656565656565656', '4545454545454545']
|
81
|
-
# - limit [integer, default
|
81
|
+
# - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex: 35
|
82
82
|
# - after [Date or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
83
83
|
# - before [Date or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
84
84
|
# - types [list of strings, default nil]: filter for log event types. ex: ['created', 'credited', 'expired', 'overdue', 'paid']
|
@@ -0,0 +1,86 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative('../utils/rest')
|
4
|
+
require_relative('../utils/checks')
|
5
|
+
require_relative('../utils/resource')
|
6
|
+
|
7
|
+
module StarkInfra
|
8
|
+
# # IssuingProduct object
|
9
|
+
#
|
10
|
+
# The IssuingProduct object displays information of avaliable card products registered to your Workspace.
|
11
|
+
# They represent a group of cards that begin with the same numbers (id) and offer the same product to end customers.
|
12
|
+
#
|
13
|
+
# ## Attributes (return-only):
|
14
|
+
# - id [string]: unique card product number (BIN) registered within the card network. ex: '53810200'
|
15
|
+
# - network [string]: card network flag. ex: 'mastercard'
|
16
|
+
# - funding_type [string]: type of funding used for payment. ex: 'credit', 'debit'
|
17
|
+
# - holder_type [string]: holder type. ex: 'business', 'individual'
|
18
|
+
# - code [string]: internal code from card flag informing the product. ex: 'MRW', 'MCO', 'MWB', 'MCS'
|
19
|
+
# - created [DateTime]: creation datetime for the IssuingProduct. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
20
|
+
class IssuingProduct < StarkInfra::Utils::Resource
|
21
|
+
attr_reader :id, :network, :funding_type, :holder_type, :code, :created
|
22
|
+
def initialize(id: nil, network: nil, funding_type: nil, holder_type: nil, code: nil, created: nil)
|
23
|
+
super(id)
|
24
|
+
@network = network
|
25
|
+
@funding_type = funding_type
|
26
|
+
@holder_type = holder_type
|
27
|
+
@code = code
|
28
|
+
@created = StarkInfra::Utils::Checks.check_datetime(created)
|
29
|
+
end
|
30
|
+
|
31
|
+
# # Retrieve IssuingProducts
|
32
|
+
#
|
33
|
+
# Receive a generator of available IssuingProduct objects previously registered to your workspace
|
34
|
+
#
|
35
|
+
# ## Parameters (optional):
|
36
|
+
# - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
|
37
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
38
|
+
#
|
39
|
+
# ## Return:
|
40
|
+
# - generator of IssuingProduct objects with updated attributes
|
41
|
+
def self.query(limit: nil, user: nil)
|
42
|
+
StarkInfra::Utils::Rest.get_stream(
|
43
|
+
limit: limit,
|
44
|
+
user: user,
|
45
|
+
**resource
|
46
|
+
)
|
47
|
+
end
|
48
|
+
|
49
|
+
# # Retrieve paged IssuingProducts
|
50
|
+
#
|
51
|
+
# Receive a list of up to 100 IssuingProduct objects previously registered to your workspace and the cursor to the next page.
|
52
|
+
#
|
53
|
+
# ## Parameters (optional):
|
54
|
+
# - cursor [string, default nil]: cursor returned on the previous page function call.
|
55
|
+
# - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex: 35
|
56
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
57
|
+
#
|
58
|
+
# ## Return:
|
59
|
+
# - list of IssuingProduct objects with updated attributes
|
60
|
+
# - cursor to retrieve the next page of IssuingProduct objects
|
61
|
+
def self.page(cursor: nil, limit: nil, user: nil)
|
62
|
+
StarkInfra::Utils::Rest.get_page(
|
63
|
+
cursor: cursor,
|
64
|
+
limit: limit,
|
65
|
+
user: user,
|
66
|
+
**resource
|
67
|
+
)
|
68
|
+
end
|
69
|
+
|
70
|
+
def self.resource
|
71
|
+
{
|
72
|
+
resource_name: 'IssuingProduct',
|
73
|
+
resource_maker: proc { |json|
|
74
|
+
IssuingProduct.new(
|
75
|
+
id: json['id'],
|
76
|
+
network: json['network'],
|
77
|
+
funding_type: json['funding_type'],
|
78
|
+
holder_type: json['holder_type'],
|
79
|
+
code: json['code'],
|
80
|
+
created: json['created']
|
81
|
+
)
|
82
|
+
}
|
83
|
+
}
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative('../utils/resource')
|
4
3
|
require_relative('../utils/rest')
|
5
4
|
require_relative('../utils/checks')
|
5
|
+
require_relative('../utils/resource')
|
6
6
|
|
7
7
|
module StarkInfra
|
8
8
|
# # IssuingPurchase object
|
@@ -14,6 +14,7 @@ module StarkInfra
|
|
14
14
|
# - holder_name [string]: card holder name. ex: 'Tony Stark'
|
15
15
|
# - card_id [string]: unique id returned when IssuingCard is created. ex: '5656565656565656'
|
16
16
|
# - card_ending [string]: last 4 digits of the card number. ex: '1234'
|
17
|
+
# - purpose [string]: purchase purpose. ex: 'purchase'
|
17
18
|
# - amount [integer]: IssuingPurchase value in cents. Minimum = 0. ex: 1234 (= R$ 12.34)
|
18
19
|
# - tax [integer]: IOF amount taxed for international purchases. ex: 1234 (= R$ 12.34)
|
19
20
|
# - issuer_amount [integer]: issuer amount. ex: 1234 (= R$ 12.34)
|
@@ -29,32 +30,42 @@ module StarkInfra
|
|
29
30
|
# - merchant_name [string]: merchant name. ex: 'Google Cloud Platform'
|
30
31
|
# - merchant_fee [integer]: fee charged by the merchant to cover specific costs, such as ATM withdrawal logistics, etc. ex: 200 (= R$ 2.00)
|
31
32
|
# - wallet_id [string]: virtual wallet ID. ex: '5656565656565656'
|
32
|
-
# - method_code [string]: method code.
|
33
|
+
# - method_code [string]: method code. Options: 'chip', 'token', 'server', 'manual', 'magstripe' or 'contactless'
|
33
34
|
# - score [float]: internal score calculated for the authenticity of the purchase. nil in case of insufficient data. ex: 7.6
|
34
|
-
# -
|
35
|
-
# - end_to_end_id [string]: Unique id used to identify the transaction through all of its life cycle, even before the purchase is denied or accepted and gets its usual id. Example: endToEndId='679cd385-642b-49d0-96b7-89491e1249a5'
|
36
|
-
# - status [string]: current IssuingCard status. ex: 'approved', 'canceled', 'denied', 'confirmed', 'voided'
|
35
|
+
# - end_to_end_id [string]: Unique id used to identify the transaction through all of its life cycle, even before the purchase is denied or approved and gets its usual id. ex: '679cd385-642b-49d0-96b7-89491e1249a5'
|
37
36
|
# - tags [string]: list of strings for tagging returned by the sub-issuer during the authorization. ex: ['travel', 'food']
|
38
|
-
# -
|
37
|
+
# - zip_code [string]: zip code of the merchant location. ex: '02101234'
|
38
|
+
#
|
39
|
+
# ## Attributes (IssuingPurchase only):
|
40
|
+
# - issuing_transaction_ids [string]: ledger transaction ids linked to this Purchase
|
41
|
+
# - status [string]: current IssuingCard status. Options: 'approved', 'canceled', 'denied', 'confirmed', 'voided'
|
39
42
|
# - updated [DateTime]: latest update datetime for the IssuingPurchase. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
43
|
+
# - created [DateTime]: creation datetime for the IssuingPurchase. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
44
|
+
#
|
45
|
+
# ## Attributes (authorization request only):
|
46
|
+
# - is_partial_allowed [bool]: true if the merchant allows partial purchases. ex: False
|
47
|
+
# - card_tags [list of strings]: tags of the IssuingCard responsible for this purchase. ex: ['travel', 'food']
|
48
|
+
# - holder_tags [list of strings]: tags of the IssuingHolder responsible for this purchase. ex: ['technology', 'john snow']
|
40
49
|
class IssuingPurchase < StarkInfra::Utils::Resource
|
41
|
-
attr_reader :id, :holder_name, :card_id, :card_ending, :amount, :tax, :issuer_amount, :issuer_currency_code,
|
50
|
+
attr_reader :id, :holder_name, :card_id, :card_ending, :purpose, :amount, :tax, :issuer_amount, :issuer_currency_code,
|
42
51
|
:issuer_currency_symbol, :merchant_amount, :merchant_currency_code, :merchant_currency_symbol,
|
43
52
|
:merchant_category_code, :merchant_country_code, :acquirer_id, :merchant_id, :merchant_name,
|
44
|
-
:merchant_fee, :wallet_id, :method_code, :score, :
|
45
|
-
:
|
53
|
+
:merchant_fee, :wallet_id, :method_code, :score, :end_to_end_id, :tags, :zip_code,
|
54
|
+
:issuing_transaction_ids, :status, :updated, :created, :is_partial_allowed, :card_tags, :holder_tags
|
46
55
|
|
47
56
|
def initialize(
|
48
|
-
id: nil, holder_name: nil, card_id: nil, card_ending: nil, amount: nil, tax: nil, issuer_amount: nil,
|
57
|
+
id: nil, holder_name: nil, card_id: nil, card_ending: nil, purpose: nil, amount: nil, tax: nil, issuer_amount: nil,
|
49
58
|
issuer_currency_code: nil, issuer_currency_symbol: nil, merchant_amount: nil, merchant_currency_code: nil,
|
50
59
|
merchant_currency_symbol: nil, merchant_category_code: nil, merchant_country_code: nil, acquirer_id: nil,
|
51
60
|
merchant_id: nil, merchant_name: nil, merchant_fee: nil, wallet_id: nil, method_code: nil, score: nil,
|
52
|
-
|
61
|
+
end_to_end_id: nil, tags: nil, zip_code: nil, issuing_transaction_ids: nil, status: nil, updated: nil, created: nil,
|
62
|
+
is_partial_allowed: nil, card_tags:nil, holder_tags:nil
|
53
63
|
)
|
54
64
|
super(id)
|
55
65
|
@holder_name = holder_name
|
56
66
|
@card_id = card_id
|
57
67
|
@card_ending = card_ending
|
68
|
+
@purpose = purpose
|
58
69
|
@amount = amount
|
59
70
|
@tax = tax
|
60
71
|
@issuer_amount = issuer_amount
|
@@ -72,12 +83,17 @@ module StarkInfra
|
|
72
83
|
@wallet_id = wallet_id
|
73
84
|
@method_code = method_code
|
74
85
|
@score = score
|
75
|
-
@issuing_transaction_ids = issuing_transaction_ids
|
76
86
|
@end_to_end_id = end_to_end_id
|
77
|
-
@status = status
|
78
87
|
@tags = tags
|
79
|
-
@
|
88
|
+
@zip_code = zip_code
|
89
|
+
@issuing_transaction_ids = issuing_transaction_ids
|
90
|
+
@status = status
|
80
91
|
@updated = StarkInfra::Utils::Checks.check_datetime(updated)
|
92
|
+
@created = StarkInfra::Utils::Checks.check_datetime(created)
|
93
|
+
@is_partial_allowed = is_partial_allowed
|
94
|
+
@card_tags = card_tags
|
95
|
+
@holder_tags = holder_tags
|
96
|
+
|
81
97
|
end
|
82
98
|
|
83
99
|
# # Retrieve a specific IssuingPurchase
|
@@ -105,9 +121,9 @@ module StarkInfra
|
|
105
121
|
# - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
|
106
122
|
# - after [Date or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 09)
|
107
123
|
# - before [Date or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
108
|
-
# - end_to_end_ids [list of strings, default
|
109
|
-
# - holder_ids [list of strings, default
|
110
|
-
# - card_ids [list of strings, default
|
124
|
+
# - end_to_end_ids [list of strings, default nil]: central bank's unique transaction ID. ex: 'E79457883202101262140HHX553UPqeq'
|
125
|
+
# - holder_ids [list of strings, default nil]: card holder IDs. ex: ['5656565656565656', '4545454545454545']
|
126
|
+
# - card_ids [list of strings, default nil]: card IDs. ex: ['5656565656565656', '4545454545454545']
|
111
127
|
# - status [list of strings, default nil]: filter for status of retrieved objects. ex: ['approved', 'canceled', 'denied', 'confirmed', 'voided']
|
112
128
|
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
|
113
129
|
#
|
@@ -138,12 +154,12 @@ module StarkInfra
|
|
138
154
|
# ## Parameters (optional):
|
139
155
|
# - cursor [string, default nil]: cursor returned on the previous page function call.
|
140
156
|
# - ids [list of strings, default nil]: purchase IDs. ex: ['5656565656565656', '4545454545454545']
|
141
|
-
# - limit [integer, default
|
157
|
+
# - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex: 35
|
142
158
|
# - after [Date or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
143
159
|
# - before [Date or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
144
|
-
# - end_to_end_ids [list of strings, default
|
145
|
-
# - holder_ids [list of strings, default
|
146
|
-
# - card_ids [list of strings, default
|
160
|
+
# - end_to_end_ids [list of strings, default nil]: central bank's unique transaction ID. ex: 'E79457883202101262140HHX553UPqeq'
|
161
|
+
# - holder_ids [list of strings, default nil]: card holder IDs. ex: ['5656565656565656', '4545454545454545']
|
162
|
+
# - card_ids [list of strings, default nil]: card IDs. ex: ['5656565656565656', '4545454545454545']
|
147
163
|
# - status [list of strings, default nil]: filter for status of retrieved objects. ex: ['approved', 'canceled', 'denied', 'confirmed', 'voided']
|
148
164
|
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
|
149
165
|
#
|
@@ -169,6 +185,61 @@ module StarkInfra
|
|
169
185
|
)
|
170
186
|
end
|
171
187
|
|
188
|
+
# # Create a single verified IssuingPurchase authorization request from a content string
|
189
|
+
#
|
190
|
+
# Use this method to parse and verify the authenticity of the authorization request received at the informed endpoint.
|
191
|
+
# Authorization requests are posted to your registered endpoint whenever IssuingPurchases are received.
|
192
|
+
# They present IssuingPurchase data that must be analyzed and answered with approval or declination.
|
193
|
+
# If the provided digital signature does not check out with the StarkInfra public key, a stark.exception.InvalidSignatureException will be raised.
|
194
|
+
# If the authorization request is not answered within 2 seconds or is not answered with an HTTP status code 200 the
|
195
|
+
# IssuingPurchase will go through the pre-configured stand-in validation.
|
196
|
+
#
|
197
|
+
# ## Parameters (required):
|
198
|
+
# - content [string]: response content from request received at user endpoint (not parsed)
|
199
|
+
# - signature [string]: base-64 digital signature received at response header 'Digital-Signature'
|
200
|
+
#
|
201
|
+
# # ## Parameters (optional):
|
202
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
|
203
|
+
#
|
204
|
+
# ## Return:
|
205
|
+
# - Parsed IssuingPurchase object
|
206
|
+
def self.parse(content:, signature:, user: nil)
|
207
|
+
StarkInfra::Utils::Parse.parse_and_verify(
|
208
|
+
content: content,
|
209
|
+
signature: signature,
|
210
|
+
user: user,
|
211
|
+
key: nil,
|
212
|
+
**resource
|
213
|
+
)
|
214
|
+
end
|
215
|
+
|
216
|
+
# # Helps you respond to a IssuingPurchase authorization request
|
217
|
+
#
|
218
|
+
# ## Parameters (required):
|
219
|
+
# - status [string]: sub-issuer response to the authorization. ex: 'approved' or 'denied'
|
220
|
+
#
|
221
|
+
# ## Parameters (conditionally required):
|
222
|
+
# - reason [string]: denial reason. Options: 'other', 'blocked', 'lostCard', 'stolenCard', 'invalidPin', 'invalidCard', 'cardExpired', 'issuerError', 'concurrency', 'standInDenial', 'subIssuerError', 'invalidPurpose', 'invalidZipCode', 'invalidWalletId', 'inconsistentCard', 'settlementFailed', 'cardRuleMismatch', 'invalidExpiration', 'prepaidInstallment', 'holderRuleMismatch', 'insufficientBalance', 'tooManyTransactions', 'invalidSecurityCode', 'invalidPaymentMethod', 'confirmationDeadline', 'withdrawalAmountLimit', 'insufficientCardLimit', 'insufficientHolderLimit'
|
223
|
+
#
|
224
|
+
# # ## Parameters (optional):
|
225
|
+
# - amount [integer, default nil]: amount in cents that was authorized. ex: 1234 (= R$ 12.34)
|
226
|
+
# - tags [list of strings, default nil]: tags to filter retrieved object. ex: ['tony', 'stark']
|
227
|
+
#
|
228
|
+
# ## Return:
|
229
|
+
# - Dumped JSON string that must be returned to us on the IssuingPurchase request
|
230
|
+
def self.response(
|
231
|
+
status:, reason:, amount:, tags:
|
232
|
+
)
|
233
|
+
params = {
|
234
|
+
'status': status,
|
235
|
+
'reason': reason,
|
236
|
+
'amount': amount,
|
237
|
+
'tags': tags
|
238
|
+
}
|
239
|
+
|
240
|
+
params.to_json
|
241
|
+
end
|
242
|
+
|
172
243
|
def self.resource
|
173
244
|
{
|
174
245
|
resource_name: 'IssuingPurchase',
|
@@ -178,6 +249,7 @@ module StarkInfra
|
|
178
249
|
holder_name: json['holder_name'],
|
179
250
|
card_id: json['card_id'],
|
180
251
|
card_ending: json['card_ending'],
|
252
|
+
purpose: json['purpose'],
|
181
253
|
amount: json['amount'],
|
182
254
|
tax: json['tax'],
|
183
255
|
issuer_amount: json['issuer_amount'],
|
@@ -195,12 +267,16 @@ module StarkInfra
|
|
195
267
|
wallet_id: json['wallet_id'],
|
196
268
|
method_code: json['method_code'],
|
197
269
|
score: json['score'],
|
198
|
-
issuing_transaction_ids: json['issuing_transaction_ids'],
|
199
270
|
end_to_end_id: json['end_to_end_id'],
|
200
|
-
status: json['status'],
|
201
271
|
tags: json['tags'],
|
272
|
+
zip_code: json['zip_code'],
|
273
|
+
issuing_transaction_ids: json['issuing_transaction_ids'],
|
274
|
+
status: json['status'],
|
202
275
|
updated: json['updated'],
|
203
|
-
created: json['created']
|
276
|
+
created: json['created'],
|
277
|
+
is_partial_allowed: json['is_partial_allowed'],
|
278
|
+
card_tags: json['card_tags'],
|
279
|
+
holder_tags: json['holder_tags']
|
204
280
|
)
|
205
281
|
}
|
206
282
|
}
|
data/lib/issuingpurchase/log.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative('../utils/resource')
|
4
3
|
require_relative('../utils/rest')
|
5
4
|
require_relative('../utils/checks')
|
6
5
|
require_relative('issuingpurchase')
|
6
|
+
require_relative('../utils/resource')
|
7
7
|
|
8
8
|
module StarkInfra
|
9
9
|
class IssuingPurchase
|
@@ -84,7 +84,7 @@ module StarkInfra
|
|
84
84
|
# ## Parameters (optional):
|
85
85
|
# - cursor [string, default nil]: cursor returned on the previous page function call
|
86
86
|
# - ids [list of strings, default nil]: list of IssuingPurchase ids to filter logs. ex: ['5656565656565656', '4545454545454545']
|
87
|
-
# - limit [integer, default
|
87
|
+
# - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex: 35
|
88
88
|
# - after [Date or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
89
89
|
# - before [Date or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
90
90
|
# - types [list of strings, default nil]: filter for log event types. ex: ['approved', 'canceled', 'confirmed', 'denied', 'reversed', 'voided']
|