pilot/ogone-payment-bundle

Ogone支付组件,Doctrine端口

安装: 149

依赖者: 0

建议者: 0

安全: 0

星星: 2

关注者: 3

分支: 5

类型:symfony-bundle

1.0.0 2015-06-23 14:38 UTC

This package is not auto-updated.

Last update: 2024-09-28 15:13:46 UTC


README

Doctrine端口的 Cedriclombardot/OgonePaymentBundle Cedriclombardot/OgonePaymentBundle

Build Status

特性

  • 功能齐全的示例控制器
  • 简单交易
  • 反馈管理
  • 别名管理

待办事项

  • 将部分包含 doctrine ORM 选项的原组件

配置

在您的 composer.json 中添加

"require": {
   "pilot/ogone-payment-bundle": "dev-master"
}

配置您的内核

$bundles = array(
    new Pilot\OgonePaymentBundle\PilotOgonePaymentBundle(),
);

在 config.yml 中配置 Ogone

pilot_ogone_payment:
    secret:
        shaInKey: Mysecretsig1875!?
        shaOutKey: Mysecretsig1875!?
        algorithm: sha512
    general:
        PSPID: MyCompagny
        currency: EUR
        language: en_EN
    design:
        title: Give Me Your money - Payment page
        bgColor: "#4e84c4"
        txtColor: "#FFFFFF"
        tblBgColor: "#FFFFFF"
        buttonBgColor: "#00467F"
        buttonTxtColor: "#FFFFFF"
        fontType: "Verdana"

创建交易

在控制器中

public function indexAction()
{
  $client = $this->getRepository('PilotOgonePaymentBundle:OgoneClient')->findOneBy(array(
      'email' => 'test@test.com',
  ));

  if (!$client) {
      $client = new OgoneClient();
      $client->setEmail('test@test.com');

      $this->getManager()->persist($client);
      $this->getManager()->flush();
  }

  $transaction = $this->get('ogone.transaction_builder')
      ->order()
          ->setClient($client)
          ->setAmount(99)
      ->end()
      ->configure()
          ->setBgColor('#ffffff')
          ->setAcceptUrl($this->generateUrl('ogone_payment_feedback', array(), true))
          ->setDeclineUrl($this->generateUrl('ogone_payment_feedback', array(), true))
          ->setExceptionUrl($this->generateUrl('ogone_payment_feedback', array(), true))
          ->setCancelUrl($this->generateUrl('ogone_payment_feedback', array(), true))
          ->setBackUrl($this->generateUrl('ogone_payment_feedback', array(), true))
      ->end()
  ;

  $transaction->save();

  $form = $transaction->getForm();

  return $this->render(
      'PilotOgonePaymentBundle:Payment:index.html.twig',
      array(
          'form' => $form->createView(),
      )
  );
}

和反馈

public function feedbackAction()
{
  if (!$this->get('ogone.feedbacker')->isValidCall()) {
      throw $this->createNotFoundException();
  }

  $this->get('ogone.feedbacker')->updateOrder();

  return $this->render(
      'PilotOgonePaymentBundle:Payment:feedback.html.twig'
  );
}

别名管理

您有Ogone premium账户且带有别名选项

更新 config.yml

pilot_ogone_payment:
    general:
        use_aliases: true

在您的交易控制器中

// Client recuperation HERE

// Transaction creation HERE

$transaction->save();

if ($this->container->getParameter('ogone.use_aliases')) {
    $alias = $this->getRepository('PilotOgonePaymentBundle:OgoneAlias')->findOneBy(array(
        'client' => $client,
        'operation' => OgoneAlias::OPERATION_BYMERCHANT,
        'name' => 'ABONNEMENT',
    ));

    if (!$alias) {
        $alias = new OgoneAlias();
        $alias
            ->setClient($client)
            ->setOperation(OgoneAlias::OPERATION_BYMERCHANT)
            ->setStatus(OgoneAlias::STATUS_ACTIVE)
            ->setName('ABONNEMENT')
        ;

        $this->getManager()->persist($alias);
        $this->getManager()->flush();
    }

    $transaction->useAlias($alias);
}

$form = $transaction->getForm();

// render the view

在此处查看完整的控制器实现:https://github.com/pilot/OgonePaymentBundle/blob/master/Controller/PaymentController.php