mp_api 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +72 -5
- data/lib/mp_api/version.rb +1 -1
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 14d24c337abe28eab714ae937b8cc427a8bfa7a6c63d1f97a3e81af62ce7c8ac
|
4
|
+
data.tar.gz: 32eeff608351f09cc4266392edef78cd60e6dbdbd5095b50034a79c8f1f4a5e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4e8c968cc02439b3e73f21e4269098744586aab0540ec339bce6e2a02c9a8a3f302f32eba0c2e15b672450d53f2205434795bc26f4e48a7ff3761075868ec15
|
7
|
+
data.tar.gz: 16ecb53202057e817de0d3a80085f4f83359cffdc0e242c7b9bc0d264de974253802859b8e420fb7b720dd9cafe942e93026b6eb057e600242e4a82c688ee3b7
|
data/README.md
CHANGED
@@ -1,19 +1,86 @@
|
|
1
1
|
# MpApi
|
2
2
|
|
3
|
-
|
3
|
+
Wrapper de integração com a API do Mercado Pago.
|
4
4
|
|
5
|
-
|
5
|
+
[Documentação API Mercado Pago](https://www.mercadopago.com.br/developers/pt/docs)
|
6
|
+
|
7
|
+
### Funcionalidades:
|
8
|
+
- Criar pagamentos Pix ou cartão de crédito
|
9
|
+
- Gerar token único para um cartão de crédito
|
10
|
+
- Atualizar e encontrar pagamentos pelo ID
|
11
|
+
- Buscar bandeira do cartão a partir dos seis primeiros digitos
|
12
|
+
|
13
|
+
## Instalação
|
14
|
+
|
15
|
+
Adicionar mp_api no Gemfile:
|
6
16
|
|
7
17
|
```ruby
|
8
18
|
gem 'mp_api'
|
9
19
|
```
|
20
|
+
ou
|
21
|
+
```shell
|
22
|
+
bundle add mp_api
|
23
|
+
```
|
10
24
|
|
11
|
-
|
25
|
+
Instalar a gem:
|
12
26
|
|
13
27
|
```shell
|
14
28
|
bin/rails generate mp_api:install
|
15
29
|
```
|
16
30
|
|
17
|
-
##
|
31
|
+
## Uso
|
32
|
+
|
33
|
+
Configurar access_token no initializer ou direto no código:
|
34
|
+
```ruby
|
35
|
+
MpApi.configure do |config|
|
36
|
+
config.access_token = "ACCESS_TOKEN"
|
37
|
+
end
|
38
|
+
```
|
18
39
|
|
19
|
-
|
40
|
+
### Exemplos de criação de pagamento
|
41
|
+
#### Cartão de crédito
|
42
|
+
```ruby
|
43
|
+
# Criação de um token para cartão teste
|
44
|
+
token = MpApi::Token.new(
|
45
|
+
card_number: "5031433215406351",
|
46
|
+
expiration_year: "2025",
|
47
|
+
expiration_month: "11",
|
48
|
+
security_code: "123",
|
49
|
+
cardholder_name: "APRO"
|
50
|
+
).create
|
51
|
+
puts token.id # c8ad2335a9bb58e585a8c35bfd9f29ad
|
52
|
+
|
53
|
+
# Encontra o ID e a bandeira do cartão
|
54
|
+
payment_method = MpApi::PaymentMethod.find_by_first_six_digits("503143")
|
55
|
+
puts payment_method.payment_method_id # "master"
|
56
|
+
|
57
|
+
# Criação do pagamento
|
58
|
+
payment = MpApi::Payment.new(
|
59
|
+
amount: 140.0,
|
60
|
+
payment_method: payment_method.payment_method_id,
|
61
|
+
payer_email: "email@example.com",
|
62
|
+
payer_identification_type: "CPF",
|
63
|
+
payer_identification_number: "12345678909",
|
64
|
+
token: token.id,
|
65
|
+
issuer_id: payment_method.issuer_id,
|
66
|
+
installments: 1,
|
67
|
+
three_d_secure_mode: true
|
68
|
+
).create
|
69
|
+
|
70
|
+
puts payment.id # 1318474186
|
71
|
+
puts payment.status # "approved"
|
72
|
+
```
|
73
|
+
|
74
|
+
#### Pix
|
75
|
+
```ruby
|
76
|
+
# Criação do pagamento
|
77
|
+
payment = MpApi::Payment.new(
|
78
|
+
payer_email: "email@example.com",
|
79
|
+
payer_identification_type: "CPF",
|
80
|
+
payer_identification_number: "12345678909",
|
81
|
+
payment_method: "pix",
|
82
|
+
amount: 140.0
|
83
|
+
).create
|
84
|
+
puts payment.id # 1318474264
|
85
|
+
puts payment.status # "pending"
|
86
|
+
```
|
data/lib/mp_api/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mp_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Todas Essas Coisas
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-06-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ac
|
@@ -43,13 +43,13 @@ files:
|
|
43
43
|
- lib/mp_api/payment_method.rb
|
44
44
|
- lib/mp_api/token.rb
|
45
45
|
- lib/mp_api/version.rb
|
46
|
-
homepage: https://github.com/
|
46
|
+
homepage: https://github.com/todasessascoisas/mp_api
|
47
47
|
licenses:
|
48
48
|
- MIT
|
49
49
|
metadata:
|
50
|
-
homepage_uri: https://github.com/
|
51
|
-
source_code_uri: https://github.com/
|
52
|
-
changelog_uri: https://github.com/
|
50
|
+
homepage_uri: https://github.com/todasessascoisas/mp_api
|
51
|
+
source_code_uri: https://github.com/todasessascoisas/mp_api
|
52
|
+
changelog_uri: https://github.com/todasessascoisas/mp_api
|
53
53
|
post_install_message:
|
54
54
|
rdoc_options: []
|
55
55
|
require_paths:
|
@@ -65,7 +65,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
65
65
|
- !ruby/object:Gem::Version
|
66
66
|
version: '0'
|
67
67
|
requirements: []
|
68
|
-
rubygems_version: 3.5.
|
68
|
+
rubygems_version: 3.5.9
|
69
69
|
signing_key:
|
70
70
|
specification_version: 4
|
71
71
|
summary: ''
|