Beispiel #1
0
 /**
  * Check and set param for payment
  *
  * @param StripeMethod $paymentMethod Payment method
  * @param float        $amount        Amount
  *
  * @return StripeManager self Object
  *
  * @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 = array('number' => $paymentMethod->getCreditCartNumber(), 'exp_month' => $paymentMethod->getCreditCartExpirationMonth(), 'exp_year' => $paymentMethod->getCreditCartExpirationYear());
     $this->chargeParams = array('card' => $cardParams, 'amount' => $cartAmount, 'currency' => strtolower($this->paymentBridge->getCurrency()));
     return $this;
 }
 /**
  * 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;
 }
 /**
  * Builds form given return, success and fail urls.
  *
  * @return FormView
  */
 public function buildForm()
 {
     $formBuilder = $this->formFactory->createNamedBuilder(null);
     $orderId = $this->paymentBridge->getOrderId();
     $orderCurrency = $this->paymentBridge->getCurrency();
     $this->checkCurrency($orderCurrency);
     /**
      * Creates the success return route, when coming back
      * from PayPal web checkout.
      */
     $successReturnUrl = $this->urlFactory->getSuccessReturnUrlForOrderId($orderId);
     /**
      * Creates the cancel payment route, when cancelling
      * the payment process from PayPal web checkout.
      */
     $cancelReturnUrl = $this->urlFactory->getCancelReturnUrlForOrderId($orderId);
     /**
      * Creates the IPN payment notification route,
      * which is triggered after PayPal processes the
      * payment and returns the validity of the transaction.
      *
      * For forther information
      *
      * https://developer.paypal.com/docs/classic/ipn/integration-guide/IPNandPDTVariables/
      * https://developer.paypal.com/webapps/developer/docs/classic/ipn/integration-guide/IPNIntro/
      */
     $processUrl = $this->urlFactory->getProcessUrlForOrderId($orderId);
     $formBuilder->setAction($this->urlFactory->getApiEndpoint())->setMethod('POST')->add('business', 'hidden', ['data' => $this->business])->add('return', 'hidden', ['data' => $successReturnUrl])->add('cancel_return', 'hidden', ['data' => $cancelReturnUrl])->add('notify_url', 'hidden', ['data' => $processUrl])->add('currency_code', 'hidden', ['data' => $orderCurrency])->add('env', 'hidden', ['data' => '']);
     /**
      * Create a PayPal cart line for each order line.
      *
      * Project specific PaymentBridgeInterface::getExtraData
      * should return an array of this form
      *
      *   ['items' => [
      *       0 => [ 'item_name' => 'Item 1', 'amount' => 1234, 'quantity' => 2 ],
      *       1 => [ 'item_name' => 'Item 2', 'amount' => 2345, 'quantity' => 1 ],
      *   ]]
      *
      * The 'items' key consists of an array with the basic information
      * of each line of the order. Amount is the price of the product,
      * not the total of the order line
      */
     $cartData = $this->paymentBridge->getExtraData();
     $itemsData = $cartData['items'];
     $iteration = 1;
     foreach ($itemsData as $orderLine) {
         $formBuilder->add('item_name_' . $iteration, 'hidden', ['data' => $orderLine['item_name']])->add('amount_' . $iteration, 'hidden', ['data' => $orderLine['amount'] / 100])->add('quantity_' . $iteration, 'hidden', ['data' => $orderLine['quantity']]);
         ++$iteration;
     }
     if (isset($cartData['discount_amount_cart'])) {
         $formBuilder->add('discount_amount_cart', 'hidden', ['data' => $cartData['discount_amount_cart'] / 100]);
     }
     return $formBuilder->getForm()->createView();
 }
