Skip to content

Instantly share code, notes, and snippets.

@ikiugu
Last active October 24, 2016 12:30
Show Gist options
  • Save ikiugu/23fa36347266989ff7fd525471fc5973 to your computer and use it in GitHub Desktop.
Save ikiugu/23fa36347266989ff7fd525471fc5973 to your computer and use it in GitHub Desktop.
PesaController
def order
pesapal = Pesapal::Merchant.new(:development) #declare a variable
pesapal.order_details = { #pass the info to order_details array
:amount => params[:amount],
:description => params[:description],
:type => 'MERCHANT',
:reference => '808-808-606',
:first_name => 'first_name',
:last_name => 'last_name',
:email => '[email protected]',
:phonenumber => '+254722123456',
:currency => 'KES'
}
session[:pay_info] = pesapal.order_details
@order_url = pesapal.generate_order_url #generate the url
render 'pesapal'
end
def callback
#declare a variable
pesapal = Pesapal::Merchant.new(:development)
#@payment_status_array = session[:pay_info]
#@reference = @payment_status_array['reference']
#@payment_status = pesapal.query_payment_status("808-808-606")
render plain: pesapal.query_payment_status("AtM9FlNfOi").inspect
end
@itskingori
Copy link

Your implementation is missing a few things (I think) ...

  1. Where do you pass credentials?
  2. Where do you set the callback?

I mean something like this ...

pesapal.config = {
  callback_url: "YOUR_CALLBACK_URL",
  consumer_key: "SOME_KEY",
  consumer_secret: "SOME_SECRET"
}

I think either I don't understand your use-case or you misunderstand how Pesapal works. Please read this simplified step-by-step.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment