Sha256: 541b7df07aba284c0ed8f651ef718d758fd4d7c9fce8ee8c958a6bfbc334718f
Contents?: true
Size: 654 Bytes
Versions: 1
Compression:
Stored size: 654 Bytes
Contents
require 'uri' require 'net/http' require 'json' module Khalti class Verification API_URL = "https://khalti.com/api/payment/verify/" SECRET_KEY = ENV['KHALTI_SECRET_KEY'] def self.verify(token, amount) raise Errors::BlankError.new('Ensure token is not blank.') if token.nil? || token.strip.empty? raise Errors::InvalidTokenError.new('Ensure token has at least 22 characters.') if token.strip.size < 22 raise Errors::InvalidAmountError.new('Ensure amount is greate than 0 paisa.') if Integer(amount) < 0 params = {'token': token, 'amount': Integer(amount)} RequestHelper.post(API_URL, params) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
khalti-0.1.5 | lib/khalti/verification.rb |