Пример #1
0
 /**
  * Tries to process a payment through Paymill
  *
  * @param FreePaymentMethod $paymentMethod Payment method
  *
  * @return FreePaymentManager Self object
  */
 public function processPayment(FreePaymentMethod $paymentMethod)
 {
     /**
      * At this point, order must be created given a card, and placed in PaymentBridge
      *
      * So, $this->paymentBridge->getOrder() must return an object
      */
     $this->paymentEventDispatcher->notifyPaymentOrderLoad($this->paymentBridge, $paymentMethod);
     /**
      * Order exists right here
      */
     $this->paymentEventDispatcher->notifyPaymentOrderCreated($this->paymentBridge, $paymentMethod);
     /**
      * Payment paid done
      *
      * Paid process has ended ( No matters result )
      */
     $this->paymentEventDispatcher->notifyPaymentOrderDone($this->paymentBridge, $paymentMethod);
     /**
      * Payment paid successfully
      *
      * Paid process has ended successfully
      */
     $this->paymentEventDispatcher->notifyPaymentOrderSuccess($this->paymentBridge, $paymentMethod);
     return $this;
 }
 /**
  * Executes the payment : DoExpressCheckoutPayment
  *
  */
 public function processPayment(PaypalExpressCheckoutMethod $paymentMethod)
 {
     $orderParameters = $paymentMethod->getSomeExtraData();
     $this->paypalWrapper->request('DoExpressCheckoutPayment', $orderParameters);
     $this->paymentEventDispatcher->notifyPaymentOrderDone($this->paymentBridge, $paymentMethod);
     if ($this->getPaymentStatus($this->paypalWrapper) == 'PaymentActionCompleted') {
         $this->paymentEventDispatcher->notifyPaymentOrderSuccess($this->paymentBridge, $paypalMethod);
     } else {
         $this->paymentEventDispatcher->notifyPaymentOrderFail($paymentBridge, $paypalMethod);
     }
     return $this->getPaymentStatus();
 }
 /**
  * Captures a previously authorized transaction.
  * This will only work for transaction whose
  * "transaction type" is "1" and not "A".
  *
  * @param $amount amount to be charged in cents
  * @param $redsysTransactionId redsys transaction id (DS_ORDER)
  *
  * @throws PaymentException
  */
 public function captureTransaction($amount, $redsysTransactionId)
 {
     /*
      * Captures a previously authorized transaction
      */
     $this->transactionType = 2;
     $entryData = sprintf(self::CAPTURE_MESSAGE, $amount, $redsysTransactionId, $this->merchantCode, $this->currency, $this->transactionType, $this->merchantTerminal);
     $this->response = sprintf(self::ROOT_MESSAGE, $entryData, $this->signTransactionMac256($redsysTransactionId, $entryData));
     $method = new RedsysApiMethod();
     try {
         $r = $this->_callSoap();
     } catch (\Exception $e) {
         /* The Soap call failed */
         $this->eventDispatcher->notifyPaymentOrderFail($this->paymentBridge, $method);
         throw new PaymentException($e->getMessage());
     }
     $this->eventDispatcher->notifyPaymentOrderDone($this->paymentBridge, $method);
     if (!$this->isAuthorized($r)) {
         $this->paymentBridge->setError($this->getError($r));
         $this->paymentBridge->setErrorCode($this->getErrorCode($r));
         $method->setTransactionResponse($this->getError($r));
         /* Payment capture has been refused */
         $this->eventDispatcher->notifyPaymentOrderFail($this->paymentBridge, $method);
         throw new PaymentException($this->getErrorCode($r));
     } else {
         /**
          * Payment OK
          */
         $this->eventDispatcher->notifyPaymentOrderSuccess($this->paymentBridge, $method);
     }
 }
Пример #4
0
 /**
  * Given a paymillTransaction response, as an array, prform desired operations
  *
  * @param string        $apiResponse   Api response
  * @param BanwireMethod $paymentMethod Payment method
  *
  * @return BanwireManager Self object
  *
  * @throws PaymentException
  */
 private function processTransaction($apiResponse, BanwireMethod $paymentMethod)
 {
     $banwireParams = json_decode($apiResponse);
     if (isset($banwireParams->order_id)) {
         $paymentMethod->setBanwireTransactionId($banwireParams->order_id);
     }
     if (isset($banwireParams->referencia)) {
         $paymentMethod->setBanwireReference($banwireParams->referencia);
     }
     /**
      * Payment paid done
      *
      * Paid process has ended ( No matters result )
      */
     $this->paymentEventDispatcher->notifyPaymentOrderDone($this->paymentBridge, $paymentMethod);
     if ($banwireParams->response == 'ok') {
         $this->paymentEventDispatcher->notifyPaymentOrderSuccess($this->paymentBridge, $paymentMethod);
     } else {
         $this->paymentEventDispatcher->notifyPaymentOrderFail($this->paymentBridge, $paymentMethod);
         throw new PaymentException();
     }
     /**
      * Log the response of gateway
      */
     return $this;
 }
Пример #5
0
 /**
  * Given a paymillTransaction response, as an array, prform desired operations
  *
  * @param array             $autWS
  * @param PagosonlineMethod $paymentMethod Payment method
  *
  * @return PagosonlineManager Self object
  *
  * @throws PaymentException
  */
 private function processTransaction($autWS, PagosonlineMethod $paymentMethod)
 {
     /**
      * Payment paid done
      *
      * Paid process has ended ( No matters result )
      */
     $this->paymentEventDispatcher->notifyPaymentOrderDone($this->paymentBridge, $paymentMethod);
     $this->logger->addInfo($paymentMethod->getPaymentName() . 'processTransaction', get_object_vars($autWS));
     /**
      * if pagosonline return code 15 o 9994 the order status is pending
      */
     if (in_array($autWS->codigoRespuesta, array('15', '9994'))) {
         //payment is still pending nothing to do
     } elseif ($autWS->codigoRespuesta == 1) {
         $this->paymentEventDispatcher->notifyPaymentOrderSuccess($this->paymentBridge, $paymentMethod);
     } else {
         $this->paymentEventDispatcher->notifyPaymentOrderFail($this->paymentBridge, $paymentMethod);
         throw new PaymentException();
     }
     /**
      * Log the response of gateway
      */
     return $this;
 }
Пример #6
0
 /**
  * Check and set param for payment.
  *
  * @param StripeMethod $paymentMethod Payment method
  * @param float        $amount        Amount
  *
  * @return array Charge params
  *
  * @throws PaymentAmountsNotMatchException
  * @throws PaymentOrderNotFoundException
  */
 private function prepareData(StripeMethod $paymentMethod, $amount)
 {
     /// first check that amounts are the same
     $cartAmount = intval($this->paymentBridge->getAmount());
     /**
      * If both amounts are different, execute Exception.
      */
     if (abs($amount - $cartAmount) > 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();
     }
     /**
      * Order exists right here.
      */
     $this->paymentEventDispatcher->notifyPaymentOrderCreated($this->paymentBridge, $paymentMethod);
     /**
      * Validate the order in the module
      * params for stripe interaction.
      */
     $cardParams = ['number' => $paymentMethod->getCreditCardNumber(), 'exp_month' => $paymentMethod->getCreditCardExpirationMonth(), 'exp_year' => $paymentMethod->getCreditCardExpirationYear()];
     return ['card' => $cardParams, 'amount' => $cartAmount, 'currency' => strtolower($this->paymentBridge->getCurrency())];
 }
Пример #7
0
 /**
  * Processes the POST request sent by Redsys
  *
  * @param array $parameters Array with response parameters
  *
  * @return RedsysManager Self object
  *
  * @throws InvalidSignatureException
  * @throws ParameterNotReceivedException
  * @throws PaymentException
  */
 public function processResult(array $parameters)
 {
     //Check we receive all needed parameters
     $this->checkResultParameters($parameters);
     $redsysMethod = new RedsysMethod();
     $dsSignature = $parameters['Ds_Signature'];
     $dsParams = $parameters['Ds_MerchantParameters'];
     $dsVersion = $parameters['Ds_SignatureVersion'];
     $paramsDecoded = base64_decode(strtr($dsParams, '-_', '+/'));
     $this->varsPay = json_decode($paramsDecoded, true);
     $dsResponse = $this->varsPay['Ds_Response'];
     $dsAmount = $this->varsPay['Ds_Amount'];
     $dsOrder = $this->varsPay['Ds_Order'];
     $dsMerchantCode = $this->varsPay['Ds_MerchantCode'];
     $dsCurrency = $this->varsPay['Ds_Currency'];
     $dsDate = $this->varsPay['Ds_Date'];
     $dsHour = $this->varsPay['Ds_Hour'];
     $dsSecurePayment = $this->varsPay['Ds_SecurePayment'];
     $dsCardCountry = $this->varsPay['Ds_Card_Country'];
     $dsAuthorisationCode = $this->varsPay['Ds_AuthorisationCode'];
     $dsConsumerLanguage = $this->varsPay['Ds_ConsumerLanguage'];
     $dsCardType = array_key_exists('Ds_Card_Type', $this->varsPay) ? $this->varsPay['Ds_Card_Type'] : '';
     $dsMerchantData = array_key_exists('Ds_MerchantData', $this->varsPay) ? $this->varsPay['Ds_MerchantData'] : '';
     if ($dsSignature != $this->expectedSignature($dsParams)) {
         throw new InvalidSignatureException();
     }
     /**
      * Adding transaction information to PaymentMethod
      *
      * This information is only available in PaymentOrderSuccess event
      */
     $redsysMethod->setDsResponse($dsResponse)->setDsAuthorisationCode($dsAuthorisationCode)->setDsCardCountry($dsCardCountry)->setDsCardType($dsCardType)->setDsConsumerLanguage($dsConsumerLanguage)->setDsDate($dsDate)->setDsHour($dsHour)->setDsSecurePayment($dsSecurePayment)->setDsOrder($dsOrder);
     /**
      * Payment paid done
      *
      * Paid process has ended ( No matters result )
      */
     $this->paymentEventDispatcher->notifyPaymentOrderDone($this->paymentBridge, $redsysMethod);
     /**
      * when a transaction is successful, $Ds_Response has a value between 0 and 99
      */
     if (!$this->transactionSuccessful($dsResponse)) {
         /**
          * Payment paid failed
          *
          * Paid process has ended failed
          */
         $this->paymentEventDispatcher->notifyPaymentOrderFail($this->paymentBridge, $redsysMethod);
         throw new PaymentException();
     }
     /**
      * Payment paid successfully
      *
      * Paid process has ended successfully
      */
     $this->paymentEventDispatcher->notifyPaymentOrderSuccess($this->paymentBridge, $redsysMethod);
     return $this;
 }
Пример #8
0
 /**
  * Confirm webpay payment
  *
  * @param WebpayMethod $paymentMethod Payment Method
  * @param array        $postData      Post parameters
  *
  * @throws \PaymentSuite\PaymentCoreBundle\Exception\PaymentException
  * @throws \PaymentSuite\WebpayBundle\Exception\WebpayMacCheckException
  * @throws \PaymentSuite\PaymentCoreBundle\Exception\PaymentOrderNotFoundException
  * @throws \PaymentSuite\PaymentCoreBundle\Exception\PaymentAmountsNotMatchException
  * @throws \PaymentSuite\PaymentCoreBundle\Exception\PaymentDuplicatedException
  *
  * @return WebpayManager Self object
  */
 public function confirmPayment(WebpayMethod $paymentMethod, array $postData)
 {
     $paymentBridge = $this->paymentBridge;
     /** @var Normal $trans */
     $trans = $paymentMethod->getTransaction();
     $tbkRespuesta = $trans->getRespuesta();
     $tbkOrdenCompra = $trans->getOrdenCompra();
     $tbkMonto = $trans->getMonto();
     $paymentMethod->setSessionId($trans->getIdSesion());
     // Check TBK_ORDEN_COMPRA
     $this->eventDispatcher->notifyPaymentOrderLoad($paymentBridge, $paymentMethod);
     if (!$paymentBridge->getOrder() || $paymentBridge->getOrderId() != $tbkOrdenCompra) {
         throw new PaymentOrderNotFoundException();
     }
     // Check TBK_RESPUESTA
     if ($tbkRespuesta !== '0') {
         $this->eventDispatcher->notifyPaymentOrderFail($paymentBridge, $paymentMethod);
         throw new PaymentException();
     }
     // Check MAC
     $fileMacName = $this->kccPath . '/log/MAC01Normal' . $trans->getIdSesion() . '.txt';
     $fileMac = fopen($fileMacName, 'w');
     foreach ($postData as $key => $val) {
         fwrite($fileMac, "{$key}={$val}&");
     }
     fclose($fileMac);
     $cmd = $this->kccPath . '/tbk_check_mac.cgi ' . $fileMacName . ' 2>&1';
     exec($cmd, $result, $retint);
     if ($retint != 0 || $result[0] != 'CORRECTO') {
         $this->eventDispatcher->notifyPaymentOrderFail($paymentBridge, $paymentMethod);
         throw new WebpayMacCheckException();
     }
     // Check MONTO
     $fileMontoName = $this->kccPath . '/log/datos' . $trans->getIdSesion() . '.log';
     if (!($fileMonto = fopen($fileMontoName, 'r'))) {
         $this->eventDispatcher->notifyPaymentOrderFail($paymentBridge, $paymentMethod);
         throw new PaymentAmountsNotMatchException();
     }
     $line = trim(fgets($fileMonto));
     fclose($fileMonto);
     $details = explode(";", $line);
     if (count($details) != 2) {
         $this->eventDispatcher->notifyPaymentOrderFail($paymentBridge, $paymentMethod);
         throw new PaymentAmountsNotMatchException();
     }
     if ($tbkMonto != $details[0] || $tbkOrdenCompra != $details[1]) {
         $this->eventDispatcher->notifyPaymentOrderFail($paymentBridge, $paymentMethod);
         throw new PaymentAmountsNotMatchException();
     }
     // Check DUPLICIDAD
     if ($paymentBridge->isOrderPaid()) {
         throw new PaymentDuplicatedException();
     }
     $this->eventDispatcher->notifyPaymentOrderSuccess($this->paymentBridge, $paymentMethod);
     return $this;
 }
