christianbraybrooke/stripe-laravel-payment-intents

0.0.2 2019-08-19 08:30 UTC

This package is auto-updated.

Last update: 2024-04-19 19:49:04 UTC


README

This package is still under development, and will require some more documentation. For help, please email chris@purplemountmedia.com.

Composer

First, require the package from packagist.org using the snippet below in the terminal. Laravel 5.5 and greater will autoload our Service provider.

composer require christianbraybrooke/stripe-laravel-payment-intents

Database

By default we will store all transactions in the database using the payment_records table. If this is not desirable, please place the following in your \App\Providers\AppServiceProvider's boot method.

use ChrisBraybrooke\LaravelStripePaymentIntent\Facades\StripePaymentIntent;

/**
 * Bootstrap any application services.
 *
 * @return void
 */
public function boot()
{
    StripePaymentIntent::dontSavePaymentRecords();
}

Next, you will need to publish the required migrations & migrate.

php artisan vendor:publish --tag="payment-migrations"

php artisan migrate

Stripe

In order for us to be able to communicate with Stripe, you will need to add your API keys to the .env file, if you haven't done so already. You will find your keys here https://dashboard.stripe.com/apikeys

STRIPE_KEY=###
STRIPE_SECRET=###

Usage

Payment Form

Out of the box, we give you a simple payment form component which will allow you to get up and running in no time. Simply add the payment feilds and scripts components to the desired page and you are good to go!

@paymentFields([
  // Amount in lowest currency (pence, cents etc.).
  // Currency in valid currency code.
  // Success URL is the route we will post to completed form data to.
  'amount' =>  12500, 'currency' => 'GBP', 'successUrl' => route('payment.submit')
])
@endpaymentFields
  
// Somewhere towards the footer
@paymentScripts()
@endpaymentScripts

Customisation

Currently, there are two things you can do to change the look of the payment form. These can be registered in your \App\Providers\AppServiceProvider's boot method.

use ChrisBraybrooke\LaravelStripePaymentIntent\Facades\StripePaymentIntent;

/**
 * Bootstrap any application services.
 *
 * @return void
 */
public function boot()
{
  	// Will give the inputs on the payment form a class of: 'form-control'
    StripePaymentIntent::setInputClass('form-control');
    
  	// Will change the colour of elements like the submit button.
  	StripePaymentIntent::setThemeColor('#efefef');
}