New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

mp_api

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mp_api

  • 1.2.2
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

MpApi

Wrapper de integração com a API do Mercado Pago.

Documentação API Mercado Pago

Funcionalidades:

  • Criar pagamentos Pix ou cartão de crédito
  • Gerar token único para um cartão de crédito
  • Atualizar e encontrar pagamentos pelo ID
  • Buscar bandeira do cartão a partir dos seis primeiros digitos

Instalação

Adicionar mp_api no Gemfile:

gem 'mp_api'

ou

bundle add mp_api

Instalar a gem:

bin/rails generate mp_api:install

Uso

Configurar access_token no initializer ou direto no código:

MpApi.configure do |config|
  config.access_token = "ACCESS_TOKEN"
end

Exemplos de criação de pagamento

Cartão de crédito
# Criação de um token para cartão teste
token = MpApi::Token.new(
  card_number: "5031433215406351",
  expiration_year: "2025",
  expiration_month: "11",
  security_code: "123",
  cardholder_name: "APRO"
).create
puts token.id # c8ad2335a9bb58e585a8c35bfd9f29ad

# Encontra o ID e a bandeira do cartão
payment_method = MpApi::PaymentMethod.find_by_first_six_digits("503143")
puts payment_method.payment_method_id # "master"

# Criação do pagamento
payment = MpApi::Payment.new(
  amount: 140.0,
  payment_method: payment_method.payment_method_id,
  payer_email: "email@example.com",
  payer_identification_type: "CPF",
  payer_identification_number: "12345678909",
  token: token.id,
  issuer_id: payment_method.issuer_id,
  installments: 1,
  three_d_secure_mode: true
).create

puts payment.id # 1318474186
puts payment.status # "approved"
Pix
# Criação do pagamento
payment = MpApi::Payment.new(
  payer_email: "email@example.com",
  payer_identification_type: "CPF",
  payer_identification_number: "12345678909",
  payment_method: "pix",
  amount: 140.0
).create
puts payment.id # 1318474264
puts payment.status # "pending"

FAQs

Package last updated on 14 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc