mufin/

comgate-bundle

安装: 57

依赖: 0

建议: 0

安全: 0

星星: 3

关注者: 2

分支: 4

开放问题: 0

类型:symfony-bundle

1.0.4 2021-05-08 11:27 UTC

This package is auto-updated.

Last update: 2024-09-25 01:13:09 UTC


README

Comgate支付功能的symfony扩展包

安装

步骤 1: 使用composer下载MufinComgateBundle

使用composer Composer 要求 mufin/comgate-bundle

$ composer require mufin/comgate-bundle

步骤 2: 启用扩展包

在kernel中启用扩展包

<?php

// app/AppKernel.php
public function registerBundles()
{
    $bundles = array(
        // ...
        new Mufin\ComgateBundle\MufinComgateBundle(),
        // ...
    );
}

步骤 3: 配置MufinComgateBundle

以下是在应用程序中使用MufinComgateBundle所需的配置的最小示例

# .env

###> mufin/comgate-bundle ###
MERCHANT_ID="your merchant id"
SECRET_KEY="secret key from comgate dashboard"
TEST_MODE=false
###< mufin/comgate-bundle ###

步骤 4: MufinComgateBundle的使用

# CartController

/**
     * @Route("/cart/payment", name="cart_payment")
     * @param ComgateConnector $comgate
     * @param Request
     * @return Response
     */
    public function payment(ComgateConnector $comgate): Response
    {
        
        $payment = new CreatePayment('PRICE', 'Your order ID', $this->getUser()->getEmail(), 'Some product');
        // to create payment on background according to API requirements
        $payment->setPrepareOnly(true);
        $response = $comgate->send($payment);
        if($response->getMessage()=="OK"){
            // do something with cart
            return $this->redirect($response->getRedirectUrl());
        }

        return $this->render('cart/payment.html.twig', []);
    }