w3sami / stripe-bundle
A simple Symfony 5 bundle to wrap Stripe API.
Installs: 21
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 1
Type:symfony-bundle
Requires
- php: ^7.2.5
- stripe/stripe-php: ^7.40
- symfony/config: ^4.3|^5.0
- symfony/dependency-injection: ^4.3|^5.0
- symfony/http-kernel: ^5.0
README
A simple wrapper for Stripe Api to use with Symfony 5.
This bundle wraps the stripe-php library, so you can inject it in your own symfony code with ease. It provides a few shortcuts too, for getting and creating a client, creating and canceling a subscription and making a single charge.
To see all available methods of stripe's php library, see https://github.com/stripe/stripe-php
Setup
Step 1: Install W3samiStripeBundle using composer
Install with composer by running the command:
$ composer require "w3sami/stripe-bundle:1.*"
Step 2: Add configuration
# config/packages/w3sami.yml w3sami: stripe: stripe_private_key: %stripe_private_key%
Usage
Using service
<?php use W3sami\StripeBundle\Services\StripeClient; public function __construct(StripeClient $stripeClient) { } ?>
or
<?php $stripeClient = $this->get('stripe_client'); ?>
##Example
###Create customer & subscription
<?php $customer = $stripeClient->createCustomer($token, $email, $name, $phone); // Store customer information $subsciption = $stripeClient->createSubscription($customerId, $planId); // Store subscription information ?>
To see all available api calls of stripe service see https://stripe.com/docs/api