Paypal Payment Transaction without navigation

Quick Inquiry


Client Speaks

Client Speaks - Testimonials for Aegis Software
You Are @ >> Home >> Articles >> Paypal Payment Transaction without navigation

Paypal Payment Transaction without navigation

The detailed research introduces how to use “PayPal payment transaction without navigation” using C# code. Today, PayPal is taken as most popular payment mode for online shopping. With this wonderful framework, money can be received or paid within seconds. This is the reason why online merchants are looking for suitable ways to integrate PayPal payment option with their online stores.

We have compiled this technical solution during one of our projects and it is working successfully with it. We are sure the solution will be helpful for programmers seeking for best possible ways to integrate PayPal payment option with their projects.

We are introducing how to use Paypal transaction API without navigation UI. We will simply get everything done by request/response using C# code. In this example, we will call DoDirectPayment method to do Direct Paypal payment Transaction using the API.

But before we are going to develop C# side code, we require some stuff on Paypal application too. So let's start with that first.

If you don't have a Paypal developer account then you need to create a new developers PayPal account by visiting and click the Sign Up Now button as shown below:

- Fill up your profile details and click on Agree and Continue button to register in Paypal Developer Account.


- After Successfully registration of a paypal developer Account you will be redirect on below page. Click on Application menu as on below page.


- Click on SandBox (Testing) Account as on below page. You will be redirect to your paypal sandbox profile page. Note that Sandbox account is for testing purpose for developers only. While dealing with real environment we need live accounts.


- Click on Profile Link to see your Profile details. You will get your profile details in Popup.


- Click on Upgrade to Pro Link as below to upgrade your paypal Sandbox Account from normal to Pro.


- Go to API credential tab in your in your Account details to see your API credential. You can see you API credential as below and you can use it in your DoDirectPayment method for transaction.


- Now go to your Application where you want use Payapal payment Integration to Do payment. - Download and Add two DLL given below in your application. Give a reference of it in references. log4net.dll and paypal_base.dll - Add a Class file with name PaypalTransaction.cs and Add below libraries.

using; using com.paypal.sdk.profiles; using com.paypal.sdk.util; using System.Configuration; using System.Collections; - Create a method with name DoDirectPayment use below code to do direct payment using Paypal. public static PaypalTransaction DoDirectPayment(string amount, string creditCardType, string creditCardNumber, string expdate_month, string cvv2Number, string firstName, string lastName,string email, string city, string state, string zip) { PaypalTransaction r = new PaypalTransaction(); try { NVPCallerServices caller = new NVPCallerServices(); IAPIProfile profile = ProfileFactory.createSignatureAPIProfile(); profile.APIUsername = "Your APIUsername";//PaypalAPIUsername; profile.APIPassword = "Your APIPasswod";//PaypalAPIPassword; profile.APISignature = "Your APISignature";// PaypalAPISignature; profile.Environment = "sandbox"; // This will change for real accounts. It should be set to "live" that time. caller.APIProfile = profile; NVPCodec encoder = new NVPCodec(); encoder["VERSION"] = "100.0"; encoder["METHOD"] = "DoDirectPayment"; // Add request-specific fields to the request. encoder["AMT"] = amount; encoder["CREDITCARDTYPE"] = creditCardType; encoder["ACCT"] = creditCardNumber; encoder["EXPDATE"] = expdate_month; encoder["CVV2"] = cvv2Number; encoder["FIRSTNAME"] = firstName; encoder["LASTNAME"] = lastName; encoder["IPADDRESS"] = ""; encoder["EMAIL"] = email; encoder["STREET"] = "Street 1"; encoder["CITY"] = city; encoder["STATE"] = state; encoder["ZIP"] = zip; encoder["COUNTRYCODE"] = "US"; encoder["CURRENCYCODE"] = "USD"; encoder["PAYMENTACTION"] = "Sale"; // Execute the API operation and obtain the response. string pStrrequestforNvp = encoder.Encode(); string pStresponsenvp = caller.Call(pStrrequestforNvp); NVPCodec decoder = new NVPCodec(); decoder.Decode(pStresponsenvp); r.TransactionStatus = decoder["ACK"]; if (r.IsTransactionSuccess) { r.Amount = decoder["AMT"]; r.CurrencyCode = decoder["CURRENCYCODE"]; r.TransactionId = decoder["TRANSACTIONID"]; r.CoRelationId = decoder["CORRELATIONID"]; r.TimeStamp = DateTime.Parse(decoder["TIMESTAMP"]); } else { r.Error = decoder["L_LONGMESSAGE0"]; r.ErrorCode = decoder["L_ERRORCODE0"]; } } catch { r = null; } return r; }

That's all.

You will get success or error code and message at the end to do further process. PaypalTransaction class can be your custom class to return required values. So you can customize it anyway you want.

Note : Payment will be deducted from your (testing) credit card not from Paypal Account in this case. For Paypal account deduction you need to use other method. It will be credited in your other Paypal account which credential you have used in method if transaction is successfull.

Same way you can use other methods like GetBalance, DoExpressCheckoutPayment, ... given in this API Explorer.

For the successful transaction, money will be deducted from your credit card not from your PayPal account and it will be added to other PayPal account as per given credentials. If you want that money should get deducted from your PayPal account then you have to make some changes in coding section. For more powerful solutions and practical approaches, stay tuned with us. We believe in sharing quality information that is useful for modern world and highly in demand.

For further information, mail us at

do not copy