> For the complete documentation index, see [llms.txt](https://docs.payum.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.payum.dev/v2/laravel/examples.md).

# Examples

Paypal Express checkout

Described in [Get it started](/v2/laravel/get-it-started.md)

### Payment model

* Configuration

```bash
$ php composer.phar require payum/payum-laravel-package payum/offline
```

```php
// bootstrap/start.php

App::resolving('payum.builder', function(\Payum\Core\PayumBuilder $payumBuilder) {
    $payumBuilder
        ->addGateway('offline', ['factory' => 'offline'])
    ;
});
```

* Prepare payment

```php
<?php
// app/controllers/PaymentController.php

use Payum\LaravelPackage\Controller\PayumController;

class PaymentController extends PayumController
{
 	public function preparePayment()
 	{
         $storage = $this->getPayum()->getStorage('Payum\Core\Model\Payment');

         $payment = $storage->create();
         $payment->setNumber(uniqid());
         $payment->setCurrencyCode('EUR');
         $payment->setTotalAmount(123); // 1.23 EUR
         $payment->setDescription('A description');
         $payment->setClientId('anId');
         $payment->setClientEmail('foo@example.com');
         $payment->setDetails(array(
           // put here any fields in a gateway format.
           // for example if you use Paypal ExpressCheckout you can define a description of the first item:
           // 'L_PAYMENTREQUEST_0_DESC0' => 'A desc',
         ));
         $storage->update($payment);

         $captureToken = $payum->getTokenFactory()->createCaptureToken('offline', $payment, 'payment_done');

         return \Redirect::to($captureToken->getTargetUrl());
 	}
}
```

### Stripe.Js

* Configuration

```bash
$ php composer.phar require payum/payum-laravel-package stripe/stripe-php payum/stripe
```

```php
// bootstrap/start.php

App::resolving('payum.builder', function(\Payum\Core\PayumBuilder $payumBuilder) {
    $payumBuilder
        ->addGateway('stripe_js', [
            'factory' => 'stripe_js',
            'publishable_key' => 'EDIT ME',
            'secret_key' => 'EDIT ME',
         ])
    ;
});
```

* Prepare payment

```php
<?php
// app/controllers/StripeController.php

use Payum\LaravelPackage\Controller\PayumController;

class StripeController extends PayumController
{
 	public function prepareJs()
 	{
         $storage = $this->getPayum()->getStorage('Payum\Core\Model\ArrayObject');
 
         $details = $storage->create();
         $details['amount'] = '100';
         $details['currency'] = 'USD';
         $details['description'] = 'a desc';
         $storage->update($details);
 
         $captureToken = $this->getPayum()->getTokenFactory()->createCaptureToken('stripe_js', $details, 'payment_done');
 
         return \Redirect::to($captureToken->getTargetUrl());
 	}
}
```

### Stripe Checkout

* Configuration

```bash
$ php composer.phar require payum/stripe payum/payum-laravel-package stripe/stripe-php
```

```php
// bootstrap/start.php

App::resolving('payum.builder', function(\Payum\Core\PayumBuilder $payumBuilder) {
    $payumBuilder
        ->addGateway('stripe_checkout', [
            'factory' => 'stripe_checkout',
            'publishable_key' => 'EDIT ME',
            'secret_key' => 'EDIT ME',
         ])
    ;
});
```

* Prepare payment

```php
<?php
// app/controllers/StripeController.php

use Payum\LaravelPackage\Controller\PayumController;

class StripeController extends PayumController
{
 	public function prepareCheckout()
 	{
         $storage = $this->getPayum()->getStorage('Payum\Core\Model\ArrayObject');
 
         $details = $storage->create();
         $details['amount'] = '100';
         $details['currency'] = 'USD';
         $details['description'] = 'a desc';
         $storage->update($details);
 
         $captureToken = $this->getPayum()->getTokenFactory()->createCaptureToken('stripe_checkout', $details, 'payment_done');
 
         return \Redirect::to($captureToken->getTargetUrl());
 	}
}
```

### Stripe Direct (via Omnipay)

* Configuration

```bash
$ php composer.phar require payum/omnipay-bridge payum/payum-laravel-package omnipay/stripe
```

```php
// bootstrap/start.php

App::resolving('payum.builder', function(\Payum\Core\PayumBuilder $payumBuilder) {
    $payumBuilder
        ->addGateway('stripe_direct', [
            'factory' => 'omnipay_direct',
            'type' => 'Stripe',
            'options' => array(
                'apiKey' => 'EDIT ME',
                'testMode' => true,
            ),
         ])
    ;
});
```

* Prepare payment

```php
<?php
// app/controllers/OmnipayController.php

use Payum\LaravelPackage\Controller\PayumController;

class OmnipayController extends PayumController
{
 	public function prepareDirect()
 	{
         $storage = $this->getPayum()->getStorage('Payum\Core\Model\ArrayObject');
 
         $details = $storage->create();
         $details['amount'] = '10.00';
         $details['currency'] = 'USD';
         $storage->update($details);
 
         $captureToken = $this->getPayum()->getTokenFactory()->createCaptureToken('stripe_direct', $details, 'payment_done');
 
         return \Redirect::to($captureToken->getTargetUrl());
 	}
}
```

***

### Supporting Payum

Payum is an MIT-licensed open source project with its ongoing development made possible entirely by the support of community and our customers. If you'd like to join them, please consider:

* [Become a sponsor](https://github.com/sponsors/Payum)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.payum.dev/v2/laravel/examples.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
