Skip to content

Stripe

Stripe uses PaymentIntents for one-time payments and exposes subscriptions and payment links through the package. The payment flow is client-side: create an intent on the server, then confirm it using Stripe.js or a mobile SDK.

Install and configure

The Stripe SDK is optional and is not installed by the package itself:

composer require stripe/stripe-php:^17.4
STRIPE_PUBLIC_KEY=pk_test_...
STRIPE_SECRET_KEY=sk_test_...
STRIPE_WEBHOOK_SECRET=whsec_...
STRIPE_CALLBACK_URL=https://example.com/payment/callback

PaymentIntent flow

use Alphabalex\PaymentMadeEasy\Facades\Payment;

$intent = Payment::driver('stripe')->initializePayment([
    'email'    => 'customer@example.com',
    'amount'   => 25.00,
    'currency' => 'usd',
    'reference'=> 'ORDER_123',
]);

// Return the client secret to your trusted client and confirm with Stripe.js.
$clientSecret = $intent['data']['client_secret'];

Never expose the secret API key. On the server, verify the PaymentIntent or process its verified webhook before marking the order paid. The reference is attached to the intent metadata; verifyPayment() expects the PaymentIntent identifier.

Stripe represents a package plan as a Product plus recurring Price. createPlan() returns the Price ID as the plan code; pass that ID when creating a subscription. Intervals supported by the driver include day, week, month, and year. The package also implements the shared payment-link contract.

$driver = Payment::driver('stripe');
$plan = $driver->createPlan([
    'name' => 'Pro Monthly', 'amount' => 29.99,
    'currency' => 'usd', 'interval' => 'month',
]);
$subscription = $driver->createSubscription([
    'email' => 'customer@example.com',
    'plan_code' => $plan['data']['plan_code'],
]);

Webhooks and capabilities

Stripe implements the shared payment, subscription, and payment-link interfaces. Configure the Stripe webhook signing secret in STRIPE_WEBHOOK_SECRET, and register the package endpoint POST /webhooks/payment-gateways/stripe. The Stripe SDK is also required for webhook signature handling. See webhook setup and verification.

See Stripe in the API reference and installation notes for the full details.