I have found an interested comment in Trello about Advanced Payment API in Prestashop and want to share it with our readers.
Standard payment modules in PrestaShop register the displayPayment
hook and return HTML from this hook, which makes it very hard to keep only one “Order Confirmation” button on the last page of the checkout.
In order to be compliant with the stricter of EU regulations, a new, parallel payment API was introduced, called Advanced Payment API.
Payment modules complying with the Advanced Payment API register the advancedPaymentOptions
hook.
From the advancedPaymentOptions
hook, modules MUST RETURN an ARRAY of zero, one, or more instances of Core_Business_Payment_PaymentOption
:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
class Core_Business_Payment_PaymentOption { // what will be displayed in the list of payment options during checkout private $callToActionText; // an URL for a picture to display private $logo; // the URL that should be called to process the actual payment once the customer has confirmed the order private $action; // the HTTP verb to use for the request to $action, implementations // must assume GET if unspecified private $method; // an associative array of parameters that need to be sent to the $action URL, // either as form variables if $method is POST, or as URL parameters if $method is GET private $inputs; // custom HTML - this should not be implemented at the moment private $form; // the name of the module that returned this option private $moduleName; // getters and setters omitted for brevity } |
Ecommerce Development
Take your online store to the next level with BelVG ecommerce development
Visit the pageWhen checking out an order, if the PS_ADVANCED_PAYMENT_API
configuration value is set, the PrestaShop core MUST only use payment methods from advancedPaymentOptions
and not even call displayPayment
.
When checking out an order, if the PS_ADVANCED_PAYMENT_API
configuration value is set, there must be on the last step of the checkout process:
- a list of available payment options that can be selected but do NOT trigger an action by the simple fact of being selected
- only ONE button that confirms the order (disabled unless the T&C checkbox is checked)
When PS_ADVANCED_PAYMENT_API
is disabled, the old process is used, and ONLY the displayPayment
hook is called.
Please do not implement the $form option, which is a bit flaky and might be removed from the API.
Looking for an experienced PrestaShop development partner? Turn to BelVG!