<?php
namespace Modules\RemoteData\CreditCardValidation; class Controller extends \App\Mvc\ControllerAbstract { protected function initialize() { parent::initialize(); $this->actionsCfg['CreditCardValidation'] = [ 'checkOption' => false, 'checkSection' => false ]; } protected function actionCreditCardValidation($R) { if (!$R['value']) { return; } $responseObj = new \stdClass(); $responseObj->status = 'skip'; $responseObj->message = ''; $ccNumber = $R['value']; $ccDetails = \App\Utils\CreditCard\NumberDetails::create($ccNumber)->getDetails(); if ($ccDetails['valid']) { $responseObj->status = 'ok'; if ($ccDetails['companyName']) { $msgText = sprintf($this->lang['msgTextOKForCompany'], $ccDetails['companyName']); } else { $msgText = $this->lang['msgTextOK']; } $responseObj->message = $msgText; } else { $responseObj->status = 'fail'; $responseObj->message = $this->lang['msgTextFail']; } return new \Engine\Mvc\Response\Json($responseObj); } } 