コード例 #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;
 }
コード例 #2
0
 /**
  * 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();
 }
コード例 #3
0
 /**
  * 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
ファイル: BanwireManager.php プロジェクト: hason/paymentsuite
 /**
  * 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
ファイル: RedsysManager.php プロジェクト: alexdw/paymentsuite
 /**
  * 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;
 }
コード例 #7
0
ファイル: WebpayManager.php プロジェクト: hason/paymentsuite
 /**
  * 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;
 }
コード例 #8
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;
 }
コード例 #9
0
 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);
     }
 }
コード例 #10
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 $response)
 {
     //Check we receive all needed parameters
     $Ds_Signature = $response['Ds_Signature'];
     $parameters = (array) json_decode(base64_decode($response['Ds_MerchantParameters']));
     $parameters = array_change_key_case($parameters, CASE_UPPER);
     $this->checkResultParameters($parameters);
     $redsysMethod = new RedsysMethod();
     $dsSignature = $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'] : '';
     $dsMerchantData = array_key_exists('DS_MERCHANTDATA', $parameters) ? $parameters['DS_MERCHANTDATA'] : '';
     $internalSignature = $this->redsysSignature->sign($dsOrder, $dsSecret, $response['Ds_MerchantParameters']);
     /**
      * Validate if signature from Redsys and our signature are identical,
      */
     $this->redsysSignature->checkSign($dsSignature, $internalSignature);
     /**
      * 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
      */
     $this->transactionSuccessful($dsResponse, $redsysMethod);
     /**
      * Payment paid successfully
      *
      * Paid process has ended successfully
      */
     $this->paymentEventDispatcher->notifyPaymentOrderSuccess($this->paymentBridge, $redsysMethod);
     return $this;
 }
コード例 #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
 /**
  * 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);
             }
         }
     }
 }
コード例 #13
0
 /**
  * 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);
 }
コード例 #14
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;
 }
コード例 #15
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;
 }
コード例 #16
0
 /**
  * Tries to process a payment through Stripe.
  *
  * @param StripeMethod $paymentMethod Payment method
  * @param float        $amount        Amount
  *
  * @throws PaymentAmountsNotMatchException
  * @throws PaymentException
  *
  * @return StripeManager Self object
  */
 public function processPayment(StripeMethod $paymentMethod, $amount)
 {
     /**
      * check and set payment data.
      */
     $chargeParams = $this->prepareData($paymentMethod, $amount);
     /**
      * make payment.
      */
     $transaction = $this->transactionFactory->create($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 ($transaction['paid'] != 1) {
         /**
          * Payment paid failed.
          *
          * Paid process has ended failed
          */
         $this->paymentEventDispatcher->notifyPaymentOrderFail($this->paymentBridge, $paymentMethod);
         throw new PaymentException();
     }
     $paymentMethod->setTransactionId($transaction['id'])->setTransactionStatus('paid')->setTransactionResponse($transaction);
     /**
      * Payment paid successfully.
      *
      * Paid process has ended successfully
      */
     $this->paymentEventDispatcher->notifyPaymentOrderSuccess($this->paymentBridge, $paymentMethod);
     return $this;
 }
コード例 #17
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;
 }
コード例 #18
0
ファイル: PaymillManager.php プロジェクト: hason/paymentsuite
 /**
  * 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;
 }
コード例 #19
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;
 }
コード例 #20
0
 /**
  * Testing notifyPaymentSuccess.
  */
 public function testNotifyPaymentOrderSuccess()
 {
     $this->eventDispatcher->expects($this->once())->method('dispatch')->with($this->equalTo(PaymentCoreEvents::PAYMENT_ORDER_SUCCESS), $this->isInstanceOf('PaymentSuite\\PaymentCoreBundle\\Event\\PaymentOrderSuccessEvent'));
     $paymentEventDispatcher = new PaymentEventDispatcher($this->eventDispatcher);
     $paymentEventDispatcher->notifyPaymentOrderSuccess($this->paymentBridge, $this->paymentMethod);
 }
コード例 #21
0
ファイル: PayuManager.php プロジェクト: hason/PayUBundle
 /**
  * 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) {
     }
 }