Пример #9
0
 /**
  * Processes the POST request sent by Redsys.
  *
  * @param array $parameters Array with response parameters
  *
  * @return RedsysManager Self object
  *
  * @throws InvalidSignatureException     Invalid signature
  * @throws ParameterNotReceivedException Invalid parameters
  * @throws PaymentException              Payment exception
  */
 public function processResult(array $parameters)
 {
     $this->checkResultParameters($parameters);
     $redsysMethod = new RedsysMethod();
     $dsSignature = $parameters['Ds_Signature'];
     $dsResponse = $parameters['Ds_Response'];
     $dsAmount = $parameters['Ds_Amount'];
     $dsOrder = $parameters['Ds_Order'];
     $dsMerchantCode = $parameters['Ds_MerchantCode'];
     $dsCurrency = $parameters['Ds_Currency'];
     $dsSecret = $this->secretKey;
     $dsDate = $parameters['Ds_Date'];
     $dsHour = $parameters['Ds_Hour'];
     $dsSecurePayment = $parameters['Ds_SecurePayment'];
     $dsCardCountry = $parameters['Ds_Card_Country'];
     $dsAuthorisationCode = $parameters['Ds_AuthorisationCode'];
     $dsConsumerLanguage = $parameters['Ds_ConsumerLanguage'];
     $dsCardType = array_key_exists('Ds_Card_Type', $parameters) ? $parameters['Ds_Card_Type'] : '';
     if ($dsSignature != $this->expectedSignature($dsAmount, $dsOrder, $dsMerchantCode, $dsCurrency, $dsResponse, $dsSecret)) {
         throw new InvalidSignatureException();
     }
     /**
      * Adding transaction information to PaymentMethod.
      *
      * This information is only available in PaymentOrderSuccess event
      */
     $redsysMethod->setDsResponse($dsResponse)->setDsAuthorisationCode($dsAuthorisationCode)->setDsCardCountry($dsCardCountry)->setDsCardType($dsCardType)->setDsConsumerLanguage($dsConsumerLanguage)->setDsDate($dsDate)->setDsHour($dsHour)->setDsSecurePayment($dsSecurePayment)->setDsOrder($dsOrder);
     /**
      * Payment paid done.
      *
      * Paid process has ended ( No matters result )
      */
     $this->paymentEventDispatcher->notifyPaymentOrderDone($this->paymentBridge, $redsysMethod);
     /**
      * when a transaction is successful, $Ds_Response has a
      * value between 0 and 99.
      */
     if (!$this->transactionSuccessful($dsResponse)) {
         /**
          * Payment paid failed.
          *
          * Paid process has ended failed
          */
         $this->paymentEventDispatcher->notifyPaymentOrderFail($this->paymentBridge, $redsysMethod);
         throw new PaymentException();
     }
     /**
      * Payment paid successfully.
      *
      * Paid process has ended successfully
      */
     $this->paymentEventDispatcher->notifyPaymentOrderSuccess($this->paymentBridge, $redsysMethod);
     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);
     }
 }
Пример #11
0
 /**
  * Collect callback data after payment process
  *
  * @param array $response Response data
  *
  * @throws PaymentAmountsNotMatchException
  * @throws PaymentException
  *
  * @return GoogleWalletManager Self object
  */
 public function processPayment($response)
 {
     $paymentMethod = new GoogleWalletMethod();
     $paymentMethod->setTransactionResponse($response);
     if (in_array('orderId', $response)) {
         $paymentMethod->setTransactionId($response['orderId'])->setTransactionStatus('paid');
         $this->paymentEventDispatcher->notifyPaymentOrderDone($this->paymentBridge, $paymentMethod);
         $this->paymentEventDispatcher->notifyPaymentOrderSuccess($this->paymentBridge, $paymentMethod);
     } else {
         $this->paymentEventDispatcher->notifyPaymentOrderFail($this->paymentBridge, $paymentMethod);
         throw new PaymentException();
     }
     return $this;
 }
Пример #12
0
 /**
  * Returns true if the transaction was successful
  *
  * @param string $dsResponse Response code
  *
  * @return boolean
  */
 protected function transactionSuccessful($dsResponse, $redsysMethod)
 {
     /**
      * When a transaction is successful, $Ds_Response has a value between 0 and 99
      */
     if (intval($dsResponse) >= 100) {
         /**
          * Payment paid failed
          *
          * Paid process has ended failed
          */
         $this->paymentEventDispatcher->notifyPaymentOrderFail($this->paymentBridge, $redsysMethod);
         throw new PaymentResponseException(false, $dsResponse);
     }
 }
