Click here to Skip to main content
15,892,161 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
How can i redirect to my website or page after getting payment success or failure in mobile recharge API


What I have tried:

C#
Response.Redirect("http://www.mydomain.com/api/recharge.php?userid=76757123343434&pinno=2323232434343&number=" + txtmobileno.Text + "&operator=" + ddloperator.SelectedItem.Value + "&circle=" + ddlcircle.SelectedItem.Value + "&amount=" + txtamount.Text + "&usertx=YOUR_TRANSACTION_ID123345&format=Json&version=4 ", false);
Posted
Updated 28-Feb-17 3:04am
Comments
Richard Deeming 28-Feb-17 8:55am    
Read the documentation of whatever API you're using.

1 solution

hi chap, this code will work fine, but it has got some security flaws, as you can see your URL it contains &amount in query string. this is also visible to user. so user can easily change this on the go. it will be like user has paid 10 bucks and can get the recharge of 100 bucks.
Better to follow below approach.
Save the users recharge request in your DB and get the UniqueId to identify that request.
Check that bookingId is not processed earlier.

Now when payment is confirmed then redirect user to BookingConfirmation page with UniqueId
in query string. Now you can get the booking request from this uniqueId and call the API's BookingConfirmation method and update the bookingrequest as processed.
This will avoid the security flaw.

PaymentPage
C#
MakePayment(long bookingId)
{
//call payment confirmation
Response.Redirect("BookingConfirmation?bookingId"+bookingId);
}

BookingConfirmation page
C#
ConfirmBooking()
{
var bookingId = Request.QueryString["bookingId"];

var bookingRequest = GetBookingDetail(bookingId);

ThirdPatryAPI.bookingConfirm(bookingRequest.mobileNo,...);

//Redirect to your desired page here

}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900