Beispiel #4
0
 /**
  * Generate log transaction file for KCC
  *
  * @return string TBK Session Id
  */
 public function processPayment()
 {
     $orderId = $this->paymentBridge->getOrderId();
     $amount = $this->paymentBridge->getAmount();
     $sessionId = $orderId . date('Ymdhis');
     // Generate session log file for KCC
     $file = fopen($this->kccPath . '/log/datos' . $sessionId . '.log', 'w');
     $line = $amount . ';' . $orderId;
     fwrite($file, $line);
     fclose($file);
     return $sessionId;
 }
 /**
  * Payment execution.
  *
  * @param Request $request Request element
  *
  * @return RedirectResponse
  */
 public function resultAction(Request $request)
 {
     $redirectRoute = $this->redirectionRoutes->getRedirectionRoute('success');
     try {
         $this->redsysManager->processResult($request->request->all());
     } catch (PaymentException $e) {
         /**
          * Must redirect to fail route.
          */
         $redirectRoute = $this->redirectionRoutes->getRedirectionRoute('failure');
     }
     $redirectUrl = $this->urlGenerator->generate($redirectRoute->getRoute(), $redirectRoute->getRouteAttributes($this->paymentBridge->getOrderId()));
     return new RedirectResponse($redirectUrl);
 }
