Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Solvency Bundle Laravel Package

astina/solvency-bundle

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation:

    composer require astina/solvency-bundle:dev-master
    

    Add to AppKernel.php:

    new Astina\Bundle\SolvencyBundle\AstinaSolvencyBundle(),
    
  2. Configure: Add to config.yml:

    astina_solvency:
        provider:
            deltavista:
                wsdl_url: "http://example.org/path/to.wsdl"
                user: "your_username"
                password: "your_password"
    
  3. First Use Case: Inject the SolvencyService in a controller or service:

    use Astina\Bundle\SolvencyBundle\Service\SolvencyService;
    
    class MyController extends Controller
    {
        public function checkSolvencyAction(Request $request, SolvencyService $solvencyService)
        {
            $result = $solvencyService->checkSolvency([
                'param1' => 'value1',
                'param2' => 'value2',
            ]);
            return $this->json($result);
        }
    }
    

Implementation Patterns

Core Workflow

  1. Service Integration: Use dependency injection to access SolvencyService in controllers, commands, or other services. Example in a command:

    use Astina\Bundle\SolvencyBundle\Service\SolvencyService;
    use Symfony\Component\Console\Command\Command;
    use Symfony\Component\Console\Input\InputInterface;
    use Symfony\Component\Console\Output\OutputInterface;
    
    class SolvencyCheckCommand extends Command
    {
        protected static $defaultName = 'app:solvency:check';
    
        private $solvencyService;
    
        public function __construct(SolvencyService $solvencyService)
        {
            $this->solvencyService = $solvencyService;
            parent::__construct();
        }
    
        protected function execute(InputInterface $input, OutputInterface $output)
        {
            $result = $this->solvencyService->checkSolvency(['customer_id' => 123]);
            $output->writeln('Solvency check result: ' . print_r($result, true));
        }
    }
    
  2. Request Handling: Pass an associative array of parameters to checkSolvency(). The bundle maps these to the DeltaVista API. Example:

    $result = $solvencyService->checkSolvency([
        'customer_id' => 'CUST123',
        'amount' => 1000.00,
        'currency' => 'EUR',
    ]);
    
  3. Response Handling: The bundle returns a structured response (e.g., ['status' => 'approved', 'risk_score' => 0.8]). Validate this in your logic:

    if ($result['status'] === 'approved') {
        // Proceed with transaction
    }
    

Advanced Patterns

  1. Custom Providers: Extend the bundle to support additional providers by implementing Astina\Bundle\SolvencyBundle\Provider\ProviderInterface and register them in the bundle configuration.

  2. Event Listeners: Listen for solvency check events (e.g., solvency.check.before, solvency.check.after) to log, transform, or validate requests/responses:

    # config/services.yml
    services:
        app.solvency_listener:
            class: AppBundle\EventListener\SolvencyListener
            tags:
                - { name: kernel.event_listener, event: solvency.check.before, method: onSolvencyCheckBefore }
    
  3. Caching Strategy: Leverage the built-in caching to reduce API calls. Customize cache lifetime and directory in config.yml:

    astina_solvency:
        cache:
            cache_dir: "%kernel.cache_dir%/solvency"
            lifetime: 3600 # Cache for 1 hour
    
  4. Testing: Mock the SolvencyService in unit tests or use the endpoint_url config to point to a test endpoint:

    astina_solvency:
        provider:
            deltavista:
                endpoint_url: "http://test-endpoint.org"
    

Gotchas and Tips

Common Pitfalls

  1. WSDL/Endpoint Mismatch: Ensure wsdl_url and endpoint_url are correct. A misconfigured endpoint will cause silent failures or SOAP faults. Test with a tool like SoapUI first.

  2. Authentication Issues: DeltaVista may reject requests with invalid credentials. Verify user and password in config.yml and check for typos.

  3. Caching Overrides: If lifetime is set to null, responses are cached indefinitely. This may lead to stale data. Set a reasonable lifetime (e.g., 3600 for 1 hour) for dynamic data.

  4. Parameter Validation: The bundle does not validate input parameters by default. Ensure your application validates inputs before passing them to checkSolvency() to avoid malformed API calls.

  5. SOAP Exceptions: SOAP faults may not be caught gracefully. Wrap calls in a try-catch block:

    try {
        $result = $solvencyService->checkSolvency($params);
    } catch (\SoapFault $e) {
        // Log error and handle gracefully
        $this->logger->error('Solvency check failed: ' . $e->getMessage());
        return $this->json(['error' => 'Solvency check failed'], 500);
    }
    

Debugging Tips

  1. Enable SOAP Debugging: Add this to config.yml to log SOAP requests/responses:

    astina_solvency:
        debug: true
    

    Logs will appear in var/log/dev.log.

  2. Check Cache Directory: Ensure the cache_dir is writable by the web server. Permissions like 755 are typically sufficient.

  3. Validate WSDL: Use php -r 'new SoapClient("http://example.org/path/to.wsdl");' to test WSDL connectivity. If this fails, the WSDL URL is incorrect.

  4. Monitor API Usage: DeltaVista may throttle or block excessive requests. Use caching and monitor API call volumes to avoid hitting limits.

Extension Points

  1. Custom Response Transformers: Override the default response handling by extending Astina\Bundle\SolvencyBundle\Transformer\ResponseTransformer and binding your class in services.yml:

    services:
        app.solvency.response_transformer:
            class: AppBundle\Transformer\CustomSolvencyResponseTransformer
            tags:
                - { name: astina_solvency.response_transformer }
    
  2. Add New Providers: Implement ProviderInterface and register it in the bundle’s Resources/config/services.xml:

    <service id="app.solvency.provider.custom" class="AppBundle\Provider\CustomProvider">
        <tag name="astina_solvency.provider" provider="custom" />
    </service>
    
  3. Override Default Configuration: Use parameter bags to override bundle defaults in config.yml:

    parameters:
        astina_solvency.cache_dir: "%kernel.cache_dir%/custom_solvency_cache"
    
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours