Create an offsite payment provider class

To create an offsite payment processor provider for the payment processor you must perform the following:

  1. Create a class to represent the payment processor provider. In the folder for your custom payment processor, add a new class item.
  2. Make the class public. Define the class to use the public access specifier.
  3. Implement IOffsitePaymentProcessorProvider.
    It extends the base IPaymentProcessorProvider and adds two additional methods.
    For information how to implement IPaymentProcessorProvider with all of his methods read the For developers: Create the payment processor provider
  4. Implement the following methods:
    • IPaymentResponse HandleOffsiteReturn(int orderNumber, HttpRequest request, PaymentMethod paymentMethod);
      Handles the offsite response after redirect back to our site.
    • IPaymentResponse HandleOffsiteNotification(int orderNumber, HttpRequest request, PaymentMethod paymentMethod);
      Handles the offsite notification send by them via asynchronous call. Usually, in PayPal this functionality is called IPN, in WorldPay it is payment response and etc.
      The methods are responsible for handing the offsite return which is when the offsite payment gateway redirects back to our site. The redirect is automatically handled by a handler on our site which then calls the HandleOffsiteReturn method. The request object passed there contains all the information which the offsite gateway has returned to us. The other method HandleOffsiteNotification is also invoked from the offsite gateway (if supported) but this call is made from their backend to our site to tell us the result of a transaction. This call is not visible on the client browser, it is direct call between them (PayPal IPN service for example) and our handler, which then invokes this method.
    • IPaymentResponse HandleOffsitePaymentExecution(int orderNumber, HttpRequest request, PaymentMethod paymentMethod);
      Handles the offsite payment execution in order to finish a payment. This method is responsible for making a call to the payment provider and completing the requested payment. Finally it updates the order information based on the payment response. 

Use the following code sample:

Notification and redirect URLs 

After you have implemented your provider class, depending on your custom provider, you may want to specify a return and redirect URL. You specify these in SubmitTransaction method. In this class, you can specify either of the following Sitefinity CMS properties:

  • GatewayNotificationUrl
    This property passes the URL where the payment processor sends information about the transaction status. Passing this property triggers the HandleOffsiteNotification method, described above.
  • GatewayRedirectSuccessUrl
    This property passes the URL where the payment processor redirects the user after a successful transaction. Passing this property triggers the HandleOffsiteReturnmethod, described above.

The way you pass the properies in the SubmitTransaction method is also specified in your payment provender documentation.

EXAMPLEpostValues.Add("notificationURL", data.GatewayNotificationUrl);

In the above example, notificationURL is a property specified by the payment provider.

Increase your Sitefinity skills by signing up for our free trainings. Get Sitefinity-certified at Progress Education Community to boost your credentials.

Get started with Integration Hub | Sitefinity Cloud | Sitefinity SaaS

This free lesson teaches administrators, marketers, and other business professionals how to use the Integration hub service to create automated workflows between Sitefinity and other business systems.

Web Security for Sitefinity Administrators

This free lesson teaches administrators the basics about protecting yor Sitefinity instance and its sites from external threats. Configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.

Foundations of Sitefinity ASP.NET Core Development

The free on-demand video course teaches developers how to use Sitefinity .NET Core and leverage its decoupled architecture and new way of coding against the platform.

Was this article helpful?