/** * 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; }
public function checkTransactionStatus($transactionId) { //All information of transaction response $statusTransactionWS = $this->pagosonlineComm->consultarEstadoTransaccion($this->accountId, $transactionId); $paymentMethod = new PagosonlineGatewayMethod(); $paymentMethod->setPagosonlineGatewayTransactionId($statusTransactionWS->transaccionId); $paymentMethod->setStatus($statusTransactionWS->estadoId); $paymentMethod->setReference($statusTransactionWS->referencia); $paymentMethod->setAmount($statusTransactionWS->valor); $this->logger->addInfo($paymentMethod->getPaymentName() . 'processTransactionCheck', get_object_vars($statusTransactionWS)); /** * if pagosonline return code 15 o 9994 the order status is pending */ $this->paymentEventDispatcher->notifyPaymentOrderLoad($this->paymentBridge, $paymentMethod); if ($statusTransactionWS->codigoRespuesta == 1) { $this->paymentEventDispatcher->notifyPaymentOrderSuccess($this->paymentBridge, $paymentMethod); } elseif (!in_array($statusTransactionWS->codigoRespuesta, array(15, 9994))) { //status 15 or 9994 payment is still in pending nothing to do $this->paymentEventDispatcher->notifyPaymentOrderFail($this->paymentBridge, $paymentMethod); } }