/**
  * Send the confirmation message only if the order is paid.
  *
  * @param OrderEvent $event
  */
 public function checkSendOrderConfirmationMessageToCustomer(OrderEvent $event)
 {
     if (Paybox::getConfigValue('send_confirmation_email_on_successful_payment', false)) {
         $paybox = new Paybox();
         if ($paybox->isPaymentModuleFor($event->getOrder())) {
             if (!$event->getOrder()->isPaid()) {
                 $event->stopPropagation();
             }
         }
     }
 }
Example #2
0
 /**
  * Returns an array of POST parameters to use to redirect the customer to the 3D Secure authentication page.
  *
  * These parameters can be used to build a web form to post in the user's browser.
  *
  * @param Card  $card       The payment card.
  * @param Money $amount     The amount of the transaction.
  * @param string $sessionId A unique session ID of up to 250 chars.
  *                          This session ID will be returned in the callback,
  *                          and used to identify this 3D Secure authentication.
  *
  * @return array
  */
 public function getPostParameters(Card $card, Money $amount, $sessionId)
 {
     $parameters = ['Amount' => $amount->getAmount()->unscaledValue(), 'Currency' => $amount->getCurrency()->getNumericCode(), 'CCNumber' => $card->getNumber(), 'CCExpDate' => $card->getValidity(), 'CVVCode' => $card->getCvv(), 'IdMerchant' => $this->paybox->getIdentifier(), 'IdSession' => $sessionId];
     if ($this->callbackUrl !== null) {
         $parameters['URLHttpDirect'] = $this->callbackUrl;
     }
     if ($this->returnUrl !== null) {
         $parameters['URLRetour'] = $this->returnUrl;
     }
     return $parameters;
 }
Example #3
0
 /**
  * @param \Paybox\PayboxDirectRequest $request An instance of a Paybox request object.
  *
  * @return \Paybox\PayboxDirectResponse The Paybox response.
  *
  * @throws \GuzzleHttp\Exception\RequestException If the communication with the server fails.
  */
 public function execute(PayboxDirectRequest $request)
 {
     $values = $request->getValues();
     $values['SITE'] = $this->paybox->getSite();
     $values['RANG'] = $this->paybox->getRank();
     $values['VERSION'] = '00104';
     $values['DATEQ'] = gmdate('dmY');
     // dmYHis
     $values['NUMQUESTION'] = $this->getNumQuestion();
     $values['HASH'] = 'SHA512';
     $values['HMAC'] = $this->paybox->hashHMAC($values);
     $httpClient = new Client();
     $response = $httpClient->request('POST', $this->url, ['form_params' => $values]);
     $body = (string) $response->getBody();
     return new PayboxDirectResponse($body);
 }
 public function configure()
 {
     if (null !== ($response = $this->checkAuth(AdminResources::MODULE, 'Paybox', AccessManager::UPDATE))) {
         return $response;
     }
     // Create the Form from the request
     $configurationForm = new ConfigurationForm($this->getRequest());
     try {
         // Check the form against constraints violations
         $form = $this->validateForm($configurationForm, "POST");
         // Get the form field values
         $data = $form->getData();
         foreach ($data as $name => $value) {
             if (is_array($value)) {
                 $value = implode(';', $value);
             }
             Paybox::setConfigValue($name, $value);
         }
         // Log configuration modification
         $this->adminLogAppend("paybox.configuration.message", AccessManager::UPDATE, sprintf("Paybox configuration updated"));
         // Redirect to the success URL,
         if ($this->getRequest()->get('save_mode') == 'stay') {
             // If we have to stay on the same page, redisplay the configuration page/
             $route = '/admin/module/Paybox';
         } else {
             // If we have to close the page, go back to the module back-office page.
             $route = '/admin/modules';
         }
         return new RedirectResponse(URL::getInstance()->absoluteUrl($route));
     } catch (FormValidationException $ex) {
         // Form cannot be validated. Create the error message using
         // the BaseAdminController helper method.
         $error_msg = $this->createStandardFormValidationErrorMessage($ex);
     } catch (\Exception $ex) {
         // Any other error
         $error_msg = $ex->getMessage();
     }
     // At this point, the form has errors, and should be redisplayed. We don not redirect,
     // just redisplay the same template.
     // Setup the Form error context, to make error information available in the template.
     $this->setupFormErrorContext($this->getTranslator()->trans("Paybox configuration", [], Paybox::MODULE_DOMAIN), $error_msg, $configurationForm, $ex);
     // Do not redirect at this point, or the error context will be lost.
     // Just redisplay the current template.
     return $this->displayConfigurationPage();
 }
