Project

momo_pay

0.0
Low commit activity in last 3 years
No release in over a year
Documentation: https://developers.momo.vn
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 2.0
~> 10.0
~> 3.0
 Project Readme

API Caller for https://momo.vn

Installation

Add this line to your application's Gemfile:

gem 'momo_pay'

And then execute:

$ bundle

Or install it yourself as:

$ gem install momo_pay

Usage

Setup:

Add config/initializers/momo.rb file with content

MomoPay.setup do |config|
  config.domain = Rails.application.secrets.momo_domain
  config.public_key = Rails.application.secrets.momo_public_key
  config.secret_key = Rails.application.secrets.momo_secret_key
  config.partner_code = Rails.application.secrets.momo_partner_code
  config.partner_name = Rails.application.secrets.momo_partner_name
end

1. App-In-App:

Request to process transaction: detail from Momo

    response = MomoPay::Mobile.process(
      partnerRefId: order_number,
      amount: order_value,
      appData: momo_token_from_app,
      customerNumber: momo_phone_from_app
    )

=> Example response data

     {
       "status"=>0,
       "message"=>"Thành công",
       "amount"=>100000,
       "transid"=>"230.....289",
       "feeMoMo"=>0,
       "signature"=>"2ab844bc9ae52.....0d04d85aef836e9"
     }
  • How to verify response by HMAC-SHA256
    MomoPay::Signature.verify!(response)

It will raise MomoPay::SignatureError exception when response data is not verified!

Request to confirm transaction: detail from Momo

    response = MomoPay::Transaction.confirm(
      partnerRefId: order_number,
      momoTransId: transid_from_process_output,
    )

To be continued...