/** * Tries to process a payment through Bankwire * * @return BankwireManager Self object * * @throws PaymentOrderNotFoundException */ public function processPayment() { $bankwireMethod = $this->bankwireMethodWrapper->getBankwireMethod(); /** * 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, $bankwireMethod); /** * 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, $bankwireMethod); /** * Payment paid done * * Paid process has ended ( No matters result ) */ $this->paymentEventDispatcher->notifyPaymentOrderDone($this->paymentBridge, $bankwireMethod); return $this; }
/** * 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; }
/** * 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())]; }
/** * Check and set param for payment * * @param AuthorizenetMethod $paymentMethod Payment method * * @return AuthorizenetManager self Object * * @throws PaymentAmountsNotMatchException * @throws PaymentOrderNotFoundException */ private function prepareData(AuthorizenetMethod $paymentMethod) { $cartAmount = (double) number_format($this->paymentBridge->getAmount() / 100, 2, '.', ''); /** * 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 authorizenet interaction */ $extraData = $this->paymentBridge->getExtraData(); $postValues = array("x_login" => $this->loginId, "x_tran_key" => $this->transactionKey, "x_version" => "3.1", "x_delim_data" => "TRUE", "x_delim_char" => "|", "x_relay_response" => "FALSE", "x_type" => "AUTH_CAPTURE", "x_method" => "CC", "x_card_num" => $paymentMethod->getCreditCartNumber(), "x_exp_date" => $paymentMethod->getCreditCartExpirationMonth() . $paymentMethod->getCreditCartExpirationYear(), "x_amount" => $cartAmount, "x_description" => $extraData['order_description']); $this->chargeParams = $this->convertPostValues($postValues); return $this; }
/** * Generate token to make the payment request * * @return string */ public function generateToken() { $extraData = $this->paymentBridge->getExtraData(); $cartAmount = (double) number_format($this->paymentBridge->getAmount() / 100, 2, '.', ''); $payload = new Payload(); $payload->setIssuedAt(time()); $payload->setExpiration(time() + 3600); $payload->addProperty("name", $extraData['order_name']); $payload->addProperty("description", $extraData['order_description']); $payload->addProperty("price", $cartAmount); $payload->addProperty("currencyCode", $this->paymentBridge->getCurrency()); $token = $payload->CreatePayload($this->merchantId); $jwtToken = JWTHelper::encode($token, $this->secretKey); $paymentMethod = new GoogleWalletMethod(); $paymentMethod->setApiToken($jwtToken); $this->paymentEventDispatcher->notifyPaymentOrderLoad($this->paymentBridge, $paymentMethod); return $jwtToken; }
/** * 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; }
/** * 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; }
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); } }
/** * @param PaymentMethodInterface $method * @param integer $amount * * @throws PaymentException */ public function processPayment(PaymentMethodInterface $method, $amount) { /** * @var RedsysApiMethod $method */ $paymentData = array('number' => $method->getCreditCartNumber(), 'holder' => $method->getCreditCartOwner(), 'expiration' => sprintf('%s%s', substr($method->getCreditCartExpirationYear(), -2, 2), str_pad($method->getCreditCartExpirationMonth(), 2, '0', STR_PAD_LEFT)), 'cvc' => $method->getCreditCartSecurity(), 'amount' => $amount); $this->setPayment($paymentData); try { $r = $this->_callSoap(); } catch (\Exception $e) { /* * The Soap call failed */ $this->eventDispatcher->notifyPaymentOrderFail($this->paymentBridge, $method); throw new PaymentException($e->getMessage()); } $this->storeTransaction($r); $this->eventDispatcher->notifyPaymentOrderLoad($this->paymentBridge, $method); if (!$this->isAuthorized($r)) { $this->paymentBridge->setError($this->getError($r)); $this->paymentBridge->setErrorCode($this->getErrorCode($r)); /** * The payment was not successful */ $this->eventDispatcher->notifyPaymentOrderFail($this->paymentBridge, $method); throw new PaymentException($this->getErrorCode($r)); } /* * Everything is ok, emitting the * payment.order.create event */ $transaction = $this->getResponseData($r); $method->setTransactionId($transaction['DS_AUTHORISATIONCODE'])->setTransactionStatus('paid')->setTransactionResponse($transaction); $this->eventDispatcher->notifyPaymentOrderCreated($this->paymentBridge, $method); /* * Return if we are only authorizing, meaning * we don't have to fire a payment success * event */ if ($this->transactionType == '1') { return; } /** * Payment process has returned control */ $this->eventDispatcher->notifyPaymentOrderDone($this->paymentBridge, $method); /** * Payment paid successfully * * Paid process has ended successfully */ $this->eventDispatcher->notifyPaymentOrderSuccess($this->paymentBridge, $method); }
/** * Creates form view for Redsys payment * * @return \Symfony\Component\Form\FormView * * @throws PaymentOrderNotFoundException */ public function processPayment() { $redsysMethod = new RedsysMethod(); /** * 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, $redsysMethod); /** * 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, $redsysMethod); $formView = $this->redsysFormTypeWrapper->buildForm(); return $formView; }
/** * 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; }
/** * Tries to process a payment through Paymill * * @param PaymillMethod $paymentMethod Payment method * @param integer $amount Amount * * @return PaymillManager Self object * * @throws PaymentAmountsNotMatchException * @throws PaymentOrderNotFoundException * @throws PaymentException */ public function processPayment(PaymillMethod $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 card, 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 paymill interaction */ $extraData = $this->paymentBridge->getExtraData(); $params = array('amount' => $paymentBridgeAmount, 'currency' => $this->paymentBridge->getCurrency(), 'token' => $paymentMethod->getApiToken(), 'description' => $extraData['order_description']); try { $transaction = $this->paymillTransactionWrapper->create($params['amount'], $params['currency'], $params['token'], $params['description']); } catch (PaymillException $e) { /** * create 'failed' transaction */ $transaction = new Transaction(); $transaction->setStatus('failed'); $transaction->setDescription($e->getCode() . ' ' . $e->getMessage()); } $this->processTransaction($transaction, $paymentMethod); return $this; }
/** * 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); } } } }
/** * Dispatches order load event and prepares paypal form for submission. * * This is a synchronous action that takes place on the implementor * side, i.e. right after click the "pay with checkout" button it the * final stage of a checkout process. * * See documentation for PaypalWebCheckout Api Integration at * * @link https://developer.paypal.com/docs/integration/web/web-checkout/ * * @throws PaymentOrderNotFoundException * * @return \Symfony\Component\Form\FormView */ public function generatePaypalForm() { $paypalMethod = $this->paymentMethodFactory->createEmpty(); /** * We expect listeners for the payment.order.load event * to store the Order into the bridge. * * So, $this->paymentBridge->getOrder() must return an object */ $this->paymentEventDispatcher->notifyPaymentOrderLoad($this->paymentBridge, $paypalMethod); /** * Order Not found Exception must be thrown just here. */ if (!$this->paymentBridge->getOrder()) { throw new PaymentOrderNotFoundException(); } /** * We expect the Order to be created and physically flushed. */ $this->paymentEventDispatcher->notifyPaymentOrderCreated($this->paymentBridge, $paypalMethod); return $this->formTypeFactory->buildForm(); }
/** * 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; }
/** * Tries to process a payment through DineromailApi * * @param DineromailApiMethod $paymentMethod Payment method * @param float $amount Amount * @param env * * @throws PaymentAmountsNotMatchException * @throws PaymentOrderNotFoundException * @return DineromailAPiManager Self object */ public function processPayment(DineromailApiMethod $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(); //params to send dineromailapi api $cardYear = substr($paymentMethod->getCardExpYear(), -2); $cardExp = str_pad($paymentMethod->getCardExpMonth(), 2, '0', STR_PAD_LEFT) . '/' . $cardYear; $items = array(); foreach ($extraData['dinero_mail_api_items'] as $key => $dineroMailApiItem) { $items[] = array('Amount' => $dineroMailApiItem['amount'], 'Currency' => $this->paymentBridge->getCurrency(), 'Code' => '', 'Description' => '', 'Name' => $dineroMailApiItem['name'], 'Quantity' => $dineroMailApiItem['quantity']); } $buyer = array('Name' => $extraData['customer_firstname'], 'LastName' => $extraData['customer_lastname'], 'Email' => $extraData['customer_email'], 'Address' => $extraData['correspondence_address'], 'Phone' => $extraData['customer_phone'], 'Country' => $extraData['customer_country'], 'City' => $extraData['correspondence_city']); $creditCard = array('Installment' => $paymentMethod->getCardQuota(), 'CreditCardNumber' => $paymentMethod->getCardNum(), 'Holder' => $paymentMethod->getCardName(), 'ExpirationDate' => $cardExp, 'SecurityCode' => $paymentMethod->getCardSecurity(), 'DocumentNumber' => '1234567', 'Address' => '', 'AddressNumber' => '', 'AddressComplement' => '', 'ZipCode' => '', 'Neighborhood' => '', 'City' => '', 'State' => '', 'Country' => ''); $result = $this->processSoap($items, $buyer, $creditCard, $paymentMethod->getCardType()); $this->processTransaction($result, $paymentMethod); return $this; }
/** * Testing notifyPaymentOrderLoad. */ public function testNotifyPaymentOrderLoad() { $this->eventDispatcher->expects($this->once())->method('dispatch')->with($this->equalTo(PaymentCoreEvents::PAYMENT_ORDER_LOAD), $this->isInstanceOf('PaymentSuite\\PaymentCoreBundle\\Event\\PaymentOrderLoadEvent')); $paymentEventDispatcher = new PaymentEventDispatcher($this->eventDispatcher); $paymentEventDispatcher->notifyPaymentOrderLoad($this->paymentBridge, $this->paymentMethod); }
/** * 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) { } }