Intelliwins Blog

Anything you wanna know about?

Paypal NVP API with and C#

by Admin 23. July 2014 16:34
Paypal has always play a major role in online payment scenario and e commerece .Paypal has provided various API and way of payment. In this article we will explore the use of NVP API of Paypal with and C#. Before we can start we need to remember few things. We need to create a Paypal merchant account. Then we need to create a API credential with paypal . There we can get API username, API password and API Signature.  Then download paypalfunction.cs file from following link Then place the file into App_Code folder and open the file in visual studio and replace the API username, API password and API signature with your API credentials. Then write down on the page where you want the payment   protected void btn_proceed_Click(object sender, EventArgs e)     {        NVPAPICaller test = new NVPAPICaller();        string retMsg = "";        string token = "";        Session["payment_amt"] = txt_cost.Text;        if (HttpContext.Current.Session["payment_amt"] != null)        {            string amt = HttpContext.Current.Session["payment_amt"].ToString();              bool ret = test.ShortcutExpressCheckout(amt, ref token, ref retMsg);                    if (ret)            {                HttpContext.Current.Session["token"] = token;                Response.Redirect(retMsg);            }            else            {                Response.Redirect("APIError.aspx?" + retMsg);            }        }        else        {            Response.Redirect("APIError.aspx?ErrorCode=AmtMissing");        } } Download the APIError.aspx and APIError.aspx.cs by clicking on the link This will redirect to paypal page where user need to enter his/her paypal credential of the account where he need to pay for the product.   Then there is a Confirmation page for the user. The URL of this confirmation page can be configured from the paypalfunction.cs file. Check return URL and change it In this page we have option to show user his final payment value and then shipping address. Also a button as pay after clicking on it the payment will be done through paypal. Codes under page_load to show final amount and shipping address.  protected void Page_Load(object sender, EventArgs e)     {            String PaymentOption = "PayPal";         if (PaymentOption == "PayPal")         {             NVPAPICaller test = new NVPAPICaller();               string retMsg = "";             string token = "";             string payerId = "";             string shippingAddress = "";             string amt = "";             token = Session["token"].ToString();               bool ret = test.GetShippingDetails(token, ref payerId, ref shippingAddress, ref retMsg,ref amt);             if (ret)             {                 Session["payerId"] = payerId;                 lbl_prc.Text = amt;                                 addrs.InnerHtml = shippingAddress;             }             else             {                 Response.Redirect("APIError.aspx?" + retMsg);             }         }     } Code Under Pay button to make the payment    protected void Button1_Click(object sender, EventArgs e)     {         String PaymentOption = "PayPal";         if (PaymentOption == "PayPal")         {             NVPAPICaller test = new NVPAPICaller();               string retMsg = "";             string token = "";             string finalPaymentAmount = "";             string PayerId = "";             NVPCodec decoder = new NVPCodec();               token = Session["token"].ToString();             PayerId = Session["payerId"].ToString();             finalPaymentAmount = Session["payment_amt"].ToString();               bool ret = test.ConfirmPayment(finalPaymentAmount, token, PayerId, ref decoder, ref retMsg);             if (ret)             {                 // Unique transaction ID of the payment. Note:  If the PaymentAction of the request was Authorization or Order, this value is your AuthorizationID for use with the Authorization & Capture APIs.                  string transactionId = decoder["PAYMENTINFO_0_TRANSACTIONID"];                   // The type of transaction Possible values: l  cart l  express-checkout                  string transactionType = decoder["PAYMENTINFO_0_TRANSACTIONTYPE"];                   // Indicates whether the payment is instant or delayed. Possible values: l  none l  echeck l  instant                  string paymentType = decoder["PAYMENTINFO_0_PAYMENTTYPE"];                   // Time/date stamp of payment                 string orderTime = decoder["PAYMENTINFO_0_ORDERTIME"];                   // The final amount charged, including any shipping and taxes from your Merchant Profile.                 string amt = decoder["PAYMENTINFO_0_AMT"];                   // A three-character currency code for one of the currencies listed in PayPay-Supported Transactional Currencies. Default: USD.                     string currencyCode = decoder["PAYMENTINFO_0_CURRENCYCODE"];                   // PayPal fee amount charged for the transaction                     string feeAmt = decoder["PAYMENTINFO_0_FEEAMT"];                   // Amount deposited in your PayPal account after a currency conversion.                     string settleAmt = decoder["PAYMENTINFO_0_SETTLEAMT"];                   // Tax charged on the transaction.                     string taxAmt = decoder["PAYMENTINFO_0_TAXAMT"];                   //' Exchange rate if a currency conversion occurred. Relevant only if your are billing in their non-primary currency. If                  string exchangeRate = decoder["PAYMENTINFO_0_EXCHANGERATE"];                 obj.upt_clint(token, transactionId);                 obj.save_trans(transactionId, transactionType, paymentType, orderTime, amt, feeAmt, settleAmt, taxAmt);                 //redirect to final thank you page after payment done                 Response.Redirect("thanks.aspx");             }             else             {                 Response.Redirect("APIError.aspx?" + retMsg);             }         }     }

Tags: , , , | Payment Gateway | Tips and tricks

Payzippy Payment Gateway Integration on C#

by Admin 1. November 2013 12:21
Well Payzippy is the newest star in the Indian payment gateway sky, Developed Flipkart One of the most popular and trusted e commerce portal of india. As flipkart is a very experienced e commerce portal they are very well versed with each and every pain and loopholes of indian payment gateway market and with this very lucrative launch offer it is a very viable solution for most of the websites.   Payzippy is providing the SDK for Java and PHP developer with supports for some very popular e commerce packages like Magento. But when it comes to other plat forms like , ROR, Django the SDK Development is still on progress, But we can use there Rest API to connect with there service. I have prepared a Demo plugin for it. You can download it from following URL   DownloadHappy Coding !!!!!

Tags: , ,

Payment Gateway

Brit Colony, Bhubaneswar,India +91 94384 80191 info@

About Us

Intelliwins mission is to alter the dynamics of the software industry by providing trusted, supportive and quality software development servies to clients that view our partnership as a strategic driver for their success.


Enter your email to join our mailing list