class Rubyrave::Client
Constants
- RAVE_LIVE_URL
- RAVE_SANDBOX_URL
Attributes
Public Class Methods
# File lib/rubyrave/client.rb, line 14 def initialize(public_key, secret_key, pbfpubkey, mode = "test", payment_method = 'sas', http_timeout = 25) self.public_key = public_key self.secret_key = secret_key self.pbfpubkey = pbfpubkey self.http_timeout = http_timeout self.mode = mode if mode == "test" self.class.base_uri RAVE_SANDBOX_URL else self.class.base_uri RAVE_LIVE_URL end end
Public Instance Methods
# File lib/rubyrave/client.rb, line 77 def checksum(payload) payload.sort_by { |k,v| k.to_s } hashed_payload = '' family.each { |k,v| hashed_payload << v } return Digest::SHA256.hexdigest(hashed_payload + self.secret_key) end
# File lib/rubyrave/client.rb, line 90 def direct_charge(client_data) payload = { "PBFPubKey": self.pbfpubkey, "client": client_data, "alg": "3DES-24" } perform_post('flwv3-pug/getpaidx/api/charge', payload) end
# File lib/rubyrave/client.rb, line 59 def encrypt(key, data) cipher = OpenSSL::Cipher::Cipher.new(“des3”) cipher.encrypt # Call this before setting key or iv cipher.key = key ciphertext = cipher.update(data) ciphertext << cipher.final return Base64.encode64(ciphertext) end
# File lib/rubyrave/client.rb, line 68 def get_key(stuff) hash = Digest::MD5.hexdigest("this is a test") last_twelve = hash[hash.length-13..hash.length-1] private_secret_key = self.secret_key private_secret_key['FLWSECK-'] = '' first_twelve = private_secret_key[0..11] return first_twelve + last_twelve end
# File lib/rubyrave/client.rb, line 86 def list_banks() perform_get('flwv3-pug/getpaidx/api/flwpbf-banks.js', {:json => 1}) end
# File lib/rubyrave/client.rb, line 99 def perform_get(endpoint, params = {}) http_params = {} unless params.empty? http_params[:query] = params end unless self.http_timeout.nil? http_params[:timeout] = self.http_timeout end self.class.get("/#{endpoint}", http_params) end
# File lib/rubyrave/client.rb, line 110 def perform_post(endpoint, data) self.class.post(endpoint, { :body => data.to_json, :headers => { 'Content-Type' => 'application/json', 'Accept' => 'application/json'} }) end
Functions to have
-
initialize() pass live or test keys to this function. DONE
-
SetMode() switch between live mode and test mode. DONE
-
Encrypt3DES() performs 3DES encryption on key and payload DONE
-
getKey() This generates the key using the secret key DONE
-
DirectCharge() required param is client, the rest is in the library DONE
-
ValidateCardCharge() transacionReference and OTP required
-
ValidateAccountCharge() same as above
-
VerifyTransaction() flw_ref, seckey, normalize=1 required tx_ref optional
-
VerifyTransactionXrequery() flw_ref, seckey, tx_ref, last_attemp, only_successful
-
ListBanks() DONE
-
ConversionRate() requires seckey origin_currency destination_currency optional amount
-
StopRecurringPayment() id of recurring payment and seckey
-
ListRecurringTransactions() seckey only
-
ListSingleRecurringPayment() seckey tx_id
-
PreautorizeCard() client seckey alg
-
CapturePayment() seckey ref
-
RefundPayment() seckey ref action=refund
-
VoidPayment() seckey ref action=void
-
ChargeWithToken() long list of body params
-
SetPaymentMethod()
-
CreateIntegrityChecksum() DONE
# File lib/rubyrave/client.rb, line 51 def set_mode(mode) self.mode = mode end
# File lib/rubyrave/client.rb, line 55 def set_payment_method(payment_meethod) self.payment_method = payment_method end