Пример #13
0
 /**
  * Testing payment Success
  */
 public function testPaymentSuccess()
 {
     $this->paymillMethod->expects($this->once())->method('getApiToken')->will($this->returnValue(self::API_TOKEN));
     $this->paymentBridge->expects($this->once())->method('getOrder')->will($this->returnValue(1));
     $this->paymillMethod->expects($this->any())->method('setTransactionId')->with($this->equalTo('123'))->will($this->returnValue($this->paymillMethod));
     $this->paymillMethod->expects($this->any())->method('setTransactionStatus')->with($this->equalTo('closed'))->will($this->returnValue($this->paymillMethod));
     $this->paymentBridge->expects($this->once())->method('getCurrency')->will($this->returnValue(self::CURRENCY));
     $this->paymentBridge->expects($this->once())->method('getAmount')->will($this->returnValue(self::ORDER_AMOUNT));
     $this->paymentBridge->expects($this->once())->method('getExtraData')->will($this->returnValue(array('order_description' => self::ORDER_DESCRIPTION)));
     $this->paymillResponseTransaction->expects($this->once())->method('getStatus')->will($this->returnValue('closed'));
     $this->paymillResponseTransaction->expects($this->once())->method('getId')->will($this->returnValue(123));
     $this->paymillTransactionWrapper->expects($this->once())->method('create')->with($this->equalTo(self::ORDER_AMOUNT), $this->equalTo(self::CURRENCY), $this->equalTo(self::API_TOKEN), $this->equalTo(self::ORDER_DESCRIPTION))->will($this->returnValue($this->paymillResponseTransaction));
     $this->paymentEventDispatcher->expects($this->once())->method('notifyPaymentOrderLoad')->with($this->equalTo($this->paymentBridge), $this->equalTo($this->paymillMethod));
     $this->paymentEventDispatcher->expects($this->once())->method('notifyPaymentOrderCreated')->with($this->equalTo($this->paymentBridge), $this->equalTo($this->paymillMethod));
     $this->paymentEventDispatcher->expects($this->once())->method('notifyPaymentOrderDone')->with($this->equalTo($this->paymentBridge), $this->equalTo($this->paymillMethod));
     $this->paymentEventDispatcher->expects($this->any())->method('notifyPaymentOrderFail');
     $this->paymentEventDispatcher->expects($this->once())->method('notifyPaymentOrderSuccess')->with($this->equalTo($this->paymentBridge), $this->equalTo($this->paymillMethod));
     $this->paymillManager->processPayment($this->paymillMethod, self::ORDER_AMOUNT);
 }
Пример #14
0
 /**
  * Post url update the order status
  *
  * @param SafetypayMethod $paymentMethod
  * @param Array           $postData
  */
 public function confirmPayment(SafetypayMethod $paymentMethod, $postData)
 {
     $this->paymentLogger->setPaymentBundle($paymentMethod->getPaymentName());
     $jsonData = json_encode($postData);
     $this->paymentLogger->log('Response: ' . $jsonData);
     $paymentMethod->setReference($postData['MerchantReferenceNo']);
     $paymentMethod->setRequestDateTime($postData['RequestDateTime']);
     $paymentMethod->setSignature($postData['Signature']);
     $paymentBridge = $this->paymentBridge;
     $signature = $this->getSignature($postData, 'RequestDateTime, MerchantReferenceNo', true);
     if ($postData['ApiKey'] !== '' || $postData['Signature'] !== '') {
         if ($this->key == $postData['ApiKey']) {
             if ($postData['Signature'] == $signature) {
                 $this->eventDispatcher->notifyPaymentOrderLoad($paymentBridge, $paymentMethod);
                 $this->eventDispatcher->notifyPaymentOrderSuccess($paymentBridge, $paymentMethod);
             }
         }
     }
 }
 /**
  * Process Paypal IPN response to payment.
  *
  * When the IPN mesage is validated, a payment success event
  * should be dispatched.
  *
  * @param int   $orderId    Order Id
  * @param array $parameters parameter array coming from Paypal IPN notification
  *
  * @throws ParameterNotReceivedException
  * @throws PaymentException
  */
 public function processPaypalIPNMessage($orderId, array $parameters)
 {
     /**
      * Retrieving the order object.
      */
     $order = $this->paymentBridge->findOrder($orderId);
     if (!$order) {
         throw new PaymentOrderNotFoundException(sprintf('Order #%s not found', $orderId));
     }
     $this->paymentBridge->setOrder($order);
     /**
      * Check that we receive the mandatory parameters.
      */
     $this->checkResultParameters($parameters);
     /**
      * Initializing PaypalWebCheckoutMethod, which is
      * an object representation of the payment information
      * coming from the payment processor.
      */
     $paypalMethod = $this->paymentMethodFactory->create($parameters['mc_gross'], $parameters['payment_status'], $parameters['notify_version'], $parameters['payer_status'], $parameters['business'], null, $parameters['verify_sign'], $parameters['payer_email'], $parameters['txn_id'], $parameters['payment_type'], $parameters['receiver_email'], null, $parameters['txn_type'], null, $parameters['mc_currency'], null, $parameters['test_ipn'], $parameters['ipn_track_id']);
     /**
      * Notifying payment.done, which means that the
      * payment has been received, although we still
      * do not know if it is succesful or not.
      * Listening fot this event is useful when one
      * wants to record transaction informations.
      */
     $this->paymentEventDispatcher->notifyPaymentOrderDone($this->paymentBridge, $paypalMethod);
     /**
      * Check if the transaction is successful.
      */
     if (!$this->transactionSuccessful($parameters)) {
         $this->paymentEventDispatcher->notifyPaymentOrderFail($this->paymentBridge, $paypalMethod);
         throw new PaymentException();
     }
     /**
      * Payment paid successfully.
      *
      * Paid process has ended successfully
      */
     $this->paymentEventDispatcher->notifyPaymentOrderSuccess($this->paymentBridge, $paypalMethod);
 }
 /**
  * Testing payment error
  *
  */
 public function testPaymentSuccess()
 {
     $this->redsysApiMethod->expects($this->once())->method('getCreditCartNumber')->will($this->returnValue(self::CART_NUMBER));
     $this->redsysApiMethod->expects($this->once())->method('getCreditCartExpirationMonth')->will($this->returnValue(self::CART_EXPIRE_MONTH));
     $this->redsysApiMethod->expects($this->once())->method('getCreditCartExpirationYear')->will($this->returnValue(self::CART_EXPIRE_YEAR));
     $this->paymentBridge->expects($this->once())->method('getOrder')->will($this->returnValue(1));
     $this->redsysApiMethod->expects($this->any())->method('setTransactionId')->with($this->equalTo('123'))->will($this->returnValue($this->redsysApiMethod));
     $this->redsysApiMethod->expects($this->any())->method('setTransactionStatus')->with($this->equalTo('paid'))->will($this->returnValue($this->redsysApiMethod));
     $this->paymentBridge->expects($this->once())->method('getCurrency')->will($this->returnValue(self::CURRENCY));
     $this->paymentBridge->expects($this->once())->method('getAmount')->will($this->returnValue(self::CART_AMOUNT));
     $cart = array('number' => self::CART_NUMBER, 'exp_month' => self::CART_EXPIRE_MONTH, 'exp_year' => self::CART_EXPIRE_YEAR);
     $chargeParams = array('card' => $cart, 'amount' => self::CART_AMOUNT, 'currency' => strtolower(self::CURRENCY));
     $this->redsysApiTransactionWrapper->expects($this->once())->method('create')->with($chargeParams)->will($this->returnValue(array('paid' => '1', 'id' => '123')));
     $this->paymentEventDispatcher->expects($this->once())->method('notifyPaymentOrderLoad')->with($this->equalTo($this->paymentBridge), $this->equalTo($this->redsysApiMethod));
     $this->paymentEventDispatcher->expects($this->once())->method('notifyPaymentOrderCreated')->with($this->equalTo($this->paymentBridge), $this->equalTo($this->redsysApiMethod));
     $this->paymentEventDispatcher->expects($this->once())->method('notifyPaymentOrderDone')->with($this->equalTo($this->paymentBridge), $this->equalTo($this->redsysApiMethod));
     $this->paymentEventDispatcher->expects($this->any())->method('notifyPaymentOrderFail');
     $this->paymentEventDispatcher->expects($this->once())->method('notifyPaymentOrderSuccess')->with($this->equalTo($this->paymentBridge), $this->equalTo($this->redsysApiMethod));
     $this->redsysApiManager->processPayment($this->redsysApiMethod, self::CART_AMOUNT);
 }
