Integration of Paypal Payment with advanced Integration Method

PayPal is a secure Payment Gateway. It is most commonly used by most of the web developers. Any user can do shopping’s without any worry because it is trust able Payment gateway Site.It provide us PayPal SDK, PaPal DLL and also API.One user can transfer his money on internet through e-commerce website. PayPal will never share your secure information with anyone. It will never disclose your credit card, visa card etc details with anyone. If we take example of world-wide that who are using PayPal integration.

eg. Ebay.com , Flipcart.com , Godady.com etc

All above website are using PayPal integration with their transaction.

Now days developers or website owner are moving towards PayPal AIM(Advanced integration method).When you are Integrating PayPal with AIM that means you are Integrating Advance method of payment. It will authorize payments and it also provide facility of ARB. ARB is used for Recurring or subscription.

ARB : ARB (Automatic Recurring Billing) that means user can create subscription for weekly, monthly, 6 month ,Yearly also. ARB can be cancelled any time either by User (buyer) or merchant.

PayPal-AIM integration with C#

Follow the below steps to Integrate PayPal-AIM with your C# Project:-

Download Source Code

1. Go to your Manage NuGet Packages and add reference of following DLL:-

  • PayPalAPISample
  • PayPalCoreSDK
  • PayPalMerchantSDK
  • PayPalPermissonSDK

2. Configure your Web.config file for Paypal Integration in your <appSetting></appSetting> section

<appSettings>
<add key="PAYPAL_REDIRECT_URL" value="https://www.sandbox.paypal.com/webscr&amp;cmd="/>
<add key="Return_Url" value="http://localhost:1542/Payment/CreateOrder"/>
<add key="Cancel_Url" value="http://localhost:1542/Payment/CreateOrder"/>
</appSettings>
Parameters Description
PAYPAL_REDIRECT_URL set redirect URL for sandbox or live.
Return_Url Set your website URL here
Cancel_Url If some one cancel order on Paypal so set path to redirect user on your site.

3. Now third step is SetExpressCheckout

SetExpressCheckout is first PayPal method to Place buyer order. So set all required parameter which is demanded by PayPal specially Item details and Item amount.

  • Create instance of SetExpressCheckoutRequestDetailsType
  • Pass following parameters
Data Type Parametrs
string ReturnURL
string CancelURL
string BuyerEmail
string ReqConfirmShipping
string InsuranceTotal
string ShippingTotal
string HandlingTotal
string TaxTotal
string ItemDescription
  • Create instance of AddressType.
  • Pass following parameter in AddressType instance
Data Type Parametrs
string Name
string Street1
string Street2
string CityName
string StateOrProvince
string Country
string PostalCode
string Phone
  • Now Create instance of PaymentDetailsItemType.
  • Pass following parameter in declared instance.
Data Type Parametrs
string Name
string Amount
string Quantity
string ItemCategory
PaymentDetailsItemType Tax
double orderTotal
string BillingTypeeg. Default value is (RECURRINGPAYMENTS)
BillingAgreementDetailsType BillingAgreementDescription

After passing all parameters it will send you a Response

  1. payerId

4. DoExpressCheckout need to call after Success message of SetExpressCheckout and receiving payerId and token.

  • Create instance of GetExpressCheckoutDetailsReq
  • Pass token you have received in response
  • Pass payerid you have received in response
Data Type Parametrs
string Token
string PayerID
PaymentActionCodeType PaymentAction

After passing all parameters it will send you a Response

  1. TransactionId

5. DoAuthorized it will Authorized or Approve the payment so just you need to pass below parameters:-

Data Type Parametrs
string Token
string TransactionID
BasicAmountType Amount
CurrencyCodeType currencyCode

After passing all parameters it will send you a Response

  • PaymentStatus

6. DoCapture it will capture the payment from buyer accounts and to perform this you need to pass below parameters:-

Data Type Parametrs
string AuthorizationID(Pass transcation Id here)
string Amount
BasicAmountType currencyCode

After passing all parameters it will send you a Response

  • PaymentStatus
  • TransactionId

7. GetTransaction call GetTransaction class to get list of transaction from PayPal Gateway and to perform this you need to pass below parameters:-

Data Type Parametrs
string StartDate
string EndDate
string statuseg. (PENDING/SUCCESS)

After passing all parameters it will send you a List of Tranaction details according to your Query.

8. void transaction To cancel buyer transaction void transaction is used and to perform this you need to pass below parameters:-

Data Type Parametrs
string AuthorizationID(Pass transcation Id here)

After passing all parameters it will send you a Success Message with AuthorizationID.

9. Refund refund amount to buyer account Refund class is used and to perform this you need to pass below parameters:-

Data Type Parametrs
string AuthorizationID(Pass transcation Id here)
string Amount
BasicAmountType currencyCode

After passing all parameters it will send you arefundTransactionResponse.

10. ARB when user want to subscribe to Merchant service in that case ARB is implemented.

  • create instance of ARB class
  • call CreateRecurring method
  • pass following parametrs
Data Type Parametrs
string Token
BasicAmountType currencyCode
AutoBillType AutoBillOutstandingAmount
BillingPeriodType period

After passing all parameters it will send you following value in response:-

  • TransactionID
  • ProfileID
  • ProfileStatus