Beispiel #6
0
 /**
  * Tries to process a payment through Banwire
  *
  * @param BanwireMethod $paymentMethod Payment method
  * @param float         $amount        Amount
  *
  * @return BanwireManager Self object
  *
  * @throws PaymentAmountsNotMatchException
  * @throws PaymentOrderNotFoundException
  * @throws PaymentException
  */
 public function processPayment(BanwireMethod $paymentMethod, $amount)
 {
     /**
      * first check that amounts are the same
      */
     $paymentBridgeAmount = intval($this->paymentBridge->getAmount());
     /**
      * If both amounts are different, execute Exception
      */
     if ($amount != $paymentBridgeAmount) {
         throw new PaymentAmountsNotMatchException(sprintf('Amounts differ. Requested: [%s] but in PaymentBridge: [%s].', $amount, $paymentBridgeAmount));
     }
     /**
      * At this point, order must be created given a cart, and placed in PaymentBridge
      *
      * So, $this->paymentBridge->getOrder() must return an object
      */
     $this->paymentEventDispatcher->notifyPaymentOrderLoad($this->paymentBridge, $paymentMethod);
     /**
      * Order Not found Exception must be thrown just here
      */
     if (!$this->paymentBridge->getOrder()) {
         throw new PaymentOrderNotFoundException();
     }
     $this->paymentEventDispatcher->notifyPaymentOrderCreated($this->paymentBridge, $paymentMethod);
     $extraData = $this->paymentBridge->getExtraData();
     $carExp = substr($paymentMethod->getCardExpYear(), -2);
     $params = array('response_format' => 'JSON', 'user' => $this->user, 'reference' => $this->paymentBridge->getOrderId() . '#' . date('Ymdhis'), 'currency' => $this->paymentBridge->getCurrency(), 'ammount' => number_format($this->paymentBridge->getAmount() / 100, 2), 'concept' => $this->paymentBridge->getOrderDescription(), 'card_num' => $paymentMethod->getCardNum(), 'card_name' => $paymentMethod->getCardName(), 'card_type' => $paymentMethod->getCardType(), 'card_exp' => $paymentMethod->getCardExpMonth() . '/' . $carExp, 'card_ccv2' => $paymentMethod->getCardSecurity(), 'address' => $extraData['correspondence_address'], 'post_code' => $extraData['customer_postal_code'], 'phone' => $extraData['customer_phone'], 'mail' => $extraData['customer_email']);
     $host = $this->api;
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $host);
     curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 6.0; WINDOWS; .NET CLR 1.1.4322)');
     curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
     curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
     curl_setopt($ch, CURLOPT_TIMEOUT, 30);
     curl_setopt($ch, CURLOPT_HEADER, 0);
     curl_setopt($ch, CURLOPT_POST, 1);
     curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params));
     if (defined('CURLOPT_ENCODING')) {
         curl_setopt($ch, CURLOPT_ENCODING, "");
     }
     $responseApi = curl_exec($ch);
     $this->processTransaction($responseApi, $paymentMethod);
     return $this;
 }
 /**
  * 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;
 }
Beispiel #8
0
 /**
  * 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;
 }
 /**
  * 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;
 }
 /**
  * @param array() $items
  * @param array() $buyer
  * @param array() $creditCard
  * @param string  $cardType
  *
  * @return object
  */
 private function processSoap($items, $buyer, $creditCard, $cardType)
 {
     $provider = $this->apiPrefix . $cardType;
     $subject = '';
     $message = '';
     if ($this->dineromail_api_debug) {
         // this is a debug environment
         //to debug dineromail API, we use the credit card select
         //to map success/fail values to pass to the transaction_id
         //field, which dineromail API uses
         switch ($cardType) {
             case 'VISA':
                 // OK
                 $merchantTransactionId = '1';
                 break;
             case 'MASTER':
                 // DENIED
                 $merchantTransactionId = '2';
                 break;
             case 'AMEX':
                 // ERROR
                 $merchantTransactionId = '3';
                 break;
             default:
                 // ERROR
                 $merchantTransactionId = '4';
                 break;
         }
     } else {
         $merchantTransactionId = $this->paymentBridge->getOrderId() . '#' . date('Ymdhis');
     }
     $uniqueMessageId = date('Ymdhis') . str_pad(rand(0, 999), 3, '0', STR_PAD_LEFT);
     $stringItems = '';
     $soapItems = array();
     foreach ($items as &$item) {
         /* UGLY HACK NEEDED UNTIL PAYMENTBRIDGE HIERARCHY WILL BE REFACTORED */
         $item['Amount'] = number_format($item['Amount'] / 100, 2, '.', '');
         $stringItems .= $item['Amount'] . $item['Code'] . $item['Currency'] . $item['Description'] . $item['Name'] . $item['Quantity'];
         $soapItems[] = $this->soapVar($item, 'Item');
     }
     $stringBuyer = $buyer['Name'] . $buyer['LastName'] . $buyer['Email'] . $buyer['Address'] . $buyer['Phone'] . $buyer['Country'] . $buyer['City'];
     $stringCreditCard = $creditCard['Installment'] . $creditCard['CreditCardNumber'] . $creditCard['Holder'] . $creditCard['ExpirationDate'] . $creditCard['SecurityCode'] . $creditCard['DocumentNumber'] . $creditCard['Address'] . $creditCard['AddressNumber'] . $creditCard['AddressComplement'] . $creditCard['ZipCode'] . $creditCard['Neighborhood'] . $creditCard['City'] . $creditCard['State'] . $creditCard['Country'];
     $cadena = $merchantTransactionId . $uniqueMessageId . $stringItems . $stringBuyer . $stringCreditCard . $provider . $subject . $message . $this->apiPassword;
     $hash = MD5($cadena);
     $client = new \SoapClient($this->wsdl, array('trace' => 1, 'exceptions' => 1));
     $soapCredentials = $this->soapVar(array('APIUserName' => $this->apiUserName, 'APIPassword' => $this->apiPassword), 'APICredential');
     $soapBuyer = $this->soapVar($buyer, 'Buyer');
     $soapCreditCard = $this->soapVar($creditCard, 'CreditCard');
     $request = array('Credential' => $soapCredentials, 'Crypt' => false, 'MerchantTransactionId' => $merchantTransactionId, 'Items' => $soapItems, 'Buyer' => $soapBuyer, 'Provider' => $provider, 'CreditCard' => $soapCreditCard, 'Subject' => $subject, 'Message' => $message, 'UniqueMessageId' => $uniqueMessageId, 'Hash' => $hash);
     $this->logger->addInfo('Request Send DineromailApi' . 'processTransaction Response', $request);
     return $client->DoPAymentWithCreditCard($request)->DoPaymentWithCreditCardResult;
 }
Beispiel #11
0
 /**
  * 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;
 }
 /**
  * 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);
 }
 /**
  * Test form creation
  */
 public function testFormCreation()
 {
     $amount = 100;
     $formData = array('Ds_Merchant_Amount' => $amount, 'Ds_Merchant_MerchantSignature' => 'CB43B12351A9826D9640CC285CBDFD8CA6A5994C', 'Ds_Merchant_MerchantCode' => $this::merchantCode, 'Ds_Merchant_Currency' => '978', 'Ds_Merchant_Terminal' => $this::terminal, 'Ds_Merchant_Order' => '342', 'Ds_Merchant_MerchantURL' => '/payment/redsys/result', 'Ds_Merchant_UrlOK' => '/payment/redsys/checkout/ok', 'Ds_Merchant_UrlKO' => '/payment/redsys/checkout/ko', 'Ds_Merchant_TransactionType' => $this::transactionType, 'Ds_Merchant_ProductDescription' => $this::prodDesc, 'Ds_Merchant_Titular' => $this::titular, 'Ds_Merchant_MerchantName' => $this::name);
     $this->paymentBridge->expects($this->once())->method('getExtraData')->will($this->returnValue(array('terminal' => $this::terminal, 'transaction_type' => $this::transactionType, 'product_description' => $this::prodDesc, 'merchant_titular' => $this::titular, 'merchant_name' => $this::name)));
     $this->paymentBridge->expects($this->once())->method('getAmount')->will($this->returnValue($amount));
     $this->paymentBridge->expects($this->once())->method('getOrderNumber')->will($this->returnValue('342'));
     $this->paymentBridge->expects($this->once())->method('getCurrency')->will($this->returnValue('EUR'));
     $this->urlFactory->expects($this->once())->method('getReturnUrlOkForOrderId')->will($this->returnValue('/payment/redsys/checkout/ok'));
     $this->urlFactory->expects($this->once())->method('getReturnUrlKoForOrderId')->will($this->returnValue('/payment/redsys/checkout/ko'));
     $this->urlFactory->expects($this->once())->method('getReturnRedsysUrl')->will($this->returnValue('/payment/redsys/result'));
     $formView = $this->redsysFormTypeWrapper->buildForm();
     $children = $formView->children;
     foreach (array_keys($formData) as $key) {
         $this->assertArrayHasKey($key, $children);
         $message = $formData[$key] . ':::' . $children[$key]->vars['value'];
         $this->assertEquals($formData[$key], $children[$key]->vars['value'], $message);
     }
 }
 /**
  * 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;
 }
 /**
  * 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);
 }
Beispiel #16
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;
 }
 /**
  * Check if transaction is complete.
  *
  * When we receive an IPN response, we should
  * check that the price paid corresponds to the
  * amount stored in the PaymentMethod. This double
  * check is essential since the web checkout form
  * could be mangled.
  *
  * @link https://developer.paypal.com/docs/classic/ipn/integration-guide/IPNIntro/
  *
  * @param array $ipnParameters Paypal IPN parameters
  *
  * @return bool
  */
 private function transactionSuccessful($ipnParameters)
 {
     /**
      * First of all we have to check the validity of the IPN
      * message. We need to send back the contents of the query
      * string coming from Paypal's IPN message.
      */
     $ipnNotifyValidateUrl = $this->urlFactory->getApiEndpoint() . '?' . http_build_query(array_merge($this->urlFactory->getPaypalNotifyValidateQueryParam(), $ipnParameters));
     $ipnValidated = file_get_contents($ipnNotifyValidateUrl) == 'VERIFIED';
     /**
      * Matching paid amount with the originating order amount,
      * this is a security check to prevent frauds by manually
      * changing the papal form.
      */
     $amountMatches = $this->paymentBridge->getAmount() / 100 == $ipnParameters['mc_gross'];
     $amountMatches = $amountMatches && $this->paymentBridge->getCurrency() == $ipnParameters['mc_currency'];
     /**
      * When a transaction is successful, payment_status has a 'Completed' value.
      */
     return $amountMatches && $ipnValidated && strcmp($ipnParameters['payment_status'], 'Completed') === 0;
 }
 /**
  * Payment execution.
  *
  * @param Request $request Request element
  *
  * @return RedirectResponse
  *
  * @throws PaymentException
  */
 public function executeAction(Request $request)
 {
     /**
      * @var FormInterface $form
      */
     $form = $this->formFactory->create('stripe_view');
     $form->handleRequest($request);
     $redirect = $this->redirectionRoutes->getRedirectionRoute('success');
     try {
         if (!$form->isValid()) {
             throw new PaymentException();
         }
         $data = $form->getData();
         $paymentMethod = $this->createStripeMethod($data);
         $this->stripeManager->processPayment($paymentMethod, $data['amount']);
     } catch (Exception $e) {
         /**
          * Must redirect to fail route.
          */
         $redirect = $this->redirectionRoutes->getRedirectionRoute('failure');
     }
     $redirectUrl = $this->urlGenerator->generate($redirect->getRoute(), $redirect->getRouteAttributes($this->paymentBridge->getOrderId()));
     return new RedirectResponse($redirectUrl);
 }
