User Defined Forms Conditional Payments Let's you add conditions to calculate amount and require payment using omnipay module
-
Install it using composer
composer require a2nt/userdefinedforms-payments -
Define Payment configuration app/_config/api-payment.yml
---
Name: 'webapp-api-payment'
---
SilverStripe\Omnipay\Model\Payment:
allowed_gateways:
- 'PayPal_Express'
SilverStripe\Omnipay\GatewayInfo:
PayPal_Express:
parameters:
username: ''
password: ''
signature: ''
testMode: true # Make sure to override this to false-
Rebuild the database and flush the cache.
-
Define Payment Rules of a specific User Form at the CMS
When the form’s Payment gateway (or site default) is Omnipay\Stripe\CheckoutGateway, checkout is handled with the Stripe PHP SDK directly (\Stripe\Checkout\Session::create()), not via Omnipay’s ServiceFactory. Implementation: A2nt\UserFormsPayments\Service\StripeCheckoutPaymentProcessor.
| Piece | Version / note |
|---|---|
| Composer package | stripe/stripe-php ^13 or ^14 (see this package’s composer.json) |
| Stripe API version | Each stripe/stripe-php release pins a dated Stripe API version via Stripe\Util\ApiVersion::CURRENT (e.g. 2023-10-16 in many v13/v14 releases). Your project’s exact value is in vendor/stripe/stripe-php/lib/Util/ApiVersion.php after composer install. Override per request with the Stripe-Version header if you need to (see Stripe’s docs). |
| Product | Stripe Checkout (hosted Checkout page; mode: payment with line_items built from the submission). |
The Composer constraint is "stripe/stripe-php": "^13 || ^14" (either major line satisfies the requirement).
Configure the secret key the same way as Omnipay Stripe: SilverStripe\Omnipay\GatewayInfo parameters for \Omnipay\Stripe\CheckoutGateway (e.g. apiKey), or fall back to the STRIPE_SK_KEY environment variable (see StripeCheckoutPaymentProcessor::getStripeSecretKey()).
Optional gateway settings (same GatewayInfo block for \Omnipay\Stripe\CheckoutGateway):
| Key | Effect |
|---|---|
allow_promotion_codes |
When true, Session::create sets allow_promotion_codes: true so customers see “Add promotion code” on Checkout. Create coupons/promotion codes in the Stripe Dashboard first. |
