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 basically 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>
ParametersDescription
PAYPAL_REDIRECT_URL set redirect URL for sandbox or live.
Return_UrlSet your website URL here
Cancel_UrlIf 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 TypeParametrs
stringReturnURL
stringCancelURL
stringBuyerEmail
stringReqConfirmShipping
stringInsuranceTotal
stringShippingTotal
stringHandlingTotal
stringTaxTotal
stringItemDescription
  • Create instance of AddressType.
  • Pass following parameter in AddressType instance
Data TypeParametrs
stringName
stringStreet1
stringStreet2
stringCityName
stringStateOrProvince
stringCountry
stringPostalCode
stringPhone
  • Now Create instance of PaymentDetailsItemType.
  • Pass following parameter in declared instance.
Data TypeParametrs
stringName
stringAmount
stringQuantity
stringItemCategory
PaymentDetailsItemTypeTax
doubleorderTotal
stringBillingTypeeg. Default value is (RECURRINGPAYMENTS)
BillingAgreementDetailsTypeBillingAgreementDescription

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 TypeParametrs
stringToken
stringPayerID
PaymentActionCodeTypePaymentAction

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 TypeParametrs
stringToken
stringTransactionID
BasicAmountTypeAmount
CurrencyCodeTypecurrencyCode

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 TypeParametrs
stringAuthorizationID(Pass transcation Id here)
stringAmount
BasicAmountTypecurrencyCode

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 TypeParametrs
stringStartDate
stringEndDate
stringstatuseg. (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 TypeParametrs
stringAuthorizationID(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 TypeParametrs
stringAuthorizationID(Pass transcation Id here)
stringAmount
BasicAmountTypecurrencyCode

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 TypeParametrs
stringToken
BasicAmountTypecurrencyCode
AutoBillTypeAutoBillOutstandingAmount
BillingPeriodTypeperiod

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

  • TransactionID
  • ProfileID
  • ProfileStatus