uc/payment-bundle

Symfony 3 bundle integrate Stripe's and PayPal SDK into a Symfony project

dev-master / 1.1.x-dev 2017-09-14 09:16 UTC

This package is not auto-updated.

Last update: 2024-11-10 04:43:07 UTC


README

Installation

To install this bundle, run the command below and you will get the latest version from [Packagist][3].

composer require stripe/stripe-php ~3.23
composer require uc/payment-bundle dev-master

Load required bundles in AppKernel.php:

// app/AppKernel.php
public function registerBundles()
{
  $bundles = array(
    // [...]
    new Uc\PaymentBundle\UcPaymentBundle(),
  );
}

And set-up the required configuration

# app/config/config.yml
uc_payment:
    stripe:
        app_id: '%uc_payment_stripe_app_id%' The Stripe app id key can be added as a symfony parameter
        app_secret: '%uc_payment_stripe_app_secret%' The Stripe secret key can be added as a symfony parameter
        public_key: '%uc_payment_stripe_public_key%' The Stripe public key can be added as a symfony parameter
    paypal:
        client_id: '%uc_payment_paypal_client_id%' The PayPal cleint id key can be added as a symfony parameter
        secret: '%uc_payment_paypal_secret%' The PayPal secret key can be added as a symfony parameter
Create a charge (to a platform, or a connected Stripe account)
/**
 * $chargeAmount (int)              : The charge amount in cents, for instance 1000 for 10.00 (of the currency)
 * $chargeCurrency (string)         : The charge currency (for instance, "eur")
 * $paymentToken (string)           : The payment token obtained using the Stripe.js library
 * $applicationFee (int)            : The amount of the application fee (in cents), default to 0
 * $chargeDescription (string)      : (optional) The charge description for the customer
 */
$stripeClient->createCharge($chargeAmount, $chargeCurrency, $paymentToken, $applicationFee, $chargeDescription);
Refund a Charge
/**
 * $chargeId (string)           : The Stripe charge ID (returned by Stripe when you create a charge)
 * $refundAmount (int)          : The charge amount in cents (if null, the whole charge amount will be refunded)
 * $metadata (array)            : additional informations about the refund, default []
 * $reason (string)             : The reason of the refund, either "requested_by_customer", "duplicate" or "fraudulent"
 * $refundApplicationFee (bool) : Wether the application_fee should be refunded aswell, default true
 * $reverseTransfer (bool)      : Wether the transfer should be reversed (when using Stripe Connect "destination" parameter on charge creation), default false
 */
$stripeClient->refundCharge($chargeId, $refundAmount, $metadata, $reason, $refundApplicationFee, $reverseTransfer);