2017 © Pedro Peláez
 

symfony-bundle payment-bundle

Symfony payment bundle

image

idci/payment-bundle

Symfony payment bundle

  • Friday, July 27, 2018
  • by idciconsulting
  • Repository
  • 2 Watchers
  • 0 Stars
  • 23 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

PaymentBundle

This Symfony bundle provide help for integrating payments solutions by the normalization of payment process thanks to gateways. Each used gateway must have a configuration to set its parameters., (*1)

Example controller :, (*2)

<?php

$paymentContext = $this->paymentManager->createPaymentContextByAlias('stripe_test'); // raw alias

$payment = $paymentContext->createPayment([
    'item_id' => 5,
    'amount' => 500,
    'currency_code' => 'EUR',
]);

return $this->render('@IDCIPayment/payment.html.twig', [
    'view' => $paymentContext->buildHTMLView(),
]);

A list of commands is provided by this bundle to manage gateway configurations & transactions., (*3)

Installation

Add dependency in your composer.json file:, (*4)

"require": {
    ...,
    "idci/payment-bundle": "^4.0",
}

Install this new dependency in your application using composer:, (*5)

$ composer update

Enable bundle in your application kernel :, (*6)

<?php
// config/bundles.php
return [
    // ...
    new IDCI\Bundle\PaymentBundle\IDCIPaymentBundle(),
];

Add this to your config.yml file, (*7)

# config/packages/idci_payment.yaml
imports:
    - {resource: '@IDCIPaymentBundle/Resources/config/config.yml'}

# Enable monolog logging using event subscriber plugged on transaction state changes
idci_payment:
    enabled_logger_subscriber: true

(Optional) If you want to customize the payment logger, by defaults, it will output into main handler, (*8)

# config/packages/monolog.yaml
monolog:
    handlers:
        # ...
        payment_log:
            type: stream
            path: "%kernel.logs_dir%/%kernel.environment%.log"
            channels: ['payment']

Install routes in your config/routes/idci_payment.yaml file:, (*9)

# config/routes/idci_payment.yaml
idci_payment:
    resource: '@IDCIPaymentBundle/Resources/config/routing.yml'
    prefix:   /

idci_payment_api:
    resource: '@IDCIPaymentBundle/Resources/config/routing_api.yml'
    prefix:   /api

These tutorials may help you to personalize yourself this bundle:, (*10)

Supported Gateways

For testing purpose: - Parameters - Cards, (*11)

Command

PaymentGatewayConfiguration
# To create a PaymentGatewayConfiguration
$ php bin/console app:payment-gateway-configuration:create

# To show the list of PaymentGatewayConfiguration
$ php bin/console app:payment-gateway-configuration:list

# To update a PaymentGatewayConfiguration
$ php bin/console app:payment-gateway-configuration:update

# To delete a PaymentGatewayConfiguration
$ php bin/console app:payment-gateway-configuration:delete
Transaction
# Remove all the aborted transaction created 1 day ago
$ php bin/console app:transaction:clean

Tests

Add test routing :, (*12)

# config/routes/dev/idci_payment.yaml

_test_payment:
    resource: '@IDCIPaymentBundle/Resources/config/routing_test.yml'
    prefix:   /_test/

You can now test gateways on /_test/payment-gateway/select (be sure to have created one or more gateway configuration), (*13)

Resources

UML Diagram

UML Diagram, (*14)

The Versions