PayPal™ SDK for .NET

The download includes the PayPal SDK .dll file to reference in your project, as well as a Visual Studio project for this complete demo site.

To run this demo on your local machine, unzip the download and open the Visual Studio solution in the PayPalSdkMvcDemo folder.

In your project, add a reference to the "Encore.PayPal.dll" file.

Add the "encore.PayPal" config section to your web.config file, and set the environment, username, password, and signature attributes. If you are also using Adaptive Payments, set the sandboxEmailAddress and applicationId attributes. Here is an example:

<configuration>
  <configSections>
      <section name="encore.PayPal" type="Encore.PayPal.SdkConfig, Encore.PayPal" requirePermission="false"/>
  </configSections>
  <encore.PayPal
      environment="(Live or Sandbox)"
      username="(Your PayPal API username)"
      password="(Your PayPal API password)"
      signature="(Your PayPal API signature)"
      sandboxEmailAddress="(Your PayPal Sanbox email address--for testing Adaptive Payments)"
      applicationId="(Your Adaptive Payments Application ID)">
  </encore.PayPal>
...
                                    

Here is a complete list of optional configuration properties. They are already defaulted to the values shown here, and it is neither necessary, nor recommended to include them unless you need to override the default.

<encore.PayPal
    environment="Live"
    version="124.0" 
    apVersion="1.2.0"
    specifyApVersion="false"
    aaVersion="1.8.7"
    specifyAaVersion="false"
    wppSignatureEndpoint="https://api-3t.paypal.com/2.0/"
    wppCertificateEndpoint="https://api.paypal.com/2.0/"
    adaptivePaymentsEndpoint="https://svcs.paypal.com/AdaptivePayments/"
    adaptiveAccountsEndpoint="https://svcs.paypal.com/AdaptiveAccounts/"
    permissionsEndpoint="https://svcs.paypal.com/Permissions/"
    paypalUrl="https://www.paypal.com/"
    delegateClass=""
    delegateMethod=""
    useCertificate="false"
    useEncryption="false"
    encryptionKey=""
    userName=""
    password=""
    signature=""
    subject=""
    sandboxEmailAddress=""
    applicationId=""
    keyPassword=""
    certificate=""
    country="US" 
    currency="USD"
    locale="US"
    disableGlobalization="true"
    returnFmfDetails="false"                                  
    shippingMethod="Download">
</encore.PayPal>
                                    

Verify that your project is targeting .NET 4.5.1 or later. Upgrade the project if necessary.

Remove the projet reference to the old "Encore.PayPal.dll" file, and add a reference to the new "Encore.PayPal.dll" file.

Remove the "licensedTo" and "licenseKey" attributes from the "encore.PayPal" section of your web.config file. A license is no longer required for this library.

API request properties like ReturnPage and CancelPage used in Express Checkout have been renamed to ReturnUrl and CancelUrl to better reflect their compatibility with MVC as well as Web Forms. You must change your code accordingly.

This means that Website Payments Pro is not enabled for your account. You need to accept the billing agreement, or contact PayPal customer service to have your account configured correctly.

This means something is incorrect with your API credentials. Usually this is because you are attempting to use Live credentials in the Sandbox, or Sandbox credentials in the Live environment.

It could be an invalid password or signature (make sure there are no extra spaces if you copy/pasted from your PayPal account page).

SdkAddressVerify returns the status of a PayPal account address, including street and zip code match results. (requires special permission)

SdkBillingAgreementUpdate updates or deletes a billing agreement.

SdkBillOutstandingAmount bills any balance due on a recurring payments profile.

SdkCreateBillingAgreement returns a billing agreement ID that may be used to make reference transactions against a PayPal account. (undocumented, needs special permission)

SdkCreateRecurringPaymentsProfile creates a recurring payments profile allowing automatic periodic billing.

SdkDoAuthorization is your request to authorize a customer order that can be fulfilled within 29 days.

SdkDoCapture is your request to completely or partially settle an order, an authorization, or reauthorization.

SdkDoDirectPayment charges or authorizes a credit card.

SdkDoExpressCheckoutPayment obtains payment through Express Checkout for a final sale or requests authorization for later capture of payment.

SdkDoNonReferencedCredit makes a non-referenced credit to a customer’s credit card.

SdkDoReauthorization reauthorizes a previously authorized a transaction and that has passed its settlement period.

