PHP code example of getcandy / stripe

1. Go to this page and download the library: Download getcandy/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/ */

    

getcandy / stripe example snippets




return [
    // ...
    'types' => [
        'card' => [
            // ...
            'driver' => 'stripe',
        ],
    ],
];

'stripe' => [
    'key' => env('STRIPE_SECRET'),
    'public_key' => env('STRIPE_PK'),
],

use \GetCandy\Stripe\Facades\Stripe;

Stripe::createIntent(\GetCandy\Models\Cart $cart);

$cart->meta->payment_intent;

use \GetCandy\Stripe\Facades\Stripe;

Stripe::fetchIntent($paymentIntentId);

if ($request->payment_intent) {
    $payment = \GetCandy\Facades\Payments::driver('card')->cart($cart)->withData([
        'payment_intent_client_secret' => $request->payment_intent_client_secret,
        'payment_intent' => $request->payment_intent,
    ])->authorize();

    if ($payment->success) {
        redirect()->route('checkout-success.view');
        return;
    }
}

sh
php artisan vendor:publish --tag=getcandy.stripe.config
sh
php artisan vendor:publish --tag=getcandy.stripe.components