We were struggling with PayUMoney integration with .Net code however steps are simple PayU provides API and documentation implementation. There are Couple of setting which is not in PayU documentation. You can use following document step by step complete process to set up your Payment gateway.
Here are the steps you need to follow to Integrated PayU with .NET (C#):
Create Pay now button in Your UI. These images below show example how we have done in our Application. You need to just change the connection string in your Case.
By clicking on “Pay Now” Application call PayNow() method
You have to write method like below. This method is provide by Paynow
Let me describe what parameter you will have to change in your case.
Note : The one in lined in yellow are input parameter you to pass PayU function. These parameter would be in same syntax as shown below however it would change for your payU account and code.
Let me again define the parameters.
- In most of the case when you are setting payment mechanism in your application these are the parameter you ask customer to fill. You have to pass these parameter to Pay you. You can find in case of our application we have used below parameter which are being passed to pay you to process payment.
UserName = labTest.PatientName;
Productprice = labTest.PayablePrice.ToString<strong>();</strong>
productInfo = "Lab Product Purchase Online";
Useremail = labTest.Email;
phoneNumber = 9134567892;
1var DomainName = Web.HttpContext.Current.Request.Url.Host;
This is for fetching the URL of application where application is hosted. In case your Application is hosted at www.abcd.com it will return abcd.
myremotepost.Add("surl", "http://" + DomainName);
Here it will input your Url as http://abcd.com
- All these three setting you will get from your PayU account.
<add key="MERCHANT_KEY" value="fB7m8s"/>
<add key="SALT" value="eRis5Chv"/>
<add key="PAYU_BASE_URL" value="https://test.payu.in/_payment"/>
Next step is to call PayNow() method
Please define PayUMoney Merchant key and SALT in your web config file like below.
Clicking on save executed PayNow() Method and redirected to User PayU login screen.
User need to fill payment details selecting payment method.
After payment user can see its transaction details on PuyUMoney.
Once payment is complete PayUMoney redirect to Retun() Method and read transactionId
Using the payment method returned by PayU you can keep track of transaction ID and show success or failure message in your UI.