简体   繁体   中英

Prestashop 3rd party payment integration

I am trying to implement a third party payment integration with prestashop. I have used the universepay module to get the basic payment module. However I need to know how to get the values of the cart items and amount so that I can pass this to my third party payment provider.In which file is this data available? can anyone help?

Refer to this hook list:

http://doc.prestashop.com/display/PS15/Hooks+in+PrestaShop+1.5

This is an (almost) complete list of available hooks in PrestaShop. If you need to find what hooks are executed at ann exact given moment (for example when you are redirected to order confirmation page), go to Hook.php class, search for exec() method, and then error_log($hook_name); . After yo know which hook you will be using, create a function in your module:

public function hook{HOOKNAME}($args){
   error_log(print_r($args, 1));
}

This way you will know what parameters are passed to you hook function. Most likely f you select some order-confimation related hook, you will have an order object passed down to you, which will have all the info about the order that you need.

If you are creating your own payment module to do this then as your module will extend PaymentModule you can then use the payment hook to get this information at the point when the list of payment buttons is being generated.

class MyPaymentModule extends PaymentModule {

  public function __construct() {
    $this->name = 'My Payment Module';
    ...
  }

  public function install() {
    return (bool)$this->registerHook('payment');
  }

  public function hookPayment( $aParams ) {
    $oCart = $aParams['cart'];
    $aProducts = $oCart->getProducts();
    ...
    $sHtmlPaymentButton = '<b>My Payment Module</b>';
    return $sHtmlPaymentButton;
  }
}

Obviously a lot of additional code and hard work would be required to turn this above code snippet into a working payment module but hopefully it gives the answer to your question and a good starting point for you.

Alternatively if you need this information for all payment modules on your shop then you can access the information from within the validateOrder function of the PaymentModule class, by using an override copy of this class file in your override/classes folder.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM