PHP code example of programster / stripe-wrapper

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

    

programster / stripe-wrapper example snippets




use Programster\Stripe\Collections\SinglePaymentLineItemsCollection;
use Programster\Stripe\Collections\SubscriptionLineItemCollection;
use Programster\Stripe\Enums\Currency;
use Programster\Stripe\Enums\RecurringInterval;
use Programster\Stripe\Models\AdjustableQuantityConfig;
use Programster\Stripe\Models\FlowConfig;
use Programster\Stripe\Models\PriceDataForSinglePayment;
use Programster\Stripe\Models\RecurringConfig;
use Programster\Stripe\Models\SinglePaymentLineItem;
use Programster\Stripe\Models\SubscriptionLineItem;
use Programster\Stripe\Models\PriceDataForSubscription;
use Programster\Stripe\Models\ProductData;
use Programster\Stripe\StripeClient;

ity: 1,
        priceDataOrPriceId: $shirt,
        adjustableQuantityConfig: new AdjustableQuantityConfig(1, 100)
    ),
    new SinglePaymentLineItem(
        quantity: 1,
        priceDataOrPriceId: $shorts,
        adjustableQuantityConfig: new AdjustableQuantityConfig(1, 100)
    )
);

$checkoutSession = $client->createCheckoutSessionForSinglePayment(
    flowConfig: $flowConfig,
    items: $items,
);

# Redirect the user to the stripe payment page.
http_response_code(303);
header('Location: ' . $checkoutSession->url);



use Programster\Stripe\Collections\SinglePaymentLineItemsCollection;
use Programster\Stripe\Collections\SubscriptionLineItemCollection;
use Programster\Stripe\Enums\Currency;
use Programster\Stripe\Enums\RecurringInterval;
use Programster\Stripe\Models\AdjustableQuantityConfig;
use Programster\Stripe\Models\FlowConfig;
use Programster\Stripe\Models\PriceDataForSinglePayment;
use Programster\Stripe\Models\RecurringConfig;
use Programster\Stripe\Models\SinglePaymentLineItem;
use Programster\Stripe\Models\SubscriptionLineItem;
use Programster\Stripe\Models\PriceDataForSubscription;
use Programster\Stripe\Models\ProductData;
use Programster\Stripe\StripeClient;

    ),
    recurring: $recurringConfig,
);

$items = new SubscriptionLineItemCollection(
    new SubscriptionLineItem(
        quantity: 1,
        priceDataOrPriceId: $shirt,
        adjustableQuantityConfig: new AdjustableQuantityConfig(1, 100)
    ),
    new SubscriptionLineItem(
        quantity: 1,
        priceDataOrPriceId: $shorts,
        adjustableQuantityConfig: new AdjustableQuantityConfig(1, 100)
    )
);

$checkoutSession = $client->createCheckoutSessionForSubscription(
    flowConfig: $flowConfig,
    items: $items,
);

# Redirect the user to the stripe payment page.
http_response_code(303);
header('Location: ' . $checkoutSession->url);