承接 snowcap/ogone-bundle 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

snowcap/ogone-bundle

Composer 安装命令:

composer require snowcap/ogone-bundle

包简介

Ogone wrapper for Symfony2

README 文档

README

This bundle introduces the Ogone payment process gateway into a Symfony project It uses the marlon-ogone Bundle, and adds a different integration approach

More info about Ogone can be found here: http://www.ogone.com

WARNING: THIS BUNDLE IS IN BETA STAGE, USE AT YOUR OWN RISKS !

Prerequisites

  • Symfony 2.1>=
  • You must have a valid Ogone account, configured with SHA-IN and SHA-OUT security activated

Installation

Download the bundle:

{
"require": {
    "snowcap/ogone-bundle": "dev-master"
}
$ php composer.phar update snowcap/ogone-bundle

Add it to your application's kernel:

// app/ApplicationKernel.php
public function registerBundles()
{
    return array(
        // ...
        new Snowcap\OgoneBundle\SnowcapOgoneBundle(),
        // ...
    );
}

Configuration

Put the following configuration options in your config file:

snowcap_ogone:
    pspid: [your_ogone_pspid]
    environment: [test|prod]
    sha_in: [your_ogone_sha_in_passhprase]
    sha_out: [your_ogone_sha_out_passhprase]
    options:
        # any option you may want to pass to Ogone, as key: value pairs

Usage

Getting the Ogone form to use in your view

A service 'snowcap_ogone.manager' allows you to get the ogone form rendering, whereby you can also define the acceptUrl, and any other option you want to send to Ogone An example could be:

/** @var $ogone \Snowcap\OgoneBundle\Manager */
$ogone = $this->get('snowcap_ogone');

$ogoneForm = $ogone->getRequestForm($locale, $orderId, $customerName, $amount, $currency, array(
    'acceptUrl' => $this->generateUrl('your_success_page_route_name', array(), true),
    // and any other option your may want to pass to Ogone
));

return array(
    'ogone_form' => $ogoneForm,
);

Pay attention, this is not a Symfony form, just a simple rendered form provided by the Ogone library.

...
{{ ogone_form|raw }}

Getting Ogone result

First you need to add a route in your routing.yml

snowcap_ogone:
    resource: "@SnowcapOgoneBundle/Controller"
    type: annotation

To catch Ogone's result, you have to create a service and tag it as an event subscriber (or an event listener): For example:

my_company_bundle.ogone_subscriber:
    class: MyCompany\MyBundle\Ogone\OgoneSubscriber
    tags:
        - { name: kernel.event_subscriber }

That service has to implement the EventSubscriberInterface, like the following:

<?php
namespace MyCompany\MyBundle\Ogone;
    
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

use Snowcap\OgoneBundle\Event\OgoneEvent;
use Snowcap\OgoneBundle\OgoneEvents;

class OgoneSubscriber implements EventSubscriberInterface
{
    /**
     * @param \Snowcap\OgoneBundle\Event\OgoneEvent $event
     */
    public function onOgoneSuccess(OgoneEvent $event)
    {
        
    }

    /**
     * @param \Snowcap\OgoneBundle\Event\OgoneEvent $event
     */
    public function onOgoneError(OgoneEvent $event)
    {
        
    }
    
    /**
     * @return array
     */
    public static function getSubscribedEvents()
    {
        return array(
            OgoneEvents::SUCCESS => 'onOgoneSuccess',
            OgoneEvents::ERROR => 'onOgoneError'
        );
    }
}

You now have two methods inside your bundle to operate all the business logic you need, enjoy !

统计信息

  • 总下载量: 5.24k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 4
  • Watchers: 2
  • Forks: 7
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2012-10-24

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固