SdkDoReferenceTransaction makes a payment based on the information provided in a previous Direct Payment, avoiding the need to provide any buyer information.

SdkDoVoid voids an order or an authorization.

SdkGetBalance returns the PayPal account balance of the account whose API credentials are used for the call.

SdkGetBillingAgreementCustomerDetails returns information about the customer, including name and address on file with PayPal.

SdkGetExpressCheckoutDetails returns information about the customer, including name and address on file with PayPal.

SdkGetRecurringPaymentsProfileDetails

returns the details of a recurring payments profile.

SdkGetTransactionDetails gets details about a transaction.

SdkManagePendingTransactionStatus accepts or denies a pending transaction. (undocumented, untested, needs special permission)

SdkManageRecurringPaymentsProfileStatus allows a recurring payment profile to be cancelled, suspended, or reactivated.

SdkMassPay processes payments en masse to up to 250 different recipients.

SdkPay Use the Pay API operation to transfer funds from a sender’s PayPal account to one or more receivers’ PayPal accounts. You can use the Pay API operation to make simple payments, chained payments, or parallel payments; these payments can be explicitly approved, preapproved, or implicitly approved.

SdkPaymentDetails Use the PaymentDetails API operation to obtain information about a payment. You can identify the payment by your tracking ID, the PayPal transaction ID in an IPN message, or the pay key associated with the payment

SdkPreapproval Use the Preapproval API operation to set up an agreement between yourself and a sender for making payments on the sender’s behalf.

SdkPreapprovalDetails Use the PreapprovalDetails API operation to obtain information about an agreement between you and a sender for making payments on the sender’s behalf.

SdkRefund The Refund API operation refunds all or part of a payment.

SdkRefundTransaction refunds a payment.

SdkSetCustomerBillingAgreement indicates to PayPal that you are using Express Checkout to create billing agreements for your customer.

SdkSetExpressCheckout indicates to PayPal that you are using Express Checkout to obtain payment from your customer.

SdkTransactionSearch searches transaction history.

SdkUpdateRecurringPaymentsProfile allows modification of the terms of a recurring payments profile.

Special Classes, Constants, and Binding Sources are provided to simplify building your payment solution.

SdkCredentialsDelegate The developer can define a function that takes no parameters and has return type SdkCredentials, and then pass that function to any API call instead of setting credentials individually. This can increase security by passing the API credentials from an encrypted store of the developer’s choice. The delegate function may also be declared in the application’s configuration file to make this a global setting.

SdkConfig is a static class that returns all properties defined in the encore.PayPal configuration section of the application’s configuration file. Default values are returned for any property not set in the configuration file.

SdkGetTransactionDetailsResponse.BindingSource returns a single transaction details record in the form of a Collection that allows binding directly as the data source for a FormView or DetailsView object.

SdkMonthCodeType encapsulates a list of calendar month constants, including integer value, short name, and long name. Includes a BindingSource property to allow binding directly to DropDownList objects, and a Get() member to allow binding to an ObjectDataSource.

SdkYearCodeType encapsulates a list of calendar year constants from the current year through current year plus eleven. Includes a BindingSource property to allow binding directly to DropDownList objects, and a Get() member to allow binding to an ObjectDataSource.

SdkStateCodeType encapsulates a list of states and provinces, including name and two-character code. Includes a BindingSource property to allow binding directly to DropDownList objects, and a Get() member to allow binding to an ObjectDataSource.

SdkCountryCodeType encapsulates a list of countries, including name and two-character code. Includes a BindingSource property to allow binding directly to DropDownList objects, and a Get() member to allow binding to an ObjectDataSource.

SdkLocaleCodeType encapsulates a list of countries for which PayPal Express Checkout pages include culture settings. Includes name and two-character code, a BindingSource property to allow binding directly to DropDownList objects, and a Get() member to allow binding to an ObjectDataSource.

SdkCreditCardTypeType encapsulates a list of credit card types accepted by PayPal. Includes a BindingSource property to allow binding directly to DropDownList objects, and a Get() member to allow binding to an ObjectDataSource.

SdkCurrencyCodeType encapsulates a list of currencies accepted by PayPal, including name and three-character code. Includes a BindingSource property to allow binding directly to DropDownList objects, and a Get() member to allow binding to an ObjectDataSource.

SdkTraceExtension class captures the XML envelopes that comprise the raw API request and response data. This allows the developer to see exactly what data is sent to and received from the API – invaluable for troubleshooting.