Example #5
0
 protected function buildForm()
 {
     $this->formBuilder->add('numero_site', 'text', ['constraints' => [new NotBlank()], 'label' => $this->translator->trans('Numéro du site', [], Paybox::MODULE_DOMAIN), 'data' => Paybox::getConfigValue('numero_site', '1234567'), 'label_attr' => ['for' => 'numero_site', 'help' => $this->translator->trans('Numéro du site, tel que fourni par Paybox', [], Paybox::MODULE_DOMAIN)]])->add('rang_site', 'text', ['constraints' => [new NotBlank()], 'label' => $this->translator->trans('Numéro de rang', [], Paybox::MODULE_DOMAIN), 'data' => Paybox::getConfigValue('rang_site', '1234567'), 'label_attr' => ['for' => 'rang_site', 'help' => $this->translator->trans('Numéro de rang, tel que fourni par Paybox', [], Paybox::MODULE_DOMAIN)]])->add('identifiant_interne', 'text', ['constraints' => [new NotBlank()], 'label' => $this->translator->trans('Identifiant interne', [], Paybox::MODULE_DOMAIN), 'data' => Paybox::getConfigValue('identifiant_interne', '123456789'), 'label_attr' => ['for' => 'identifiant_interne', 'help' => $this->translator->trans('Identifiant interne, tel que fourni par Paybox', [], Paybox::MODULE_DOMAIN)]])->add('clef_privee', 'text', array('constraints' => [new NotBlank()], 'label' => $this->translator->trans('Clef privée d\'échange', [], Paybox::MODULE_DOMAIN), 'data' => Paybox::getConfigValue('clef_privee', ''), 'label_attr' => ['for' => 'clef_privee', 'help' => $this->translator->trans('Voyez ci-dessous comment générer votre clef privée.', [], Paybox::MODULE_DOMAIN)]))->add('url_serveur', 'url', ['constraints' => [new NotBlank(), new UrlValidator()], 'label' => $this->translator->trans('URL de production du serveur Paybox', [], Paybox::MODULE_DOMAIN), 'data' => Paybox::getConfigValue('url_serveur', "https://tpeweb.paybox.com/cgi/MYchoix_pagepaiement.cgi"), 'label_attr' => ['for' => 'url_serveur', 'help' => $this->translator->trans('URL du serveur Paybox en mode production', [], Paybox::MODULE_DOMAIN)]])->add('url_serveur_test', 'url', ['constraints' => [new NotBlank(), new UrlValidator()], 'label' => $this->translator->trans('URL de test du serveur Paybox', [], Paybox::MODULE_DOMAIN), 'data' => Paybox::getConfigValue('url_serveur_test', "https://preprod-tpeweb.paybox.com/cgi/MYchoix_pagepaiement.cgi"), 'label_attr' => ['for' => 'url_serveur_test', 'help' => $this->translator->trans('URL du serveur Paybox en mode test', [], Paybox::MODULE_DOMAIN)]])->add('url_retour_abandon', 'url', ['constraints' => [new NotBlank(), new UrlValidator()], 'label' => $this->translator->trans('URL de retour en cas d\'abandon', [], Paybox::MODULE_DOMAIN), 'data' => Paybox::getConfigValue('url_retour_abandon', URL::getInstance()->absoluteUrl('/paybox/cancel')), 'label_attr' => ['for' => 'url_retour_abandon', 'help' => $this->translator->trans('URL de la page présentée à votre client en cas d\'abandon du paiement.', [], Paybox::MODULE_DOMAIN)]])->add('url_retour_succes', 'url', ['constraints' => [new NotBlank(), new UrlValidator()], 'label' => $this->translator->trans('URL de retour après un paiement réussi', [], Paybox::MODULE_DOMAIN), 'data' => Paybox::getConfigValue('url_retour_succes', URL::getInstance()->absoluteUrl('/paybox/success')), 'label_attr' => ['for' => 'url_retour_succes', 'help' => $this->translator->trans('URL de la page présentée à votre client après un paiement réussi.', [], Paybox::MODULE_DOMAIN)]])->add('url_retour_refus', 'url', ['constraints' => [new NotBlank(), new UrlValidator()], 'label' => $this->translator->trans('URL de retour en cas de rejet du paiement', [], Paybox::MODULE_DOMAIN), 'data' => Paybox::getConfigValue('url_retour_refus', URL::getInstance()->absoluteUrl('/paybox/rejected')), 'label_attr' => ['for' => 'url_retour_refus', 'help' => $this->translator->trans('URL de la page présentée à votre client après rejet de son paiement.', [], Paybox::MODULE_DOMAIN)]])->add('url_ipn', 'url', ['constraints' => [new NotBlank(), new UrlValidator()], 'label' => $this->translator->trans('URL IPN', [], Paybox::MODULE_DOMAIN), 'data' => Paybox::getConfigValue('url_ipn', URL::getInstance()->absoluteUrl('/paybox/callback')), 'label_attr' => ['for' => 'url_ipn', 'help' => $this->translator->trans('URL appellée par la banque poour confirmer les commandes', [], Paybox::MODULE_DOMAIN)], 'attr' => []])->add('mode', 'choice', ['constraints' => [new NotBlank()], 'choices' => ['TEST' => $this->translator->trans('Test', [], Paybox::MODULE_DOMAIN), 'PRODUCTION' => $this->translator->trans('Production', [], Paybox::MODULE_DOMAIN)], 'label' => $this->translator->trans('Mode de fonctionnement', [], Paybox::MODULE_DOMAIN), 'data' => Paybox::getConfigValue('mode', 'TEST'), 'label_attr' => ['for' => 'mode', 'help' => $this->translator->trans('En mode test, seuls les IPs ci-dessous peuvent accéder à ce module de paiement.', [], Paybox::MODULE_DOMAIN)]])->add('allowed_ip_list', 'textarea', ['required' => false, 'label' => $this->translator->trans('Adresses IP autorisées en mode test', [], Paybox::MODULE_DOMAIN), 'data' => Paybox::getConfigValue('allowed_ip_list', $this->getRequest()->getClientIp()), 'label_attr' => ['for' => 'platform_url', 'help' => $this->translator->trans('En mode test, liste des apdresses IP autorisées à utiliser le module de paiement en front office. Indiquer une adresse par ligne. Votre IP actuelle est %ip', ['%ip' => $this->getRequest()->getClientIp()], Paybox::MODULE_DOMAIN), 'attr' => ['rows' => 3]]])->add('minimum_amount', 'text', ['constraints' => [new NotBlank(), new GreaterThanOrEqual(['value' => 0])], 'label' => $this->translator->trans('Minimum order total', [], Paybox::MODULE_DOMAIN), 'data' => Paybox::getConfigValue('minimum_amount', '0'), 'label_attr' => ['for' => 'minimum_amount', 'help' => $this->translator->trans('Minimum order total in the default currency for which this payment method is available. Enter 0 for no minimum', [], Paybox::MODULE_DOMAIN)]])->add('maximum_amount', 'text', ['constraints' => [new NotBlank(), new GreaterThanOrEqual(['value' => 0])], 'label' => $this->translator->trans('Maximum order total', [], Paybox::MODULE_DOMAIN), 'data' => Paybox::getConfigValue('maximum_amount', '0'), 'label_attr' => ['for' => 'maximum_amount', 'help' => $this->translator->trans('Maximum order total in the default currency for which this payment method is available. Enter 0 for no maximum', [], Paybox::MODULE_DOMAIN)]])->add('send_confirmation_email_on_successful_payment', 'checkbox', ['required' => false, 'label' => $this->translator->trans('Envoi du mail de confirmation de commande sur paiement réussi', [], Paybox::MODULE_DOMAIN), 'data' => Paybox::getConfigValue('send_confirmation_email_on_successful_payment', '1') == '1', 'label_attr' => ['for' => 'send_confirmation_email_on_successful_payment', 'help' => $this->translator->trans('Cochez cette case pour envoyer le mail de confirmation de commande à vos clients une fois que le paiement a été confirmé.', [], Paybox::MODULE_DOMAIN)]]);
 }
Example #6
0
 /**
  * Check if total order amount is in the module's limits
  *
  * @return bool true if the current order total is within the min and max limits
  */
 protected function checkMinMaxAmount()
 {
     // Check if total order amount is in the module's limits
     $order_total = $this->getCurrentOrderTotalAmount();
     $min_amount = Paybox::getConfigValue('minimum_amount', 0);
     $max_amount = Paybox::getConfigValue('maximum_amount', 0);
     return $order_total > 0 && ($min_amount <= 0 || $order_total >= $min_amount) && ($max_amount <= 0 || $order_total <= $max_amount);
 }