/**
  * Tries to process a payment through Pagosonline
  *
  * @param PagosonlineMethod $paymentMethod Payment method
  * @param float             $amount        Amount
  *
  * @return PagosonlineManager Self object
  *
  * @throws PaymentAmountsNotMatchException
  * @throws PaymentOrderNotFoundException
  * @throws PaymentException
  */
 public function processPayment(PagosonlineMethod $paymentMethod, $amount)
 {
     /// first check that amounts are the same
     $paymentBridgeAmount = (double) $this->paymentBridge->getAmount();
     /**
      * If both amounts are different, execute Exception
      */
     if (abs($amount - $paymentBridgeAmount) > 1.0E-5) {
         throw new PaymentAmountsNotMatchException();
     }
     /**
      * At this point, order must be created given a cart, and placed in PaymentBridge
      *
      * So, $this->paymentBridge->getOrder() must return an object
      */
     $this->paymentEventDispatcher->notifyPaymentOrderLoad($this->paymentBridge, $paymentMethod);
     /**
      * Order Not found Exception must be thrown just here
      */
     if (!$this->paymentBridge->getOrder()) {
         throw new PaymentOrderNotFoundException();
     }
     $this->paymentEventDispatcher->notifyPaymentOrderCreated($this->paymentBridge, $paymentMethod);
     $extraData = $this->paymentBridge->getExtraData();
     $object_ws = new \stdClass();
     $object_ws->cuentaId = $this->accountId;
     $object_ws->referencia = $this->paymentBridge->getOrderId() . '#' . date('Ymdhis');
     $object_ws->descripcion = $this->paymentBridge->getOrderDescription();
     $object_ws->valor = $this->paymentBridge->getAmount();
     $object_ws->iva = $extraData['vat'];
     $object_ws->baseDevolucionIva = $extraData['refund_vat'];
     $object_ws->isoMoneda4217 = $this->paymentBridge->getCurrency();
     $object_ws->numeroCuotas = $paymentMethod->getCardQuota();
     $object_ws->nombreComprador = $extraData['customer_firstname'] . $extraData['customer_lastname'];
     $object_ws->emailComprador = $extraData['customer_email'];
     $object_ws->franquicia = $paymentMethod->getCardType();
     $object_ws->numero = $paymentMethod->getCardNum();
     $object_ws->codigoSeguridad = $paymentMethod->getCardSecurity();
     $object_ws->nombreTarjetaHabiente = $paymentMethod->getCardName();
     $object_ws->fechaExpiracion = $paymentMethod->getCardExpYear() . '/' . $paymentMethod->getCardExpMonth();
     $object_ws->validarModuloAntiFraude = true;
     $object_ws->reportarPaginaConfirmacion = false;
     //Antifraude
     $object_ws->ciudadCorrespondencia = $extraData['correspondence_city'];
     $object_ws->cookie = $paymentMethod->getCookie();
     $object_ws->direccionCorrespondencia = $extraData['correspondence_address'];
     $object_ws->ipComprador = $paymentMethod->getClientIp();
     $object_ws->paisCorrespondencia = 'CO';
     $object_ws->userAgent = $paymentMethod->getUserAgent();
     $autWS = $this->pagosonlineComm->solicitarAutorizacion($object_ws);
     $this->logger->addInfo($paymentMethod->getPaymentName(), get_object_vars($object_ws));
     $paymentMethod->setPagosonlineTransactionId($autWS->transaccionId);
     $paymentMethod->setPagosonlineReference($autWS->referencia);
     $this->processTransaction($autWS, $paymentMethod);
     return $this;
 }
Example #2
0
 /**
  * Tries to process a payment through Banwire
  *
  * @param BanwireMethod $paymentMethod Payment method
  * @param float         $amount        Amount
  *
  * @return BanwireManager Self object
  *
  * @throws PaymentAmountsNotMatchException
  * @throws PaymentOrderNotFoundException
  * @throws PaymentException
  */
 public function processPayment(BanwireMethod $paymentMethod, $amount)
 {
     /**
      * first check that amounts are the same
      */
     $paymentBridgeAmount = intval($this->paymentBridge->getAmount());
     /**
      * If both amounts are different, execute Exception
      */
     if ($amount != $paymentBridgeAmount) {
         throw new PaymentAmountsNotMatchException(sprintf('Amounts differ. Requested: [%s] but in PaymentBridge: [%s].', $amount, $paymentBridgeAmount));
     }
     /**
      * At this point, order must be created given a cart, and placed in PaymentBridge
      *
      * So, $this->paymentBridge->getOrder() must return an object
      */
     $this->paymentEventDispatcher->notifyPaymentOrderLoad($this->paymentBridge, $paymentMethod);
     /**
      * Order Not found Exception must be thrown just here
      */
     if (!$this->paymentBridge->getOrder()) {
         throw new PaymentOrderNotFoundException();
     }
     $this->paymentEventDispatcher->notifyPaymentOrderCreated($this->paymentBridge, $paymentMethod);
     $extraData = $this->paymentBridge->getExtraData();
     $carExp = substr($paymentMethod->getCardExpYear(), -2);
     $params = array('response_format' => 'JSON', 'user' => $this->user, 'reference' => $this->paymentBridge->getOrderId() . '#' . date('Ymdhis'), 'currency' => $this->paymentBridge->getCurrency(), 'ammount' => number_format($this->paymentBridge->getAmount() / 100, 2), 'concept' => $this->paymentBridge->getOrderDescription(), 'card_num' => $paymentMethod->getCardNum(), 'card_name' => $paymentMethod->getCardName(), 'card_type' => $paymentMethod->getCardType(), 'card_exp' => $paymentMethod->getCardExpMonth() . '/' . $carExp, 'card_ccv2' => $paymentMethod->getCardSecurity(), 'address' => $extraData['correspondence_address'], 'post_code' => $extraData['customer_postal_code'], 'phone' => $extraData['customer_phone'], 'mail' => $extraData['customer_email']);
     $host = $this->api;
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $host);
     curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 6.0; WINDOWS; .NET CLR 1.1.4322)');
     curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
     curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
     curl_setopt($ch, CURLOPT_TIMEOUT, 30);
     curl_setopt($ch, CURLOPT_HEADER, 0);
     curl_setopt($ch, CURLOPT_POST, 1);
     curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params));
     if (defined('CURLOPT_ENCODING')) {
         curl_setopt($ch, CURLOPT_ENCODING, "");
     }
     $responseApi = curl_exec($ch);
     $this->processTransaction($responseApi, $paymentMethod);
     return $this;
 }