예제 #1
0
 /**
  * Instantiate the handler
  * @link http://www.manula.com/manuals/payco/payment-api/hostedpagesdraft/en/topic/reserve
  * @param Config $config Config class for the library
  * @param array $data Data in the MNS call. Please see API documentation for possible values
  * @param ProcessorInterface $processor Class provided by the Integration to be ran once a MNS call is validated
  * @throws ParamNotProvided
  * @throws \Upg\Library\Callback\Exception\MacValidation
  */
 public function __construct(Config $config, array $data, ProcessorInterface $processor)
 {
     $this->config = $config;
     $this->processor = $processor;
     $missingParams = array();
     foreach ($this->requireFields as $param) {
         if (array_key_exists($param, $data)) {
             $this->data[$param] = $data[$param];
         } else {
             $missingParams[] = $param;
         }
     }
     foreach ($this->optionalFields as $param) {
         if (array_key_exists($param, $data)) {
             $this->data[$param] = $data[$param];
         } else {
             $this->data[$param] = '';
         }
     }
     if (!empty($missingParams)) {
         throw new ParamNotProvided(implode(', ', $missingParams));
     }
     $macCalculator = new MacCalculator($this->config, $this->data);
     $macCalculator->validateResponse();
     $this->processor->sendData($this->data['merchantID'], $this->data['storeID'], $this->data['orderID'], $this->data['captureID'], $this->data['merchantReference'], $this->data['paymentReference'], $this->data['userID'], $this->data['amount'], $this->data['currency'], $this->data['transactionStatus'], $this->data['orderStatus'], $this->data['additionalData'], $this->data['timestamp'], $this->data['version']);
 }
예제 #2
0
 /**
  * Construct a instance of the Callback Handler
  * See the linked documentaion under the Callback
  * @link http://www.manula.com/manuals/payco/payment-api/hostedpagesdraft/en/topic/reserve
  * @param Config $config Payco config
  * @param array $data Array of data in the call back
  * @param ProcessorInterface $processor Processor to handle the call back
  * @throws Exception\MacValidation
  * @throws ParamNotProvided
  */
 public function __construct(Config $config, array $data, ProcessorInterface $processor)
 {
     $this->config = $config;
     $this->processor = $processor;
     //ok validate the request data;
     $missingParams = array();
     foreach ($this->validParams as $param) {
         if (array_key_exists($param, $data)) {
             $this->data[$param] = $data[$param];
         } else {
             $missingParams[] = $param;
         }
     }
     foreach ($this->optionalParam as $param) {
         if (array_key_exists($param, $data)) {
             $this->data[$param] = $data[$param];
         } else {
             $this->data[$param] = '';
         }
     }
     if (!empty($missingParams)) {
         throw new ParamNotProvided(implode(', ', $missingParams));
     }
     /**
      * validate the call back mac
      */
     $macCalculator = new MacCalculator($this->config, $this->data);
     $macCalculator->validateResponse();
     $additionalInfo = array();
     if (!empty($data['additionalInformation'])) {
         $additionalInfo = json_decode($data['additionalInformation'], true);
     }
     /**
      * Send the data to the processor
      */
     $this->processor->sendData($data['notificationType'], $data['merchantID'], $data['storeID'], $data['orderID'], $data['paymentMethod'], $data['resultCode'], $data['merchantReference'], $data['paymentInstrumentID'], $additionalInfo, $data['message']);
 }