PHP code example of hackeresq / laravel-stripe

1. Go to this page and download the library: Download hackeresq/laravel-stripe library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

hackeresq / laravel-stripe example snippets


'stripe' => [
    'secret' => env('STRIPE_SECRET'),
]

    // you can use the global helper function
    $stripe = stripe();

    // or the facade
    $stripe = Stripe::make();

    // get customer payment methods
    $paymentMethods = $stripe->paymentMethods->all([
        'type' => 'card',
        'customer' => 'cus_13374j9a2ff13j0oh8',
    ]);
    
    // create payment intent
    $paymentIntent = $stripe->paymentIntents->create([
        'amount' => 2000 // amount is in cents (or the lowest denomination of your currency)
        'currency' => 'usd',
        'payment_method_types' => ['card'],
        'customer' => 'cus_13374j9a2ff13j0oh8',
        'metadata' => []
    ]);

    // confirm payment intent
    $paymentIntent = $stripe->paymentIntents->confirm($paymentIntent['id'], [
        'payment_method' => $paymentMethod[0]['id'],
        'setup_future_usage' => 'off_session',
    ]);