Beispiel #19
0
 /**
  * Render stripe scripts view
  *
  * @return string js code needed by Stripe behaviour
  */
 public function renderPaymentScripts()
 {
     return $this->environment->display($this->scriptsTemplate, array('public_key' => $this->publicKey, 'currency' => $this->paymentBridgeInterface->getCurrency()));
 }
 /**
  * Buildform function
  *
  * @param FormBuilderInterface $builder the formBuilder
  * @param array                $options the options for this form
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->setAction($this->router->generate($this->controllerRouteName, array(), true))->setMethod('POST')->add('amount', 'hidden', array('data' => $this->paymentBridge->getAmount()))->add('currency', 'hidden', array('data' => $this->paymentBridge->getCurrency()))->add('paypal_express_params', 'hidden', array('data' => $options['paypal_express_params']))->add('submit', 'submit');
 }
 /**
  * Free Payment execution.
  *
  * @return RedirectResponse
  */
 public function executeAction()
 {
     $this->freePaymentManager->processPayment();
     $successUrl = $this->urlGenerator->generate($this->successRedirectionRoute->getRoute(), $this->successRedirectionRoute->getRouteAttributes($this->paymentBridge->getOrderId()));
     return new RedirectResponse($successUrl);
 }
 /**
  * Return stripe script
  *
  * @return string Stripe script
  */
 protected function getStripeScript()
 {
     $currency = $this->paymentBridgeInterface->getCurrency();
     return $this->templating->render('StripeBundle:Stripe:scripts.html.twig', ['public_key' => $this->publicKey, 'currency' => $currency]);
 }
 /**
  * Render stripe scripts.
  *
  * @param Twig_Environment $environment Environment
  */
 public function renderStripeScripts(Twig_Environment $environment)
 {
     $environment->display($this->scriptsTemplate, ['public_key' => $this->publicKey, 'currency' => $this->paymentBridgeInterface->getCurrency()]);
 }
