- How do I install Omnipay Dummy for Laravel payment testing?
- Run `composer require league/omnipay omnipay/dummy` to install the package. Then configure Omnipay in your Laravel app using the Dummy gateway, e.g., `$gateway = Omnipay::create('Dummy');`. Ensure your Omnipay version matches the dummy driver’s compatibility.
- Can I use Omnipay Dummy in Laravel for CI/CD pipeline testing?
- Yes, it’s ideal for CI/CD since it requires no external dependencies. Replace real gateway calls with `Omnipay::create('Dummy')` in your tests. For dynamic responses (e.g., randomized transaction IDs), manually configure the dummy driver or extend it via PHPUnit mocks.
- Does Omnipay Dummy support Laravel’s Omnipay facade or laravel-omnipay wrapper?
- Yes, it works seamlessly with Laravel’s Omnipay facade or the `laravel-omnipay` wrapper. Just replace the gateway name (e.g., `'Stripe'` → `'Dummy'`) in your configuration. The dummy driver implements the same interface as real gateways.
- How do I simulate failed payments in Omnipay Dummy for Laravel tests?
- Use card numbers ending in odd digits (e.g., `4444333322221111`) to trigger failures. For more control, extend the dummy driver or use PHPUnit’s mock objects to override responses. Example: `$gateway->setTestMode(true)` (if supported by your driver).
- Is Omnipay Dummy compatible with Laravel 10 and PHP 8.2?
- The dummy driver was last updated in 2018 but remains compatible with modern PHP (8.0+) and Laravel due to Omnipay’s backward compatibility. Test thoroughly if using newer PHP features like typed properties, as minor adjustments may be needed.
- Can I mock gateway-specific behaviors like 3D Secure or refunds with Omnipay Dummy?
- No, the dummy driver only supports basic Omnipay flows (e.g., purchases). For advanced scenarios like 3D Secure or refunds, use PHPUnit’s mock objects or supplement with real gateway test modes (e.g., Stripe’s test API).
- What’s the difference between Omnipay Dummy and Stripe/PayPal test modes?
- Omnipay Dummy is a generic mock with hardcoded success/failure logic (based on card numbers), while Stripe/PayPal test modes replicate real gateway behaviors. Use Dummy for unit/integration tests and real test modes for end-to-end validation.
- How do I handle dynamic responses (e.g., unique transaction IDs) in Laravel tests with Omnipay Dummy?
- Extend the dummy driver to generate dynamic IDs or use PHPUnit’s mock objects to override responses. Example: `$this->getMockBuilder(DummyGateway::class)->setMethods(['doPurchase'])->getMock()`. Avoid relying on hardcoded IDs in production-like tests.
- Is Omnipay Dummy safe for production use in Laravel?
- No, it’s explicitly for testing. The MIT license prohibits production use. For live payments, replace the dummy driver with a real gateway (e.g., Stripe, PayPal) and use their test modes for staging.
- How do I update Omnipay Dummy if Omnipay releases a new major version?
- The package may lag behind Omnipay updates. Fork the repo or check for community alternatives (e.g., `omnipay/mock`). Test compatibility by installing the latest Omnipay and dummy driver side-by-side in a sandbox environment.