mp_api 2.2.0 → 2.3.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/mp_api/client.rb +12 -4
- data/lib/mp_api/item.rb +25 -0
- data/lib/mp_api/version.rb +1 -1
- metadata +8 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bd8aeefc7758768285d0eb089327721c340a8affec21ae421242a8cf2b161ce4
|
|
4
|
+
data.tar.gz: a8fcdb42276e6951dcdad15865bc88fff3e622f9a134c15a93841739ae0623e6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 10f58ee5bb49744cd78aa26b7940f703f891a0606d648774a6131875fd887d1bc00b8bbb9f2186e8ef6e445bc10855f0a60d31cc6773fcb66a2d69cdd47a1200
|
|
7
|
+
data.tar.gz: be2ae974b4713e68c24cf8af5b4f71e1f67031f50dfa18b0014cb08e5e5383724d69041348874efc55551a402ae817b36caa12f1a9a8afab31b9a99f013cd189
|
data/lib/mp_api/client.rb
CHANGED
|
@@ -4,7 +4,8 @@ module MpApi
|
|
|
4
4
|
MAX_RETRIES = 1
|
|
5
5
|
SAVE_RESPONSES = true
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
# @param items [Array<MpApi::Item>] Array de objetos Item contendo id, title, description, category_id, quantity, unit_price
|
|
8
|
+
def create_pix_payment(date_of_expiration: nil, amount:, description: nil, statement_descriptor: nil, payment_method:, payer_email:, payer_identification_type:, payer_identification_number:, external_reference: nil, items: [])
|
|
8
9
|
body = {
|
|
9
10
|
date_of_expiration: date_of_expiration,
|
|
10
11
|
transaction_amount: amount,
|
|
@@ -18,12 +19,16 @@ module MpApi
|
|
|
18
19
|
number: payer_identification_number
|
|
19
20
|
}
|
|
20
21
|
},
|
|
21
|
-
external_reference: external_reference
|
|
22
|
+
external_reference: external_reference,
|
|
23
|
+
additional_info: {
|
|
24
|
+
items: items.map(&:to_api_hash)
|
|
25
|
+
}
|
|
22
26
|
}.compact
|
|
23
27
|
post("/payments", body:)
|
|
24
28
|
end
|
|
25
29
|
|
|
26
|
-
|
|
30
|
+
# @param items [Array<MpApi::Item>] Array de objetos Item contendo id, title, description, category_id, quantity, unit_price
|
|
31
|
+
def create_credit_card_payment(date_of_expiration: nil, amount:, description: nil, statement_descriptor: nil, payment_method:, payer_email:, payer_identification_type:, payer_identification_number:, capture: nil, external_reference: nil, token: nil, issuer_id: nil, installments: nil, three_d_secure_mode: false, items: [])
|
|
27
32
|
body = {
|
|
28
33
|
date_of_expiration: date_of_expiration,
|
|
29
34
|
transaction_amount: amount,
|
|
@@ -42,7 +47,10 @@ module MpApi
|
|
|
42
47
|
token: token,
|
|
43
48
|
issuer_id: issuer_id,
|
|
44
49
|
installments: installments,
|
|
45
|
-
three_d_secure_mode: three_d_secure_mode ? "optional" : "not_supported"
|
|
50
|
+
three_d_secure_mode: three_d_secure_mode ? "optional" : "not_supported",
|
|
51
|
+
additional_info: {
|
|
52
|
+
items: items.map(&:to_api_hash)
|
|
53
|
+
}
|
|
46
54
|
}.compact
|
|
47
55
|
post("/payments", body:)
|
|
48
56
|
end
|
data/lib/mp_api/item.rb
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module MpApi
|
|
2
|
+
class Item
|
|
3
|
+
|
|
4
|
+
attr_reader :id, :title, :description, :category_id, :quantity, :unit_price
|
|
5
|
+
def initialize(id:, title:, description:, category_id: nil, quantity: nil, unit_price: nil)
|
|
6
|
+
@id = id
|
|
7
|
+
@title = title
|
|
8
|
+
@description = description
|
|
9
|
+
@category_id = category_id
|
|
10
|
+
@quantity = quantity
|
|
11
|
+
@unit_price = unit_price
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def to_api_hash
|
|
15
|
+
{
|
|
16
|
+
id: id,
|
|
17
|
+
title: title,
|
|
18
|
+
description: description,
|
|
19
|
+
category_id: category_id,
|
|
20
|
+
quantity: quantity,
|
|
21
|
+
unit_price: unit_price
|
|
22
|
+
}
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
data/lib/mp_api/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: mp_api
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Todas Essas Coisas
|
|
8
|
+
autorequire:
|
|
8
9
|
bindir: exe
|
|
9
10
|
cert_chain: []
|
|
10
|
-
date:
|
|
11
|
+
date: 2026-07-14 00:00:00.000000000 Z
|
|
11
12
|
dependencies:
|
|
12
13
|
- !ruby/object:Gem::Dependency
|
|
13
14
|
name: ac
|
|
@@ -23,6 +24,7 @@ dependencies:
|
|
|
23
24
|
- - ">="
|
|
24
25
|
- !ruby/object:Gem::Version
|
|
25
26
|
version: 1.1.0
|
|
27
|
+
description:
|
|
26
28
|
email:
|
|
27
29
|
- caioif4@gmail.com
|
|
28
30
|
executables: []
|
|
@@ -34,6 +36,7 @@ files:
|
|
|
34
36
|
- Rakefile
|
|
35
37
|
- lib/mp_api.rb
|
|
36
38
|
- lib/mp_api/client.rb
|
|
39
|
+
- lib/mp_api/item.rb
|
|
37
40
|
- lib/mp_api/version.rb
|
|
38
41
|
homepage: https://github.com/todasessascoisas/mp_api
|
|
39
42
|
licenses:
|
|
@@ -42,6 +45,7 @@ metadata:
|
|
|
42
45
|
homepage_uri: https://github.com/todasessascoisas/mp_api
|
|
43
46
|
source_code_uri: https://github.com/todasessascoisas/mp_api
|
|
44
47
|
changelog_uri: https://github.com/todasessascoisas/mp_api
|
|
48
|
+
post_install_message:
|
|
45
49
|
rdoc_options: []
|
|
46
50
|
require_paths:
|
|
47
51
|
- lib
|
|
@@ -56,7 +60,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
56
60
|
- !ruby/object:Gem::Version
|
|
57
61
|
version: '0'
|
|
58
62
|
requirements: []
|
|
59
|
-
rubygems_version: 3.
|
|
63
|
+
rubygems_version: 3.5.3
|
|
64
|
+
signing_key:
|
|
60
65
|
specification_version: 4
|
|
61
66
|
summary: ''
|
|
62
67
|
test_files: []
|