Project

nequi

0.0
The project is in a healthy, maintained state
Nequi gem provides a convenient way to integrate with Nequi payments systems for processing payments and other related operations.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

~> 2.8, >= 2.8.1
~> 0.21.0
~> 6.2
~> 3.18, >= 3.18.1
 Project Readme

Nequi

Nequi: Payments with Push Notification

Installation

  1. Get the keys for Nequi: Nequi Developer Portal
  2. Obtain a test phone number and download a testing application. This needs to be approved in the Slack channel; use the following link to join: Nequi Development Slack Channel

Gems and Configuration

Add the following gems to your Gemfile:

gem 'nequi'
gem 'dotenv-rails'

Then run:

bundle install

Create a .env file and add your keys to it:

PHONE=YourPhoneNumberHere
NEQUI_API_KEY=YourApiKeyHere
NEQUI_CLIENT_ID=YourClientIdHere
NEQUI_CLIENT_SECRET=YourClientSecretHere
NEQUI_AUTH_URI=https://oauth.sandbox.nequi.com/token
NEQUI_AUTH_GRANT_TYPE=client_credentials
NEQUI_API_BASE_PATH=https://api.sandbox.nequi.com/payments/v2
NEQUI_STATUS_PAYMENT=/-services-paymentservice-getstatuspayment
NEQUI_UNREGISTEREDPAYMENT_ENDPOINT=/-services-paymentservice-unregisteredpayment

Next, add the following code to your config/initializers/nequi.rb file:

Nequi.configure do |config|
  config.auth_uri = ENV['NEQUI_AUTH_URI']
  config.auth_grant_type = ENV['NEQUI_AUTH_GRANT_TYPE']
  config.client_id = ENV['NEQUI_CLIENT_ID']
  config.client_secret = ENV['NEQUI_CLIENT_SECRET']
  config.api_base_path = ENV['NEQUI_API_BASE_PATH']
  config.api_key = ENV['NEQUI_API_KEY']
  config.unregisteredpayment_endpoint = ENV['NEQUI_UNREGISTEREDPAYMENT_ENDPOINT']
  config.nequi_status_payment = ENV['NEQUI_STATUS_PAYMENT']
  config.phone = ENV['PHONE']
end
  bundle exec sidekiq

Usage

In your controller, you can use the following code to create a payment:

  def create
    logs = Nequi.payment_request(params[:amount].to_i.to_s, params[:phone], params[:product_id])

    if logs[:status] == 200 && logs[:api_status] == '0'
      redirect_to payment_request_path(id: 1), {message: "Pay in nequi"}
    else
      redirect_to root_path, {message: "Payment request Error #{logs[:message]}"}
    end
  end

License

This gem is available as open-source under the terms of the MIT License.