Integration with PrestaShop original Paypal module
This section describe how to integrate PrestaShop Paypal module with Agile prepaid credit/tokens module 1.5.0.5 above . (PrestaShop 1.5x or above)
If you have installed Agile prepard token/credit module at normal checkout or combination checkout mode, and you also use PrestaShop orginal Paypal module, you may need to make some small changes to integrate the 2 modules to work together properly. Because this change cannot be implemented in a normal override way, so we have to add some code to PrestaShop Paypal module,
If you are using PrestaShop original Paypal module(Version 3.7.1 or above confirmed), please make following changes to integration with this module
FIle: /modules/paypal/express_checkout/process.php
Location: Add following code at end of method function setDiscountsList
///Agile Code Begin- integrattion with Aigle prepaid token/credit module
if(Module::isInstalled('agileprepaidcredit'))
{
require_once(_PS_ROOT_DIR_ . "/modules/agileprepaidcredit/agileprepaidcredit.php");
$tokens_used_in_cart = AgilePrepaidCredit::tokens_used_in_cart($this->context->cart->id);
if($tokens_used_in_cart >0)
{
$tokens_value = AgilePrepaidCredit::ConvertTokens2Price($tokens_used_in_cart, $this->context->cart->id_currency);
$fields['L_PAYMENTREQUEST_0_NUMBER'.++$index] = 0;
$fields['L_PAYMENTREQUEST_0_NAME'.$index] = $this->l('Tokens/Credit');
/* It is a discount so we store a negative value */
$fields['L_PAYMENTREQUEST_0_AMT'.$index] = - 1 * Tools::ps_round($tokens_value, $this->decimals);
$fields['L_PAYMENTREQUEST_0_QTY'.$index] = 1;
$total = Tools::ps_round($total + $fields['L_PAYMENTREQUEST_0_AMT'.$index], $this->decimals);
}
}
///Agile Code End- integrattion with Aigle prepaid token/credit module