Creating payment plugins¶
In order to create a plugin for a payment broker, first you need to
write a subclass of
and place it in
processor.py in your app.
The only method you have to provide is
that needs to return a
HttpResponse subclass (eg. HttpResponseRedirect or TemplateResponse).
The use of all other methods depends directly on how the paywall operates.
To make your plugin available for the rest of the framework, you need to register it.
The most convenient way to do so is
from django.apps import AppConfig class MyPluginAppConfig(AppConfig): name = "getpaid_myplugin" verbose_name = "Some payment broker" def ready(self): from getpaid.registry import registry registry.register(self.module)
This way your plugin will be automatically registered after adding it to
Base URL of production environment.
Base URL of sandbox environment.
The name of the provider for the
List of accepted currency codes (ISO 4217).
Logo URL - can be used in templates.
List of potentially successful HTTP status codes returned by paywall when creating payment
For friendly urls
get_our_baseurl(request: django.http.request.HttpRequest = None, **kwargs) → str¶
Little helper function to get base url for our site. Note that this way ‘https’ is enforced on production environment.
prepare_form_data(post_data: dict, **kwargs) → Mapping[str, Any]¶
If backend support several modes of operation, POST should probably additionally calculate some sort of signature based on passed data.
get_form(post_data: dict, **kwargs) → django.forms.forms.BaseForm¶
(Optional) Used to get POST form for backends that use such flow.
prepare_transaction(request: django.http.request.HttpRequest, view: Optional[django.views.generic.base.View] = None, **kwargs) → django.http.response.HttpResponse¶
Prepare Response for the view asking to prepare transaction.
This method handles the callback from paywall for the purpose of asynchronously updating the payment status in our system.
HttpResponse instance that will be presented as answer to the callback.
fetch_payment_status(**kwargs) → getpaid.types.PaymentStatusResponse¶
Logic for checking payment status with paywall.
charge(amount: Union[decimal.Decimal, float, int, None] = None, **kwargs) → getpaid.types.ChargeResponse¶
(Optional) Check if payment can be locked and call processor’s method. This method is used eg. in flows that pre-authorize payment during order placement and charge money later.
release_lock(**kwargs) → decimal.Decimal¶
(Optional) Release locked payment. This can happen if pre-authorized payment cannot be fullfilled (eg. the ordered product is no longer available for some reason). Returns released amount.
start_refund(amount: Union[decimal.Decimal, float, int, None] = None, **kwargs) → decimal.Decimal¶
Refunds the given amount.
Returns the amount that is refunded.
cancel_refund(**kwargs) → bool¶
Cancels started refund.
Returns True/False if the cancel succeeded.