Пример #17
0
 /**
  * Decline payment, given an Id of an existing order.
  *
  * @param int $orderId Id from order to decline
  *
  * @return BankwireManager self Object
  *
  * @throws PaymentOrderNotFoundException
  */
 public function declinePayment($orderId)
 {
     /**
      * Loads order to validate.
      */
     $this->paymentBridge->findOrder($orderId);
     /**
      * Order Not found Exception must be thrown just here.
      */
     if (!$this->paymentBridge->getOrder()) {
         throw new PaymentOrderNotFoundException();
     }
     /**
      * Payment failed.
      *
      * Paid process has ended with failure
      */
     $this->paymentEventDispatcher->notifyPaymentOrderFail($this->paymentBridge, $this->methodFactory->create());
     return $this;
 }
Пример #18
0
 /**
  * Validates payment, given an Id of an existing order
  *
  * @param integer $orderId Id from order to validate
  *
  * @return BankwireManager self Object
  *
  * @throws PaymentOrderNotFoundException
  */
 public function validatePayment($orderId)
 {
     /**
      * Loads order to validate
      */
     $this->paymentBridge->findOrder($orderId);
     /**
      * Order Not found Exception must be thrown just here
      */
     if (!$this->paymentBridge->getOrder()) {
         throw new PaymentOrderNotFoundException();
     }
     /**
      * Payment paid successfully
      *
      * Paid process has ended successfully
      */
     $this->paymentEventDispatcher->notifyPaymentOrderSuccess($this->paymentBridge, $this->bankwireMethodWrapper->getBankwireMethod());
     return $this;
 }
Пример #19
0
 /**
  * Given a Dineromail response, as a SimpleXMLElement, perform desired operations
  *
  * @param  SimpleXMLElement  $xml Dineromail response
  * @return DineromailManager Self object
  */
 public function processTransaction($xml)
 {
     $paymentMethod = new DineromailMethod();
     $this->logger->addInfo($paymentMethod->getPaymentName() . 'processTransaction: ' . $xml->asXML());
     switch ($status = $xml->ESTADO) {
         case self::STATUS_PENDING:
             break;
         case self::STATUS_ACCEPTED:
         case self::STATUS_DENIED:
             $paymentMethod->setDineromailTransactionId($xml->ID);
             $paymentMethod->setAmount($xml->MONTO);
             $this->paymentEventDispatcher->notifyPaymentOrderLoad($this->paymentBridge, $paymentMethod);
             break;
         default:
     }
     if ($status == self::STATUS_ACCEPTED) {
         $this->paymentEventDispatcher->notifyPaymentOrderSuccess($this->paymentBridge, $paymentMethod);
     }
     if ($status == self::STATUS_DENIED) {
         $this->paymentEventDispatcher->notifyPaymentOrderFail($this->paymentBridge, $paymentMethod);
     }
     return $this;
 }
