コード例 #1
0
ファイル: PaylineManager.php プロジェクト: Alban-io/Payline
 /**
  * @see : 3.1.1 PAYLINE-GUIDE-Descriptif des appels webservices.
  * @param Order $order
  * @return RedirectResponse
  * @throws \Exception
  */
 public function doWebPayment(Order $order)
 {
     /** @var Customer $subscriber */
     $customer = $order->getCustomer();
     $array['version'] = self::VERSION;
     $array['returnURL'] = $this->frontRouter->generate('order.placed', ['order_id' => $order->getId()], true);
     $array['cancelURL'] = $this->frontRouter->generate('order.failed', ['order_id' => $order->getId(), 'message' => 'payline'], true);
     $array['notificationURL'] = $this->paylineRouter->generate('payline_notify', ['orderId' => $order->getId()], true);
     $amount = (double) $order->getTotalAmount() * 100;
     $currency = CurrencyNumericCodeQuery::create()->findPk($order->getCurrency()->getCode())->getNumericCode();
     $array['payment']['amount'] = $amount;
     $array['payment']['currency'] = $currency;
     $array['payment']['action'] = '100';
     $array['payment']['mode'] = 'CPT';
     $array['payment']['contractNumber'] = $this->config->getContractNumber();
     $array['order']['ref'] = $order->getRef();
     $array['order']['amount'] = $amount;
     $array['order']['currency'] = $currency;
     $array['order']['date'] = $order->getUpdatedAt()->format('d/m/Y H:m');
     $array['buyer']['lastName'] = $customer->getLastName();
     $array['buyer']['firstName'] = $customer->getFirstName();
     $array['buyer']['email'] = $customer->getEmail();
     $array['securityMode'] = 'SSL';
     $response = $this->payline->doWebPayment($array);
     $code = $response['result']['code'];
     if ($code !== '00000') {
         $message = isset($response['result']['longMessage']) ? $response['result']['longMessage'] : 'Error undefined';
         $this->logger->error($message);
         throw new \Exception($message);
     }
     return new RedirectResponse($response['redirectURL']);
 }
コード例 #2
0
 /**
  *
  * in this function you add all the fields you need for your Form.
  * Form this you have to call add method on $this->formBuilder attribute :
  */
 protected function buildForm()
 {
     $paylineConfig = new PaylineConfig();
     $this->formBuilder->add('merchantId', 'text', ['constraints' => [new NotBlank()], 'label' => $this->trans('Merchant id :'), 'data' => $paylineConfig->getMerchantId()])->add('merchantAccesskey', 'text', ['constraints' => [new NotBlank()], 'label' => $this->trans('Merchant access key :'), 'data' => $paylineConfig->getMerchantAccesskey()])->add('contractNumber', 'text', ['constraints' => [new NotBlank()], 'label' => $this->trans('Contract number :'), 'data' => $paylineConfig->getContractNumber()])->add('env', 'choice', ['constraints' => [new NotBlank()], 'label' => $this->trans('Environment :'), 'choices' => [PaylineConfig::ENV_DEV => $this->trans('Development'), PaylineConfig::ENV_HOMO => $this->trans('Approval'), PaylineConfig::ENV_PROD => $this->trans('Production')], 'expanded' => false, 'multiple' => false, 'data' => $paylineConfig->getEnv()])->add('minimumAmount', 'money', ['constraints' => [new NotBlank(), new GreaterThanOrEqual(['value' => 0])], 'label' => $this->trans('Minimum order total'), 'data' => $paylineConfig->getMinimumAmount(), 'label_attr' => ['for' => 'minimum_amount', 'help' => $this->trans('Minimum order total in the default currency for which this payment method is available. Enter 0 for no minimum')]])->add('maximumAmount', 'money', ['constraints' => [new NotBlank(), new GreaterThanOrEqual(['value' => 0])], 'label' => $this->trans('Maximum order total'), 'data' => $paylineConfig->getMaximumAmount(), 'label_attr' => ['for' => 'maximum_amount', 'help' => $this->trans('Maximum order total in the default currency for which this payment method is available. Enter 0 for no maximum')]]);
 }