Payment Provider Integration App
By default UNA script has Payments app which is required to process payments. The app which will be used to sell something (for example, Market) should be integrated with Payments app. In this case Payments app undertakes everything related to payment processing while Market app should give products info in appropriate format and receive the notification about processed payments. It may be useful if something should be updated (generated) in module's database.
In the same time Payments app has a number of Payment Providers integrated by default. For example, PayPal, Stripe, ChargeBee, etc. Payment providers which are activated in Studio -> Payments app will be available to site members who want to sell something in Market or some other payments related apps. Each payment provider has it's own class in modules/boonex/payment/classes/
folder and some data in Payments app related database tables. So, if you're a developer and want to integrate some new payment provider in UNA you don't need to recreate the whole Payments app, but also you cannot simply put your payment provider PHP class in classes folder of Payments app. In this case you need to create your own standalone module which will integrate payment provider you are working with into default UNA's Payments app.
First of all you need to create a simple UNA module. You may read more about it here. By default you don't need to create pages, menus, etc inside your module, if the payment provider you're working with doesn't require them because of some specific circumstances or features. Then you need to create a special integration class and register your payment provider in Payments app database:
- Create a class following the Code Convention. The class should extends
BxBaseModPaymentProvider
base class and implementsiBxBaseModPaymentProvider
base interface. If you take a look atiBxBaseModPaymentProvider
interface you'll see that you need to realize three methodsinitializeCheckout
,finalizeCheckout
andfinalizedCheckout
:
initializeCheckout
- is called with Payments app before the payment process is handed over to payment provider itself. So, it's needed to prepare the data to be passed to the payment provider.finalizeCheckout
- is called when a response with data was received from the payment provider.finalizedCheckout
- is called in some cases when an intermediate response from the payment provider is received but final data will be received and processed automatically later. By default, this method is realized inBxBaseModPaymentProvider
parent class. If you don't need this specific functionality then you don't need to override the method in your class. For more details you may take a look atBxPaymentProviderPayPal
class (for single payments processing) andBxPaymentProviderStripe
class (for single and recurring payments processing) inmodule/boonex/payment/classes/
folder.
- To register your payment provider you need to add info about it in the following tables:
bx_payment_providers
andbx_payment_providers_options
.
bx_payment_providers
- one row should be added in this table. It contains information about the payment provider itself: unique name, title, options prefix, class name, class file, etc. In our case it's essential to fill in both class name and class file, that Payments app knows which class should be used to process payments from this payment provider and where exactly the class can be found. Use relative path from root directly of UNA script.bx_payment_providers_options
- this table is needed to describe a list of payment provider related options which should be filled in by seller (an owner of payment provider account). The number of options which will be added in this table is determined with the requirements of integrated payment provider. For more details you may take a look atinstall.sql
file inmodules/boonex/payment/install/sql/
folder. You may find registrations and options for all already integrated payment providers there.