Пример #20
0
 /**
  * Tries to process a payment through Authorizenet
  *
  * @param AuthorizenetMethod $paymentMethod Payment method
  *
  * @throws PaymentAmountsNotMatchException
  * @throws PaymentException
  *
  * @return AuthorizenetManager Self object
  */
 public function processPayment(AuthorizenetMethod $paymentMethod)
 {
     /**
      * check and set payment data
      */
     $this->prepareData($paymentMethod);
     /**
      * make payment
      */
     $transaction = $this->transactionWrapper->create($this->chargeParams);
     /**
      * Payment paid done
      *
      * Paid process has ended ( No matters result )
      */
     $this->paymentEventDispatcher->notifyPaymentOrderDone($this->paymentBridge, $paymentMethod);
     /**
      * when a transaction is successful, it is marked as 'closed'
      */
     if (!isset($transaction[2]) || $transaction[2] != 1) {
         /**
          * Payment paid failed
          *
          * Paid process has ended failed
          */
         $this->paymentEventDispatcher->notifyPaymentOrderFail($this->paymentBridge, $paymentMethod);
         throw new PaymentException();
     }
     $paymentMethod->setTransactionId($transaction[37])->setTransactionStatus('paid')->setTransactionResponse($transaction);
     /**
      * Payment paid successfully
      *
      * Paid process has ended successfully
      */
     $this->paymentEventDispatcher->notifyPaymentOrderSuccess($this->paymentBridge, $paymentMethod);
     return $this;
 }
Пример #21
0
 public function testPaymentSuccess()
 {
     $dsResponse = 0;
     $dsAuthorisationCode = '222FFF';
     $dsCardCountry = 'ESP';
     $dsCardType = 'y';
     $dsConsumerLanguage = 'y';
     $dsDate = 'X';
     $dsHour = 'X';
     $dsSecurePayment = '1';
     $parameters = array('Ds_Date' => $dsDate, 'Ds_Hour' => $dsHour, 'Ds_Terminal' => '1', 'Ds_SecurePayment' => $dsSecurePayment, 'Ds_Signature' => '9A163AA5034368367665866E62D603A5A92C5D35', 'Ds_Response' => $dsResponse, 'Ds_Amount' => '99', 'Ds_Order' => '0001', 'Ds_MerchantCode' => '999008881', 'Ds_Currency' => '978', 'Ds_TransactionType' => '2', 'Ds_MerchantData' => 'Mis datos', 'Ds_Card_Country' => $dsCardCountry, 'Ds_AuthorisationCode' => $dsAuthorisationCode, 'Ds_ConsumerLanguage' => $dsConsumerLanguage, 'Ds_Card_Type' => $dsCardType);
     $this->paymentEventDispatcher->expects($this->once())->method('notifyPaymentOrderDone')->with($this->equalTo($this->paymentBridge));
     $this->redsysMethod->expects($this->any())->method('setDsResponse')->with($this->equalTo($dsResponse))->will($this->returnValue($this->redsysMethod));
     $this->redsysMethod->expects($this->any())->method('setDsAuthorisationCode')->with($this->equalTo($dsAuthorisationCode))->will($this->returnValue($this->redsysMethod));
     $this->redsysMethod->expects($this->any())->method('setDsCardCountry')->with($this->equalTo($dsCardCountry))->will($this->returnValue($this->redsysMethod));
     $this->redsysMethod->expects($this->any())->method('setDsCardType')->with($this->equalTo($dsCardType))->will($this->returnValue($this->redsysMethod));
     $this->redsysMethod->expects($this->any())->method('setDsConsumerLanguage')->with($this->equalTo($dsConsumerLanguage))->will($this->returnValue($this->redsysMethod));
     $this->redsysMethod->expects($this->any())->method('setDsDate')->with($this->equalTo($dsDate))->will($this->returnValue($this->redsysMethod));
     $this->redsysMethod->expects($this->any())->method('setDsHour')->with($this->equalTo($dsHour))->will($this->returnValue($this->redsysMethod));
     $this->redsysMethod->expects($this->any())->method('setDsSecurePayment')->with($this->equalTo($dsSecurePayment))->will($this->returnValue($this->redsysMethod));
     $this->paymentEventDispatcher->expects($this->once())->method('notifyPaymentOrderDone')->with($this->equalTo($this->paymentBridge));
     $this->paymentEventDispatcher->expects($this->once())->method('notifyPaymentOrderSuccess')->with($this->equalTo($this->paymentBridge));
     $this->redsysManager->processResult($parameters);
 }
