getPaypalVaultingByIdCustomer($idCustomer, $mode); if (is_object($paypalVaultingObject) == false || \Validate::isLoadedObject($paypalVaultingObject) == false) { $paypalVaultingObject = new \PaypalVaulting(); $paypalVaultingObject->id_customer = $idCustomer; $paypalVaultingObject->sandbox = (int)$mode; if ((int)$mode) { $profileKey = md5(\Configuration::get('PAYPAL_MB_SANDBOX_CLIENTID')); } else { $profileKey = md5(\Configuration::get('PAYPAL_MB_LIVE_CLIENTID')); } $paypalVaultingObject->profile_key = $profileKey; } $paypalVaultingObject->rememberedCards = $rememberedCards; try { return $paypalVaultingObject->save(); } catch (\Exception $e) { return false; } } /** * @param $idCustomer integer id of the Prestashop Customer object * @param $mode bool mode of the payment (sandbox or live) * @return string */ public function getRememberedCardsByIdCustomer($idCustomer, $mode = null) { if ($mode === null) { $mode = (int)\Configuration::get('PAYPAL_SANDBOX'); } $paypalVaultingObject = $this->getPaypalVaultingByIdCustomer($idCustomer, $mode); if (is_object($paypalVaultingObject) == false || \Validate::isLoadedObject($paypalVaultingObject) == false) { return ''; } return $paypalVaultingObject->rememberedCards; } /** * @param $idCustomer integer id of the Prestashop Customer object * @param $mode bool mode of the payment (sandbox or live) * @return \PaypalVaulting object or false */ public function getPaypalVaultingByIdCustomer($idCustomer, $mode = null) { if ($mode === null) { $mode = (int)\Configuration::get('PAYPAL_SANDBOX'); } if ((int)$mode) { $profileKey = md5(\Configuration::get('PAYPAL_MB_SANDBOX_CLIENTID')); } else { $profileKey = md5(\Configuration::get('PAYPAL_MB_LIVE_CLIENTID')); } $collection = new \PrestaShopCollection(\PaypalVaulting::class); $collection->where('id_customer', '=', (int)$idCustomer); $collection->where('sandbox', '=', (int)$mode); $collection->where('profile_key', '=', $profileKey); return $collection->getFirst(); } }