Last active
October 24, 2016 12:30
-
-
Save ikiugu/23fa36347266989ff7fd525471fc5973 to your computer and use it in GitHub Desktop.
PesaController
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Your implementation is missing a few things (I think) ...
- Where do you pass credentials?
- 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
The method 'order' works successfully and I can post a transaction to Pesapal, the second one (callback) does not work and each time I run it, I get nil. I am trying to query a transaction using the transaction reference and I keep getting nil on line 28