定制 mkurc1/payu-bundle 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mkurc1/payu-bundle

最新稳定版本:1.0.3

Composer 安装命令:

composer require mkurc1/payu-bundle

包简介

Symfony PayuBundle

README 文档

README

The bundle integrate PayU into Symfony Framework.

Configure

Require the bundle with composer:

$ composer require mkurc1/payu-bundle

Enable the bundle in the kernel:

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new PayuBundle\PayuBundle(),
        // ...
    );
}

Create your Order class and implement OrderInterface:

<?php

namespace AppBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use PayuBundle\Entity\OrderInterface;

/**
 * @ORM\Table("payu_order")
 * @ORM\Entity()
 */
class Order implements OrderInterface
{
    /**
     * @var integer
     *
     * @ORM\Column(type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="IDENTITY")
     */
    private $id;


    public function getName()
    {
        return 'Order';
    }

    public function getDescription()
    {
        return 'Payment order number ' . $this->getId();
    }

    public function getTotalPrice()
    {
        return 111; // your price
    }

    /**
     * @return int
     */
    public function getId()
    {
        return $this->id;
    }
}

Create your PayuOrderRequest class:

<?php

namespace AppBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use PayuBundle\Entity\PayuOrderRequest as AbstractPayuOrderRequest;

/**
 * @ORM\Table("payu_request")
 * @ORM\Entity()
 */
class PayuOrderRequest extends AbstractPayuOrderRequest
{
    /**
     * @var Order
     *
     * @ORM\ManyToOne(targetEntity="AppBundle\Entity\Order")
     * @ORM\JoinColumn(nullable=false)
     */
    private $order;

    /**
     * @return Order
     */
    public function getOrder()
    {
        return $this->order;
    }

    /**
     * @param Order $order
     */
    public function setOrder($order)
    {
        $this->order = $order;
    }
}

Configure your application:

# app/config/config.yml
monolog:
    handlers:
        payu:
            type: stream
            path: "%kernel.logs_dir%/payu.log"
            channels: [payu]

payu:
    class:
        request: AppBundle\Entity\PayuOrderRequest # your PayuOrderRequest class
    redirect: app_profile_edit # redirect to route after payment
    environment: secure
    pos_id: 145227
    signature_key: 13a980d4f851f3d9a1cfc792fb1f5e50

Configure your routing:

# app/config/routing.yml
payu:
    resource: "@PayuBundle/Controller/"
    type:     annotation

Create your Controller:

<?php

namespace AppBundle\Controller;

use AppBundle\Entity\Order;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;

/**
 * @Route("/order")
 */
class OrderController extends Controller
{
    /**
     * @Route("/pay/{order}")
     * @Method("GET")
     */
    public function payAction(Order $order)
    {
        $payRequest = $this->get('payu.client')->createRequest($order);

        return $this->redirect($payRequest->getResponse()->redirectUri);
    }
}

Update your database schema:

$ php app/console doctrine:schema:update --force

You now can use your payment system!

License

The bundle is released under the MIT License.

统计信息

  • 总下载量: 56
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 2
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-09-21