dabsquared/wells-fargo-ach-bundle
Install the Bundle
Add to composer.json:
"require": {
"klinche/wells-fargo-ach-bundle": "^1.0"
}
Run composer update klinche/wells-fargo-ach-bundle.
Register the bundle in config/bundles.php:
return [
// ...
Klinche\WellsFargoACHBundle\WellsFargoACHBundle::class => ['all' => true],
];
Configure the Bundle Publish the default config:
php artisan vendor:publish --tag=wells-fargo-ach-config
Edit config/wells_fargo_ach.php with your API credentials (username, password, and account details).
First Use Case: Sending an ACH Transaction Inject the service into a controller or command:
use Klinche\WellsFargoACHBundle\Service\WellsFargoACHService;
public function sendAchPayment(WellsFargoACHService $achService)
{
$transaction = [
'type' => 'credit', // or 'debit'
'amount' => 100.00,
'account_number' => '123456789',
'routing_number' => '021000021',
'name' => 'John Doe',
'description' => 'Payment for services',
];
$response = $achService->sendTransaction($transaction);
return $response;
}
Transaction Creation
Use the WellsFargoACHService to construct and send ACH transactions:
$service = $this->container->get('wells_fargo_ach.service');
$response = $service->sendTransaction([
'type' => 'debit',
'amount' => 50.00,
'account_number' => '987654321',
'routing_number' => '122100023',
'name' => 'Jane Smith',
'description' => 'Invoice #12345',
'addenda' => ['reference' => 'REF123'], // Optional addenda data
]);
Batch Processing
For multiple transactions, use the sendBatch method:
$batch = [
[
'type' => 'credit',
'amount' => 25.00,
'account_number' => '111222333',
'routing_number' => '021000021',
'name' => 'Customer A',
],
// ... more transactions
];
$response = $achService->sendBatch($batch);
Handling Responses
Validate responses using the isSuccessful() method:
if ($achService->isSuccessful($response)) {
// Process successful transaction
} else {
$error = $achService->getErrorMessage($response);
// Log or handle error
}
Integration with Laravel Events Dispatch events for transaction lifecycle hooks:
event(new AchTransactionSent($transaction, $response));
WellsFargoACHService via constructor or service container.config/wells_fargo_ach.php for environment-specific settings.\Log::info('ACH Transaction Sent', ['transaction' => $transaction, 'response' => $response]);
Deprecated Package
omnipay/wellsfargo to a maintained version like omnipay/common).No Built-in Retry Logic
use Illuminate\Support\Facades\Queue;
Queue::later(now()->addMinutes(5), function () use ($transaction) {
$this->sendAchPayment($transaction);
});
Hardcoded API Endpoints
$service->setGatewayUrl('https://new-api-endpoint.com');
No Transaction Status Polling
$gateway = $achService->getGateway();
$gateway->setTestMode(true); // Use test credentials first
$gateway->setDebug(true); // Log raw API responses
account_number, routing_number, and amount meet Wells Fargo’s ACH formatting rules.use Illuminate\Cache\RateLimiter;
RateLimiter::for('ach', function () {
return Limit::perMinute(10)->by($this->user()->id());
});
Custom Gateways
Extend the service to support other ACH providers by implementing Omnipay\Common\GatewayInterface:
class CustomACHGateway extends \Omnipay\Common\AbstractGateway {
// Override purchase(), authorize(), etc.
}
Webhook Handling Add a route to handle Wells Fargo’s webhook notifications:
Route::post('/wells-fargo/ach/webhook', [AchWebhookController::class, 'handle']);
Database Storage
Store transaction records in a ach_transactions table:
Schema::create('ach_transactions', function (Blueprint $table) {
$table->id();
$table->string('transaction_id');
$table->string('status');
$table->json('metadata');
$table->timestamps();
});
Testing Use Laravel’s HTTP tests to mock the ACH service:
$this->mock(WellsFargoACHService::class)
->shouldReceive('sendTransaction')
->andReturn(['success' => true]);
How can I help you explore Laravel packages today?