Пример #22
0
 /**
  * Given a paymillTransaction response, as an array, prform desired operations
  *
  * @param Transaction   $transaction   Transaction
  * @param PaymillMethod $paymentMethod Payment method
  *
  * @return PaymillManager Self object
  *
  * @throws PaymentException
  */
 private function processTransaction(Transaction $transaction, PaymillMethod $paymentMethod)
 {
     /**
      * Payment paid done
      *
      * Paid process has ended ( No matters result )
      */
     $this->paymentEventDispatcher->notifyPaymentOrderDone($this->paymentBridge, $paymentMethod);
     /**
      * when a transaction is successful, it is marked as 'closed'
      */
     $transactionStatus = $transaction->getStatus();
     if (empty($transactionStatus) || $transactionStatus != 'closed') {
         /**
          * Payment paid failed
          *
          * Paid process has ended failed
          */
         $paymentMethod->setTransaction($transaction);
         $this->paymentEventDispatcher->notifyPaymentOrderFail($this->paymentBridge, $paymentMethod);
         throw new PaymentException();
     }
     /**
      * Adding to PaymentMethod transaction information
      *
      * This information is only available in PaymentOrderSuccess event
      */
     $paymentMethod->setTransactionId($transaction->getId())->setTransactionStatus($transactionStatus)->setTransaction($transaction);
     /**
      * Payment paid successfully
      *
      * Paid process has ended successfully
      */
     $this->paymentEventDispatcher->notifyPaymentOrderSuccess($this->paymentBridge, $paymentMethod);
     return $this;
 }
Пример #23
0
 /**
  *
  * @param $result \soap response
  * @param DineromailApiMethod $paymentMethod Payment method
  *
  * @throws \PaymentSuite\PaymentCoreBundle\Exception\PaymentException
  * @return DineromailApiMethod                                        Self object
  *
  */
 private function processTransaction($result, DineromailApiMethod $paymentMethod)
 {
     $this->logger->addInfo($paymentMethod->getPaymentName() . 'processTransaction Result', get_object_vars($result));
     $paymentMethod->setDineromailApiReference($result->MerchantTransactionId);
     $paymentMethod->setDineromailApiTransactionId($result->TransactionId);
     /**
      * Payment paid done
      *
      * Paid process has ended ( No matters result )
      */
     $this->paymentEventDispatcher->notifyPaymentOrderDone($this->paymentBridge, $paymentMethod);
     switch ($result->Status) {
         case 'OK':
         case 'COMPLETED':
             $this->paymentEventDispatcher->notifyPaymentOrderSuccess($this->paymentBridge, $paymentMethod);
             break;
         case 'PENDING':
             break;
         default:
             $this->paymentEventDispatcher->notifyPaymentOrderFail($this->paymentBridge, $paymentMethod);
             throw new PaymentException();
     }
     return $this;
 }
Пример #24
0
 /**
  * Check transaction status
  *
  * @param string $transactionId Payu transaction ID
  */
 public function checkTransactionStatus($transactionId)
 {
     /** @var TransactionResponseDetailDetails $details */
     $details = $this->detailsFactory->create(PayuDetailsTypes::TYPE_TRANSACTION_RESPONSE_DETAIL);
     $details->setTransactionId($transactionId);
     /** @var $request TransactionResponseDetailRequest */
     $request = $this->requestFactory->create(PayuRequestTypes::TYPE_TRANSACTION_RESPONSE_DETAIL);
     $request->setDetails($details);
     try {
         $payload = $this->processTransactionResponseDetailRequest($request);
         $paymentMethod = new PayuMethod();
         $paymentMethod->setTransactionId($transactionId)->setState($payload->getState())->setResponseMessage($payload->getResponseMessage())->setResponseCode($payload->getResponseCode())->setPaymentNetworkResponseErrorMessage($payload->getPaymentNetworkResponseErrorMessage())->setAuthorizationCode($payload->getAuthorizationCode())->setExtraParameters($payload->getExtraParameters())->setOperationDate($payload->getOperationDate())->setPaymentNetworkResponseCode($payload->getPaymentNetworkResponseCode())->setTrazabilityCode($payload->getTrazabilityCode());
         switch ($payload->getState()) {
             case 'APPROVED':
                 $this->paymentEventDispatcher->notifyPaymentOrderLoad($this->paymentBridge, $paymentMethod);
                 $this->paymentEventDispatcher->notifyPaymentOrderSuccess($this->paymentBridge, $paymentMethod);
                 break;
             case 'PENDING':
                 break;
             default:
                 $this->paymentEventDispatcher->notifyPaymentOrderLoad($this->paymentBridge, $paymentMethod);
                 $this->paymentEventDispatcher->notifyPaymentOrderFail($this->paymentBridge, $paymentMethod);
                 break;
         }
     } catch (PaymentException $e) {
     }
 }
 /**
  * Testing notifyPaymentFail.
  */
 public function testNotifyPaymentOrderFail()
 {
     $this->eventDispatcher->expects($this->once())->method('dispatch')->with($this->equalTo(PaymentCoreEvents::PAYMENT_ORDER_FAIL), $this->isInstanceOf('PaymentSuite\\PaymentCoreBundle\\Event\\PaymentOrderFailEvent'));
     $paymentEventDispatcher = new PaymentEventDispatcher($this->eventDispatcher);
     $paymentEventDispatcher->notifyPaymentOrderFail($this->paymentBridge, $this->paymentMethod);
 }