xola/omnipay-bundle 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

xola/omnipay-bundle

Composer 安装命令:

composer require xola/omnipay-bundle

包简介

Integrates Omnipay 3 with Symfony 2+

README 文档

README

This bundle integrates the Omnipay payment processing library into Symfony2.

This bundle supports Omnipay 3

Installation

To install via Composer, add the following to your composer.json file:

{
    "require": {
        "xola/omnipay-bundle": "^3"
    }
}

Add the bundle to your application kernel.

// app/AppKernel.php
public function registerBundles()
{
    return array(
        // ...
        new Xola\OmnipayBundle\OmnipayBundle(),
        // ...
    );
}

Configuration

(Optional) In the Omnipay library, you would programmatically set parameters required by a gateway. With this bundle, it's possible to configure these parameters in your Symfony config files.

# app/config/password_dev.yml
parameters:
    # Custom gateway
    omnipay.my_custom_key.apiKey: myGatewayKey
    omnipay.my_custom_key.gateway: MyGateway

    # Default Stripe gateway
    omnipay.stripe_default.apiKey: myApiKey
    omnipay.stripe_default.gateway: Stripe

    # Gateway for Stripe Canada account
    omnipay.stripe_canada.apiKey: myStripeCanadaApiKey
    omnipay.stripe_canada.gateway: Stripe

    # Authorize.NET AIM
    omnipay.authorize_net_aim.transactionKey: myTransactionKey
    omnipay.authorize_net_aim.gateway: AuthorizeNet_AIM

In the sample configuration above, my_custom_key is a unique key you define for each of your gateways. omnipay.my_custom_name.gateway is the class name for a Omnipay gateway driver (e.g. Stripe). You may choose to define multiple keys for the same Omnipay gateway with different credentials. In the above configuration, we have configured two gateway definitions for Stripe -- both use the Stripe Omnipay driver, however, they each use a different set of credentials.

Usage

Use the new omnipay service to create gateway object:

    // From within a controller. This will return an instance `\Omnipay\Stripe`. `stripe_default` is the key as
    // specified in the config.
    $gateway = $this->get('omnipay')->get('stripe_default');

    // From within a controller. This will return an instance of `\Omnipay\MyGateway` as specified in
    // `omnipay.my_custom_name.gateway`
    $gateway = $this->get('omnipay')->get('my_custom_name');

The rest is identical to how you would normally use Omnipay

$formData = ['number' => '4242424242424242', 'expiryMonth' => '11', 'expiryYear' => '2018', 'cvv' => '123'];
$response = $gateway->purchase(['amount' => '10.00', 'currency' => 'USD', 'card' => $formData])->send();

if ($response->isSuccessful()) {
    // payment was successful: update database
    print_r($response);
} elseif ($response->isRedirect()) {
    // redirect to offsite payment gateway
    $response->redirect();
} else {
    // payment failed: display message to customer
    echo $response->getMessage();
}

The gateway classes which are returned are already initialized with the parameters defined in the config files.

统计信息

  • 总下载量: 17.28k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 10
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 9
  • Watchers: 5
  • Forks: 11
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-07-01

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固