Beispiel #24
0
 /**
  * Buildform function
  *
  * @param FormBuilderInterface $builder the formBuilder
  * @param array                $options the options for this form
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->setAction($this->router->generate($this->controllerRouteName, array(), true))->setMethod('POST')->add('card_type', 'choice', array('required' => true, 'choices' => array('visa' => 'Visa', 'mastercard' => 'MasterCard', 'amex' => 'American Express')))->add('card_name', 'text', array('required' => true))->add('card_num', 'text', array('required' => true, 'max_length' => 16))->add('card_exp_month', 'choice', array('required' => true, 'choices' => array_combine(range(1, 12), range(1, 12))))->add('card_exp_year', 'choice', array('required' => true, 'choices' => array_combine(range(2013, 2025), range(2013, 2025))))->add('card_ccv2', 'text', array('required' => true, 'max_length' => 4))->add('amount', 'hidden', array('data' => $this->paymentBridge->getAmount()))->add('submit', 'submit');
 }
 /**
  * Build form function
  *
  * @param FormBuilderInterface $builder the formBuilder
  * @param array                $options the options for this form
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('credit_card', 'text', array('required' => true, 'max_length' => 20))->add('credit_cart_security', 'text', array('required' => true, 'max_length' => 4))->add('credit_cart_expiration_month', 'choice', array('required' => true, 'choices' => array_combine(range(1, 12), range(1, 12))))->add('credit_cart_expiration_year', 'choice', array('required' => true, 'choices' => array_combine(range(date('Y'), 2025), range(date('Y'), 2025))))->add('amount', 'hidden', array('data' => $this->paymentBridge->getAmount()));
 }
Beispiel #26
0
 /**
  * Buildform function
  *
  * @param FormBuilderInterface $builder the formBuilder
  * @param array                $options the options for this form
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->setAction($this->router->generate($this->controllerRouteName, array(), true))->setMethod('POST')->add('credit_card_1', 'text', array('required' => true, 'max_length' => 4))->add('credit_card_2', 'text', array('required' => true, 'max_length' => 4))->add('credit_card_3', 'text', array('required' => true, 'max_length' => 4))->add('credit_card_4', 'text', array('required' => true, 'max_length' => 4))->add('credit_card_owner', 'text', array('required' => true))->add('credit_card_expiration_month', 'choice', array('required' => true, 'choices' => array_combine(range(1, 12), range(1, 12))))->add('credit_card_expiration_year', 'choice', array('required' => true, 'choices' => array_combine(range(date('Y'), 2025), range(date('Y'), 2025))))->add('credit_card_security', 'text', array('required' => true, 'max_length' => 4))->add('amount', 'hidden', array('data' => $this->paymentBridge->getAmount()))->add('api_token', 'hidden', array('data' => ''))->add('submit', 'submit', array('label' => $this->submitLabel, 'attr' => array('class' => $this->submitCssClass)));
 }
Beispiel #27
0
 /**
  * Render banwire scripts view
  */
 public function renderPaymentScripts()
 {
     $this->environment->display('BanwireBundle:Banwire:scripts.html.twig', array('currency' => $this->paymentBridgeInterface->getCurrency()));
 }
 /**
  * Builds form given session ID and success and fail routes
  *
  * @param string $sessionId Session ID
  * @param string $okRoute   Ok route
  * @param string $failRoute Fail route
  *
  * @return FormBuilderInterface
  */
 public function buildForm($sessionId, $okRoute, $failRoute)
 {
     $formBuilder = $this->formFactory->createNamedBuilder(null)->setAction($this->cgiUri . '/tbk_bp_pago.cgi')->setMethod('POST')->add('TBK_TIPO_TRANSACCION', 'hidden', array('data' => 'TR_NORMAL'))->add('TBK_MONTO', 'hidden', array('data' => $this->paymentBridge->getAmount()))->add('TBK_ORDEN_COMPRA', 'hidden', array('data' => $this->paymentBridge->getOrderId()))->add('TBK_ID_SESION', 'hidden', array('data' => $sessionId))->add('TBK_URL_EXITO', 'hidden', array('data' => $okRoute))->add('TBK_URL_FRACASO', 'hidden', array('data' => $failRoute));
     return $formBuilder;
 }
 /**
  * Build form function
  *
  * @param FormBuilderInterface $builder the formBuilder
  * @param array                $options the options for this form
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('credit_card_owner', 'text', array('required' => false))->add('credit_card', 'text', array('max_length' => 20, 'required' => false))->add('credit_card_security', 'text', array('required' => false, 'max_length' => 4))->add('credit_card_expiration_month', 'choice', array('required' => false, 'choices' => array_combine(range(1, 12), range(1, 12))))->add('credit_card_expiration_year', 'choice', array('required' => false, 'choices' => array_combine(range(date('Y'), 2025), range(date('Y'), 2025))))->add('amount', 'hidden', array('required' => true, 'data' => $this->paymentBridge->getAmount()))->add('additionalData', 'hidden', array('required' => false))->add('generationDate', 'hidden', array('required' => false, 'attr' => ['data-encrypted-name' => 'generationtime']));
 }