### Install Stripe Library with Composer Source: https://github.com/payum/payumbundle/blob/master/Resources/doc/custom_purchase_examples/stripe_js.md Run this command to add the Stripe payment gateway library to your project. ```bash $ composer require "payum/stripe" ``` -------------------------------- ### Install Klarna Invoice Library Source: https://github.com/payum/payumbundle/blob/master/Resources/doc/custom_purchase_examples/klarna_invoice.md Use Composer to add the Klarna Invoice payment provider library to your project. ```bash $ composer require "payum/klarna-invoice:@stable" ``` -------------------------------- ### Install Be2bill Library Source: https://github.com/payum/payumbundle/blob/master/Resources/doc/custom_purchase_examples/be2bill.md Run this command to add the Be2bill payment gateway library to your project. ```bash $ composer require "payum/be2bill" ``` -------------------------------- ### Install Stripe Library Source: https://github.com/payum/payumbundle/blob/master/Resources/doc/custom_purchase_examples/stripe_checkout.md Use Composer to add the Stripe payment gateway library to your project. ```bash composer require "payum/stripe" ``` -------------------------------- ### Install Payex Library Source: https://github.com/payum/payumbundle/blob/master/Resources/doc/custom_purchase_examples/payex.md Run this composer command to add the Payex library to your project dependencies. ```bash $ composer require "payum/payex" ``` -------------------------------- ### Install PayPal Pro Checkout Library Source: https://github.com/payum/payumbundle/blob/master/Resources/doc/custom_purchase_examples/paypal_pro_checkout.md Use Composer to install the necessary library for PayPal Pro Checkout integration. ```bash composer require "payum/paypal-pro-checkout-nvp" ``` -------------------------------- ### Install Klarna Checkout Library Source: https://github.com/payum/payumbundle/blob/master/Resources/doc/custom_purchase_examples/klarna_checkout.md Use Composer to add the Klarna Checkout library to your project. This is the first step in integrating the gateway. ```bash $ composer require "payum/klarna-checkout:@stable" ``` -------------------------------- ### Install PayPal Express Checkout Library Source: https://github.com/payum/payumbundle/blob/master/Resources/doc/custom_purchase_examples/paypal_express_checkout.md Run this composer command to add the PayPal Express Checkout library to your project. Ensure you have Composer installed. ```bash $ composer require "payum/paypal-express-checkout-nvp" ``` -------------------------------- ### Install Authorize.NET AIM Library Source: https://github.com/payum/payumbundle/blob/master/Resources/doc/custom_purchase_examples/authorize_net_aim.md Use Composer to add the Authorize.NET AIM library to your project dependencies. ```bash $ composer require "payum/authorize-net-aim" ``` -------------------------------- ### Install Payum Bundle and Gateways Source: https://github.com/payum/payumbundle/blob/master/Resources/doc/get_it_started.md Use composer to require the PayumBundle and desired payment gateway extensions. Ensure you select appropriate gateway packages for your needs. ```bash composer require "payum/payum-bundle" "payum/offline" "php-http/guzzle7-adapter" ``` -------------------------------- ### Install Libraries for Stripe and Omnipay Source: https://github.com/payum/payumbundle/blob/master/Resources/doc/custom_purchase_examples/stripe_via_omnipay.md Run this command to add the necessary Payum bridge and Stripe omnipay library to your project. ```bash $ composer require "payum/omnipay-bridge" "omnipay/stripe:~2.0" ``` -------------------------------- ### Install Omnipay Bridge and Paypal Library Source: https://github.com/payum/payumbundle/blob/master/Resources/doc/custom_purchase_examples/paypal_via_omnipay.md Run this command to add the necessary Composer packages for Omnipay Paypal integration. ```bash $ composer require "payum/omnipay-bridge" "omnipay/paypal:~2.0" ``` -------------------------------- ### Perform a Purchase with PayumBundle Source: https://github.com/payum/payumbundle/blob/master/README.md Initiate a payment purchase using the PayumBundle. This example demonstrates setting up a payment model and executing a capture request. ```php setNumber(uniqid()); $payment->setCurrencyCode('EUR'); $payment->setTotalAmount(123); // 1.23 EUR $payment->setDescription('A description'); $payment->setClientId('anId'); $payment->setClientEmail('foo@example.com'); $gateway = $this->get('payum')->getGateway('offline'); $gateway->execute(new Capture($payment)); ``` -------------------------------- ### Update Storage Configuration (Payum 0.8 to 0.9) Source: https://github.com/payum/payumbundle/blob/master/UPGRADE.md Storage configurations have moved from within a context to a root `payum.storages` section. This example shows how to migrate. ```yml payum: a_context: a_factory: storages: Acme\PaymentBundle\Entity\PaymentDetails: doctrine: driver: orm ``` ```yml payum: storages: Acme\PaymentBundle\Entity\PaymentDetails: payment: contexts: [a_factory] doctrine: orm a_context: a_factory: ``` -------------------------------- ### Configure Payum Storages and Gateways Source: https://github.com/payum/payumbundle/blob/master/Resources/doc/get_it_started.md Configure Payum's token and payment storages using Doctrine ORM and define the available payment gateways. This example sets up an 'offline' gateway. ```yaml #config/packages/payum.yml payum: security: token_storage: Acme\PaymentBundle\Entity\PaymentToken: { doctrine: orm } storages: Acme\PaymentBundle\Entity\Payment: { doctrine: orm } gateways: offline: factory: offline ``` -------------------------------- ### Migrate Gateway Configuration (Payum 1.x to 2.0) Source: https://github.com/payum/payumbundle/blob/master/UPGRADE.md The configuration for gateways has been updated. The `gateways_v2` option is now `gateways`, and the old `gateways` option is removed. Refer to the provided gist for detailed examples. ```yml payum: gateways: # ... gateway configurations ``` -------------------------------- ### Get Currency Details with GetCurrency Request Source: https://github.com/payum/payumbundle/blob/master/Resources/doc/iso4217-or-currency-details.md Execute a GetCurrency request to retrieve details like alpha3 code, name, exponent, and country for a given currency. This can be done directly or within another action. ```php payum->getGatewayFactory('offline')->create(); $gateway->execute($currency = new \Payum\Core\GetCurrency('USD')); echo $currency->alpha3; // USD echo $currency->name; // US Dollar echo $currency->exp; // 2 echo $currency->country; // US // and so on... ``` ```php gateway->execute($currency = new Payum\Core\GetCurrency('USD')); } } ``` -------------------------------- ### Retrieve Currency Details Directly with ISO4217 Service Source: https://github.com/payum/payumbundle/blob/master/Resources/doc/iso4217-or-currency-details.md Access the ISO4217 service directly to find currency details by its alpha3 code. This method provides a more direct way to get currency information. ```php get('payum.iso4217'); /** @var \Payum\ISO4216\Currency $currency **/ $currency = $iso4217->findByAlpha3('USD'); echo $currency->getAlpha3(); // USD echo $currency->getName(); // US Dollar echo $currency->getExp(); // 2 echo $currency->getCountry(); // US ``` -------------------------------- ### Use Backend-Configured Gateway in Controller Source: https://github.com/payum/payumbundle/blob/master/Resources/doc/configure-payment-in-backend.md Demonstrates how to create a payment, set its details, and generate a capture token using a gateway configured dynamically in the backend. Ensure the 'done' route is defined for redirection. ```php payum->getStorage('Acme\PaymentBundle\Entity\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'); $storage->update($payment); $captureToken = $this->payum->getTokenFactory()->createCaptureToken( $gatewayName, $payment, 'done' // the route to redirect after capture ); return $this->redirect($captureToken->getTargetUrl()); } } ``` -------------------------------- ### Get Payment Status with PayumBundle Source: https://github.com/payum/payumbundle/blob/master/README.md Retrieve the human-readable status of a payment using PayumBundle. Ensure the payment object is already defined. ```php execute($status = new GetHumanStatus($payment)); echo $status->getValue(); ``` -------------------------------- ### Payum Bundle Configuration: Before 0.6 Source: https://github.com/payum/payumbundle/blob/master/UPGRADE.md Illustrates the configuration structure for storages in Payum Bundle prior to version 0.6. ```yaml payum: contexts: foo: storages: Acme\PaymentBundle\Entity\TokenizedDetails: filesystem: storage_dir: %kernel.root_dir%/Resources/payments id_property: token ``` -------------------------------- ### Get Payment Status Source: https://github.com/payum/payumbundle/blob/master/Resources/doc/console_commands.md Use this command to retrieve the current status of a payment. Specify the payment name, model class, and model ID. ```bash $ php bin/console payum:status paypal --model-class=Acme\PaymentBundle\Entity\Payment --model-id=1 > Status: success ``` -------------------------------- ### Tag Custom Action for All Gateways with Prepend Option Source: https://github.com/payum/payumbundle/blob/master/Resources/doc/custom_action_usage.md Tag your custom action service with `payum.action` and set `all: true` to apply it to all gateways. Use `prepend: true` to add it before other actions. ```yaml # src/Acme/PaymentBundle/Resources/config/services.yml services: acme.payum.action.foo: class: Acme\PaymentBundle\Payum\Action\FooAction public: true tags: - {name: payum.action, prepend: true, all: true } ``` -------------------------------- ### Explicitly Pass Credit Card Details Source: https://github.com/payum/payumbundle/blob/master/Resources/doc/custom_purchase_examples/paypal_pro_checkout.md Example of how to explicitly pass sensitive credit card details like account number, CVV2, and expiration date using `SensitiveValue`. ```php payum->getHttpRequestVerifier()->verify($request); $identity = $token->getDetails(); $model = $this->payum->getStorage($identity->getClass())->find($identity); $gateway = $this->payum->getGateway($token->getGatewayName()); // you can invalidate the token. The url could not be requested any more. // $this->payum->getHttpRequestVerifier()->invalidate($token); // Once you have token you can get the model from the storage directly. //$identity = $token->getDetails(); //$details = $payum->getStorage($identity->getClass())->find($identity); // or Payum can fetch the model for you while executing a request (Preferred). $gateway->execute($status = new GetHumanStatus($token)); $details = $status->getFirstModel(); // you have order and payment status // so you can do whatever you want for example you can just print status and payment details. return new JsonResponse(array( 'status' => $status->getValue(), 'details' => iterator_to_array($details), )); } ``` -------------------------------- ### Debug Payment Gateway Source: https://github.com/payum/payumbundle/blob/master/Resources/doc/debugging.md Run this command to inspect the actions, extensions, and APIs added to a payment. It helps in understanding the payment processing flow. ```bash php bin/console payum:gateway:debug ``` -------------------------------- ### Prepare Payment Order and Capture Token Source: https://github.com/payum/payumbundle/blob/master/Resources/doc/get_it_started.md Controller action to create a payment entity, set its details, and generate a capture token. It then redirects the user to the token's target URL to initiate the payment process. ```php payum->getStorage('Acme\PaymentBundle\Entity\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'); $storage->update($payment); $captureToken = $this->payum->getTokenFactory()->createCaptureToken( $gatewayName, $payment, 'done' // the route to redirect after capture ); return $this->redirect($captureToken->getTargetUrl()); } } ``` -------------------------------- ### Register an API Service Source: https://github.com/payum/payumbundle/blob/master/Resources/doc/container_tags.md Use the `payum.api` tag to register a service as an API. The service can be any object. Attributes like `factory`, `gateway`, `all`, `alias`, and `prepend` control where the API is applied. ```yaml services: acme.foo_api: class: Acme\Payum\FooApi public: true tags: - { name: payum.api, factory: foo, gateway: bar, all: true, alias: foo, prepend: false } ``` -------------------------------- ### Simplify API Options Configuration (Payum 0.8 to 0.9) Source: https://github.com/payum/payumbundle/blob/master/UPGRADE.md API options previously nested under `api.options` should now be moved to the root of the factory configuration. This simplifies the structure. ```yml payum: a_context: a_factory: api: options: foo: foo bar: bar ``` ```yml payum: a_context: a_factory: foo: foo bar: bar ``` -------------------------------- ### Prepare Payment Authorization Source: https://github.com/payum/payumbundle/blob/master/Resources/doc/authorize.md Use this controller action to prepare a payment for authorization. It sets up payment details and creates a capture token, redirecting to the target URL for completion. ```php payum->getStorage('Acme\PaymentBundle\Entity\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'); $storage->update($payment); $captureToken = $this->payum->getTokenFactory()->createCaptureToken( $gatewayName, $payment, 'done' // the route to redirect after capture; ); return $this->redirect($captureToken->getTargetUrl()) } } ``` -------------------------------- ### Register an Extension Service Source: https://github.com/payum/payumbundle/blob/master/Resources/doc/container_tags.md Use the `payum.extension` tag to register a service as an extension. The service must implement `Payum\Core\Extension\ExtensionInterface`. Attributes like `factory`, `gateway`, `all`, `alias`, and `prepend` control where the extension is applied. ```yaml services: acme.foo_extension: class: Payum\Core\Extension\ExtensionInterface public: true tags: - { name: payum.extension, factory: foo, gateway: bar, all: true, alias: foo, prepend: false } ``` -------------------------------- ### Clear Cache and Debug Source: https://github.com/payum/payumbundle/blob/master/UPGRADE-3.0.md After migrating configurations, clear the application cache and use debug commands to verify the container and router configurations. ```bash php bin/console cache:clear ``` ```bash php bin/console debug:container payum ``` ```bash php bin/console debug:router | grep payum ``` -------------------------------- ### Create Purchase Token Source: https://github.com/payum/payumbundle/blob/master/Resources/doc/console_commands.md Creates a purchase link that can be sent manually via email or used when a user needs a new payment link. Requires payment details and a URL to redirect to after purchase. ```bash $ php bin/console payum:security:create-capture-token paypal \ --model-class=Acme\PaymentBundle\Entity\Payment \ --model-id=1 \ --after-url="url-or-route-to-go-after-purchase" > Hash: oTA0w-SRaVY8U1pRr6MVshAtdjiogRENTlnJit6lYLg > Url: http://localhost/payment/capture/oTA0w-SRaVY8U1pRr6MVshAtdjiogRENTlnJit6lYLg > After Url: url-or-route-to-go-after-purchase > Details: Acme\PaymentBundle\Entity\Payment#1 ``` -------------------------------- ### Custom Gateway Configuration Source: https://github.com/payum/payumbundle/blob/master/Resources/doc/configuration_reference.md Configure a custom gateway. If the service is not set, an empty gateway will be created. ```yaml payum: gateways: aName: factory: custom # if service not set an empty gateway will be created. service: ~ ``` -------------------------------- ### Configure Stripe.js Gateway Source: https://github.com/payum/payumbundle/blob/master/Resources/doc/custom_purchase_examples/stripe_js.md Configure your Stripe.js gateway in `config/packages/payum.yml`. Ensure you replace `your_gateway_here` with a descriptive name and provide your Stripe publishable and secret keys. ```yaml payum: gateways: your_gateway_here: factory: stripe_js publishable_key: 'get this from gateway' secret_key: 'get this from gateway' ``` -------------------------------- ### Configure PayPal Express Checkout Gateway Source: https://github.com/payum/payumbundle/blob/master/Resources/doc/custom_purchase_examples/paypal_express_checkout.md Add this configuration to your `payum.yml` file. Replace placeholder values with your actual PayPal credentials and choose whether to use sandbox mode. ```yaml payum: gateways: your_gateway_here: factory: paypal_express_checkout username: 'get this from gateway side' password: 'get this from gateway side' signature: 'get this from gateway side' sandbox: true ``` -------------------------------- ### Prepare Payment with Authorize.NET AIM Source: https://github.com/payum/payumbundle/blob/master/Resources/doc/custom_purchase_examples/authorize_net_aim.md Prepare payment details for Authorize.NET AIM, including amount and client email. This code snippet demonstrates how to create and update payment details and generate a capture token for redirection. ```php get('payum')->getStorage('Acme\PaymentBundle\Entity\PaymentDetails'); /** @var \Acme\PaymentBundle\Entity\PaymentDetails $details */ $details = $storage->create(); $details['amount'] = 1.23; $details['clientemail'] = 'user@email.com'; $storage->update($details); $captureToken = $this->get('payum')->getTokenFactory()->createCaptureToken( $gatewayName, $details, 'acme_gateway_done' // the route to redirect after capture ); return $this->redirect($captureToken->getTargetUrl()); } } ``` -------------------------------- ### Configure Klarna Invoice Gateway Source: https://github.com/payum/payumbundle/blob/master/Resources/doc/custom_purchase_examples/klarna_invoice.md Set up the Klarna Invoice gateway in your PayumBundle configuration. Remember to replace placeholder values with your actual credentials and choose a descriptive gateway name. ```yaml payum: gateways: your_gateway_here: factory: klarna_invoice secret: 'EDIT ME' eid: 'EDIT ME' sandbox: true ``` -------------------------------- ### Configure Omnipay Paypal Gateway Source: https://github.com/payum/payumbundle/blob/master/Resources/doc/custom_purchase_examples/paypal_via_omnipay.md Configure your Payum gateway in `config/packages/payum.yml` to use the Omnipay Paypal_Express factory. Replace placeholder credentials with your actual Paypal details. Set `testMode` to `true` for testing. ```yaml payum: gateways: your_gateway_here: factory: omnipay type: Paypal_Express username: 'REPLACE IT', password: 'REPLACE IT', signature: 'REPLACE IT', testMode: true ``` -------------------------------- ### Configure PayumBundle Source: https://github.com/payum/payumbundle/blob/master/README.md Configure PayumBundle for storages and gateways. For Symfony 4+, create a `config/packages/payum.yaml` file. ```yaml payum: storages: Payum\Core\Model\Payment: filesystem: storage_dir: '%kernel.root_dir%/Resources/payments' id_property: number security: token_storage: Payum\Core\Model\Token: filesystem: storage_dir: '%kernel.root_dir%/Resources/gateways' id_property: hash gateways: offline: factory: offline ``` -------------------------------- ### Migrate Service Configuration: XML to PHP Source: https://github.com/payum/payumbundle/blob/master/UPGRADE-3.0.md Update your service configuration imports from XML to PHP format for PayumBundle 3.0. ```yaml imports: - { resource: '@PayumBundle/Resources/config/payum.xml' } - { resource: '@PayumBundle/Resources/config/storage/doctrine.orm.xml' } ``` ```yaml imports: - { resource: '@PayumBundle/Resources/config/payum.php' } - { resource: '@PayumBundle/Resources/config/storage/doctrine.orm.php' } ``` -------------------------------- ### Create Capture Token - PHP Source: https://github.com/payum/payumbundle/blob/master/Resources/doc/purchase_done_action.md Use this to create a capture token for a payment, specifying the gateway, payment details, and the route for redirection after the capture is complete. ```php payum->getTokenFactory()->createCaptureToken( $gatewayName, $details, 'acme_payment_done' ); ``` -------------------------------- ### Register a Gateway Service Source: https://github.com/payum/payumbundle/blob/master/Resources/doc/container_tags.md Use the `payum.gateway` tag to register a service as a gateway. The service must implement `Payum\Core\GatewayInterface`. The `gateway` attribute defines the name of the gateway. ```yaml services: acme.foo_gateway: class: Payum\Core\Gateway public: true tags: - { name: payum.gateway, gateway: foo } ``` -------------------------------- ### Prepare Payment for PayPal Pro Checkout Source: https://github.com/payum/payumbundle/blob/master/Resources/doc/custom_purchase_examples/paypal_pro_checkout.md Prepare payment details, including amount and currency, and create a capture token to redirect the user for payment processing. The 'acme_payment_done' route is specified as the redirect destination after the capture. ```php get('payum')->getStorage('Acme\PaymentBundle\Entity\PaymentDetails'); /** @var \Acme\PaymentBundle\Entity\PaymentDetails $details */ $details = $storage->create(); $details['amt'] = 1; $details['currency'] = 'USD'; $storage->update($details); $captureToken = $this->get('payum')->getTokenFactory()->createCaptureToken( $gatewayName, $details, 'acme_payment_done' // the route to redirect after capture; ); return $this->redirect($captureToken->getTargetUrl()); } } ``` -------------------------------- ### Define API Factory and Service in YAML Source: https://github.com/payum/payumbundle/blob/master/Resources/doc/custom_api_usage.md This YAML configuration defines the API factory service using environment variables for credentials and then defines the custom PayPal Express Checkout API service, linking it to the factory. ```yaml # src/Acme/PaymentBundle/Resources/config/services.yml services: # ... acme.payment.payum.api.factory: class: Acme\PaymentBundle\Payum\Api\Factory arguments: $username: '%env(PAYPAL_EXPRESS_CHECKOUT_USERNAME)%' $password: '%env(PAYPAL_EXPRESS_CHECKOUT_PASSWORD)%' $signature: '%env(PAYPAL_EXPRESS_CHECKOUT_SIGNATURE)%' acme.payment.payum.paypal_express_checkout_api: class: Payum\Paypal\ExpressCheckout\Nvp\Api public: true factory_service: acme.payment.payum.api.factory factory_method: createPaypalExpressCheckoutApi ``` -------------------------------- ### Payum Bundle Configuration: After 0.6 Source: https://github.com/payum/payumbundle/blob/master/UPGRADE.md Shows the updated configuration structure for security tokens in Payum Bundle from version 0.6 onwards. Note the change in storage entity and `id_property`. ```yaml payum: security: token_storage: Acme\PaymentBundle\Entity\PayumSecurityToken: filesystem: storage_dir: %kernel.root_dir%/Resources/payments id_property: hash ``` -------------------------------- ### Define Custom Action Service Source: https://github.com/payum/payumbundle/blob/master/Resources/doc/custom_action_usage.md Define your custom action as a service in your services.yml file. Ensure it is publicly accessible. ```yaml # src/Acme/PaymentBundle/Resources/config/services.yml services: acme.payum.action.foo: class: Acme\PaymentBundle\Payum\Action\FooAction public: true ``` -------------------------------- ### Prepare Paypal Payment Action Source: https://github.com/payum/payumbundle/blob/master/Resources/doc/custom_purchase_examples/paypal_via_omnipay.md This Symfony controller action prepares a payment using the configured Omnipay Paypal gateway. It sets the payment amount and creates a capture token for redirection. Ensure your `PaymentDetails` entity and `acme_payment_done` route are correctly set up. ```php get('payum')->getStorage('Acme PaymentBundle Entity PaymentDetails'); /** @var Acme PaymentBundle Entity PaymentDetails */ $details = $storage->create(); $details['amount'] = 10; $storage->update($details); $captureToken = $this->get('payum')->getTokenFactory()->createCaptureToken( $gatewayName, $details, 'acme_payment_done' // the route to redirect after capture; ); return $this->redirect($captureToken->getTargetUrl()); } } ``` -------------------------------- ### Payum Default Storage Configuration Source: https://github.com/payum/payumbundle/blob/master/Resources/doc/configuration_reference.md Configure default storages for Payum models. Supports 'all' flag and specific factories or payments. ```yaml payum: storages: A\Model\Class: gateway: all: true factories: [] payments: [] # storage specific options Another\Model\Class: payment: all: true factories: [] payments: [] # storage specific options ``` -------------------------------- ### Prepare Klarna Invoice Payment Source: https://github.com/payum/payumbundle/blob/master/Resources/doc/custom_purchase_examples/klarna_invoice.md Prepare a payment by setting details such as price, currency, and cart items in the format required by Klarna. This snippet demonstrates how to create and store payment details, then generate a capture token to redirect the user. ```php get('payum')->getStorage('Acme\PaymentBundle\Entity\PaymentDetails'); /** @var \Acme\PaymentBundle\Entity\PaymentDetails $details */ $payment = $payum->getPayment($paymentName); $payment->execute($getAddresses = new GetAddresses($pno)); $details = $storage->create(); $details = array( /** @link https://developers.klarna.com/en/testing/invoice-and-account */ 'pno' => '410321-9202', 'amount' => -1, 'gender' => \KlarnaFlags::MALE, 'articles' => array( array( 'qty' => 4, 'artNo' => 'HANDLING', 'title' => 'Handling fee', 'price' => '50.99', 'vat' => '25', 'discount' => '0', 'flags' => \KlarnaFlags::INC_VAT | \KlarnaFlags::IS_HANDLING ), ), 'billing_address' => $getAddresses->getFirstAddress()->toArray(), 'shipping_address' => $getAddresses->getFirstAddress()->toArray(), ); $storage->update($details); $captureToken = $this->getTokenFactory()->createCaptureToken( $gatewayName, $details, 'acme_payment_done' ); $storage->update($details); return $this->redirect($captureToken->getTargetUrl()); } } ``` -------------------------------- ### Authorize.Net AIM Gateway Configuration Source: https://github.com/payum/payumbundle/blob/master/Resources/doc/configuration_reference.md Configure the Authorize.Net AIM gateway with login ID, transaction key, and sandbox mode. ```yaml payum: gateways: aName: factory: authorize_net_aim login_id: 'required' transaction_key: 'required' sandbox: true ``` -------------------------------- ### Register a Gateway Factory Service Source: https://github.com/payum/payumbundle/blob/master/Resources/doc/container_tags.md Use the `payum.gateway_factory` tag to register a service as a gateway factory. The service must implement `Payum\Core\GatewayFactoryInterface`. The `factory` attribute defines the name of the factory. ```yaml services: acme.foo_gateway_factory: class: Payum\Core\GatewayFactory public: true tags: - { name: payum.gateway_factory, factory: foo } ``` -------------------------------- ### Payum Gateway Configuration Source: https://github.com/payum/payumbundle/blob/master/Resources/doc/configuration_reference.md Configure Payum gateways with options, layout templates, container parameters, and services. ```yaml payum: gateways: foo_gateway: # options bar_gateway: # options payum.template.layout: "AcmeDemoBundle::layout.html.twig" #use container parameter payum.template.foo: "%aParameterName%" # use service from container payum.action.foo: "@aServiceId" payum.api.foo: "@aServiceId" payum.extension.foo: "@aServiceId" ``` -------------------------------- ### Register Custom Storage Service Source: https://github.com/payum/payumbundle/blob/master/Resources/doc/storages.md Register the custom storage implementation as a service in the Payum configuration. ```yaml # config/packages/payum.yml services: acme.payment.payum.storage.custom: class: Acme\PaymentBundle\Payum\Storage\CustomStorage ``` -------------------------------- ### Configure Payum Filesystem Token Storage Source: https://github.com/payum/payumbundle/blob/master/Resources/doc/storages.md Configure Payum to use filesystem storage for the custom PaymentToken class. Specify the storage directory and the property used for identification. ```yaml # config/packages/payum.yml payum: security: token_storage: Acme\PaymentBundle\Model\PaymentToken: filesystem: storage_dir: %kernel.root_dir%/Resources/payments id_property: hash ``` -------------------------------- ### Klarna Invoice Gateway Configuration Source: https://github.com/payum/payumbundle/blob/master/Resources/doc/configuration_reference.md Configure the Klarna Invoice gateway with secret, EID, country, language, currency, and sandbox mode. ```yaml payum: gateways: aName: factory: klarna_invoice secret: 'required' eid: 'required' country: SE language: SV currency: SEK sandbox: true ``` -------------------------------- ### Omnipay Gateway Configuration Source: https://github.com/payum/payumbundle/blob/master/Resources/doc/configuration_reference.md Configure an Omnipay gateway with a type and options. ```yaml payum: gateways: aName: factory: omnipay type: 'required' options: foo: fooOpt bar: barOpt ``` -------------------------------- ### Configure Payex Gateway Source: https://github.com/payum/payumbundle/blob/master/Resources/doc/custom_purchase_examples/payex.md Configure the Payex gateway in your PayumBundle settings. Ensure you replace placeholder values with your actual account credentials and set the sandbox mode appropriately. ```yaml payum: gateways: your_gateway_here: factory: payex account_number: 'get this from gateway side' encryption_key: 'get this from gateway side' sandbox: true ``` -------------------------------- ### Enable PayumBundle in Kernel Source: https://github.com/payum/payumbundle/blob/master/Resources/doc/get_it_started.md Register the PayumBundle in your Symfony application's kernel configuration. This step is typically handled by Symfony Flex, but manual addition is shown here. ```php ['all' => true], ]; ``` -------------------------------- ### Migrate Routing Configuration: XML to YAML Source: https://github.com/payum/payumbundle/blob/master/UPGRADE-3.0.md Update your routing configuration imports from XML to YAML format for PayumBundle 3.0. ```yaml _payum: resource: '@PayumBundle/Resources/config/routing/all.xml' ``` ```yaml _payum: resource: '@PayumBundle/Resources/config/routing/all.yaml' ``` -------------------------------- ### Create Notify Token Source: https://github.com/payum/payumbundle/blob/master/Resources/doc/console_commands.md Generates a secure URL for payment gateway notifications, useful when the gateway does not support per-model callback URLs. Optionally associates a model with the token. ```bash $ php bin/console payum:security:create-notify-token paypal --model-class=Acme\PaymentBundle\Entity\Payment --model-id=1 > Hash: oTA0w-SRaVY8U1pRr6MVshAtdjiogRENTlnJit6lYLg > Url: http://localhost/payment/notify/oTA0w-SRaVY8U1pRr6MVshAtdjiogRENTlnJit6lYLg > Details: Acme\PaymentBundle\Entity\Payment#1 ``` -------------------------------- ### Configure PayPal Pro Checkout Gateway Source: https://github.com/payum/payumbundle/blob/master/Resources/doc/custom_purchase_examples/paypal_pro_checkout.md Configure the PayPal Pro Checkout gateway in your PayumBundle settings. Ensure you replace placeholder credentials with your actual PayPal API details. The 'tender' parameter specifies the payment method (C for Credit Card, P for PayPal, A for ACH). ```yaml payum: gateways: your_gateway_here: factory: paypal_pro_checkout username: 'EDIT ME' password: 'EDIT ME' partner: 'EDIT ME' vendor: 'EDIT ME' tender: C sandbox: true ``` -------------------------------- ### Payum ORM Storage Configuration Source: https://github.com/payum/payumbundle/blob/master/Resources/doc/storages.md Configure Payum to use Doctrine ORM for token and payment detail storage. ```yaml # config/packages/payum.yml payum: security: token_storage: Acme\PaymentBundle\Entity\PaymentToken: { doctrine: orm } storages: Acme\PaymentBundle\Entity\PaymentDetails: { doctrine: orm } ``` -------------------------------- ### Payex Gateway Configuration Source: https://github.com/payum/payumbundle/blob/master/Resources/doc/configuration_reference.md Configure the Payex gateway with encryption key, account number, and sandbox mode. ```yaml payum: gateways: aName: factory: payex encryption_key: 'required' account_number: 'required' sandbox: true ``` -------------------------------- ### Prepare Stripe.js Payment in Controller Source: https://github.com/payum/payumbundle/blob/master/Resources/doc/custom_purchase_examples/stripe_js.md Prepare payment details such as amount, currency, and description in your controller. This code snippet demonstrates how to create and update payment details and then generate a capture token for redirection. ```php getPayum()->getStorage('Acme\GatewayBundle\Entity\PaymentDetails'); /** @var PaymentDetails $details */ $details = $storage->create(); $details["amount"] = 100; $details["currency"] = 'USD'; $details["description"] = 'a description'; $storage->update($details); $captureToken = $this->get('payum')->getTokenFactory()->createCaptureToken( $gatewayName, $details, 'acme_payment_done' // the route to redirect after capture; ); return $this->redirect($captureToken->getTargetUrl()); } } ``` -------------------------------- ### Configure Payum Filesystem Payment Details Storage Source: https://github.com/payum/payumbundle/blob/master/Resources/doc/storages.md Configure Payum to use filesystem storage for the custom PaymentDetails class. Define the storage directory and the ID property. ```yaml storages: Acme\PaymentBundle\Model\PaymentDetails: filesystem: storage_dir: %kernel.root_dir%/Resources/payments id_property: id ``` -------------------------------- ### Define GatewayConfig Entity Source: https://github.com/payum/payumbundle/blob/master/Resources/doc/configure-payment-in-backend.md Create a Doctrine entity that implements Payum's GatewayConfigInterface to store gateway configurations. This entity must have an ID field. ```php fooGateway (Payum\Core\Gateway): > Actions: > Payum\Core\Action\CapturePaymentAction > Payum\Core\Action\NotifyOrderAction > Payum\Core\Action\ExecuteSameRequestWithModelDetailsAction > Payum\Bundle\PayumBundle\Action\GetHttpRequestAction > Payum\Bundle\PayumBundle\Action\ObtainCreditCardAction > Payum\Core\Bridge\Twig\Action\RenderTemplateAction > Payum\Offline\Action\CaptureAction > Payum\Offline\Action\ConvertPaymentAction > Payum\Offline\Action\StatusAction > > Extensions: > Payum\Core\Extension\EndlessCycleDetectorExtension > Payum\Core\Bridge\Psr\Log\LogExecutedActionsExtension > Payum\Core\Bridge\Psr\Log\LoggerExtension > Payum\Core\Extension\StorageExtension > Payum\Core\Storage\FilesystemStorage > Payum\Core\Model\ArrayObject > > Apis: ``` -------------------------------- ### Configure Stripe Gateway in Payum Source: https://github.com/payum/payumbundle/blob/master/Resources/doc/custom_purchase_examples/stripe_via_omnipay.md Configure the Stripe gateway in your Payum configuration file. Ensure you replace 'your_gateway_name' with a descriptive name and 'abc123' with your actual Stripe API key. Set 'testMode' to true for testing. ```yaml payum: gateways: your_gateway_here: factory: omnipay type: Stripe apiKey: abc123 testMode: true ``` -------------------------------- ### Payum Security Token Storage Configuration Source: https://github.com/payum/payumbundle/blob/master/Resources/doc/configuration_reference.md Configure the token storage for Payum security. Specify the model class and any storage-specific options. ```yaml payum: security: token_storage: A\Model\TokenClass: # storage specific options ``` -------------------------------- ### Stripe.Js Gateway Configuration Source: https://github.com/payum/payumbundle/blob/master/Resources/doc/configuration_reference.md Configure the Stripe.Js gateway with publishable and secret keys. ```yaml payum: gateways: aName: factory: stripe_js publishable_key: 'required' secret_key: 'required' ``` -------------------------------- ### Refund a Payment Source: https://github.com/payum/payumbundle/blob/master/Resources/doc/refund.md Use this snippet to initiate a refund for a payment. It also checks the status and dumps details if the refund fails. ```php payum->getGateway('offline'); $gateway->execute(new Refund($payment)); $gateway->execute($status = new GetHumanStatus($payment)); if ($status->isRefunded()) { // Refund went well } else { // Something went wrong. Lets check details to find out why var_dump($payment->getDetails()); } ``` -------------------------------- ### Be2Bill Gateway Configuration Source: https://github.com/payum/payumbundle/blob/master/Resources/doc/configuration_reference.md Configure the Be2Bill gateway with identifier, password, and sandbox mode. ```yaml payum: gateways: aName: factory: be2bill identifier: 'required' password: 'required' sandbox: true ``` -------------------------------- ### Payum Filesystem Storage Configuration Source: https://github.com/payum/payumbundle/blob/master/Resources/doc/configuration_reference.md Configure Payum to use filesystem storage, specifying the storage directory and ID property. ```yaml payum: storages: A\Model\Class: filesystem: storage_dir: 'required' id_property: 'required' ``` -------------------------------- ### Klarna Checkout Gateway Configuration Source: https://github.com/payum/payumbundle/blob/master/Resources/doc/configuration_reference.md Configure the Klarna Checkout gateway with secret, merchant ID, and sandbox mode. ```yaml payum: gateways: aName: factory: klarna_checkout secret: 'required' merchant_id: 'required' sandbox: true ``` -------------------------------- ### Be2Bill Onsite Gateway Configuration Source: https://github.com/payum/payumbundle/blob/master/Resources/doc/configuration_reference.md Configure the Be2Bill Onsite gateway with identifier, password, and sandbox mode. ```yaml payum: gateways: aName: factory: be2bill_onsite identifier: 'required' password: 'required' sandbox: true ``` -------------------------------- ### Prepare Stripe Payment in Symfony Controller Source: https://github.com/payum/payumbundle/blob/master/Resources/doc/custom_purchase_examples/stripe_via_omnipay.md This PHP code prepares a payment using the Stripe gateway. It creates payment details, sets the amount, and generates a capture token for redirection. Ensure your storage is configured for 'Acme\PaymentBundle\Entity\PaymentDetails'. ```php get('payum')->getStorage('Acme\PaymentBundle\Entity\PaymentDetails'); /** @var \Acme\PaymentBundle\Entity\PaymentDetails */ $details = $storage->create(); $details['amount'] = 10; $storage->update($details); $captureToken = $this->get('payum')->getTokenFactory()->createCaptureToken( $gatewayName, $details, 'acme_payment_done' // the route to redirect after capture; ); return $this->redirect($captureToken->getTargetUrl()); } } ``` -------------------------------- ### Propel Token Model Implementation Source: https://github.com/payum/payumbundle/blob/master/Resources/doc/storages.md Implement the Token class extending Propel's BaseToken for Propel ORM integration. ```php setHash(Random::generateToken()); } } ``` -------------------------------- ### Configure Klarna Checkout Gateway Source: https://github.com/payum/payumbundle/blob/master/Resources/doc/custom_purchase_examples/klarna_checkout.md Configure the Klarna Checkout gateway in your PayumBundle configuration file. Ensure you replace placeholder values with your actual merchant ID and secret. ```yaml payum: gateways: your_gateway_here: factory: klarna_checkout secret: 'get this from gateway side' merchant_id: 'REPLACE WITH YOUR MERCHANT_ID' sandbox: true ``` -------------------------------- ### Propel Payment Model Implementation Source: https://github.com/payum/payumbundle/blob/master/Resources/doc/storages.md Implement the Payment class extending Propel's BasePayment for Propel ORM integration. ```php