PHP code example of origami / stripe

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

    

origami / stripe example snippets


    
    'stripe' => [
        'secret' => env('STRIPE_SECRET'),
        'key' => env('STRIPE_KEY'),
        'webhook' => [
            'secret' => env('STRIPE_WEBHOOK_SECRET'),
        ]
    ],


// Make a Payment from a payment_intent ID. 
$payment = Origami\Stripe\Payment::find($id);

// Or create a Payment as a new payment_intent
$payment = Origami\Stripe\Payment::create([
    'amount' => 1000,
    'currency' => 'gbp',
    'payment_method' => $method,
    'capture_method' => 'manual',
    'payment_method_types' => ['card'],
    'confirmation_method' => 'manual',
    'confirm' => true,
]));

$payment->amount();

public function hasStatus($status)

$payment->hasStatus(['

$payment->>isCancelled();
$payment->isSucceeded();
$payment->isSuccessful(); // Alias for above

try {
    
    $payment = Origami\Stripe\Payment::create([
        'amount' => 1000,
        'currency' => 'gbp',
        'payment_method' => $method,
        'capture_method' => 'manual',
        'payment_method_types' => ['card'],
        'confirmation_method' => 'manual',
        'confirm' => true,
    ]));

    if (!$payment) {
        throw new Exception('Error fetching Stripe payment');
    }

    $payment->validate();

    // PaymentIntent is valid
    // capture_method: manual above means we need to capture in another controller
    // capture_method: automatic above means the payment was successully taken

    return response([
        'payment_intent_id' => $payment->id,
        'success' => true,
    ]);

} catch (Origami\Stripe\PaymentActionRequired $e) {
    // Action is