为Checkout.com开发的基于Symfony的支付网关

安装: 10

依赖项: 0

建议者: 0

安全: 0

星标: 0

关注者: 0

分支: 0

开放问题: 0

类型:symfony-bundle

1.4 2019-05-16 14:23 UTC

This package is auto-updated.

Last update: 2024-09-17 02:46:07 UTC


README

alt text

**:heavy_exclamation_mark: 此库指向Checkout.com的经典API. **

要求

PHP 5 > 5.3.0

Symfony 2.8 > 4

如何使用此库

使用Composer或手动将Checkout Symfony Bundle的dev-master版本添加到您的项目中

使用Composer(推荐)

在项目的根目录中运行以下命令

composer require checkout-bundle/checkout

或在您的项目的composer.json中添加Checkout.com包

"require": {
    "php": ">=5.2.4",
    "checkout-bundle/checkout": "dev-master"
},

手动

下载或克隆github仓库,master或下载一个发布版,并将其手动添加到您的项目中。

示例

将库添加到您的项目后,在您的AppKernal.php中注册Bundle。

 public function registerBundles()
    {
        $bundles = [
            .........
            ........
           .........
            new Checkout\PaymentBundle\CheckoutPaymentBundle(),
        ];

在您的routing.yml中添加Checkout Bundle的路由

checkout_payment:
    resource: "@CheckoutPaymentBundle/Resources/config/routing.yml"
    prefix:   /

您可以将请求转发到Checkout Controller以使用Checkout.js启动支付,如下所示

在MyController.php中

    /**
     * @param Request $request
     * @return \Symfony\Component\HttpFoundation\Response
     * @\Sensio\Bundle\FrameworkExtraBundle\Configuration\Route("payment")
     */
    public function create_payment(Request $request){

        return $this->forward('CheckoutPaymentBundle:Checkout:show', [
        'currency' => 'USD',
        'amount' => 10,
        'customer_name' => 'Omair Afzal',
        'cartObject' =>  null,
        'country_code' => 'US',
        'callback_url' => 'http://iam_callback_url.com',
        'timeout' => 300,
        'public_key' => 'XXXXXXXXXXX',
        'env' => 'sandbox'   //live
        ]);
    }

默认情况下,$connectTimeout$readTimeout都是60秒。您可以根据需要更改它们。

$env接受'sandbox''live'作为值。此参数允许您在沙盒环境或实时环境之间切换。默认情况下将使用沙盒环境。