Skip to content

v1.2.0

Choose a tag to compare

@theihasan theihasan released this 09 May 06:23
· 14 commits to main since this release

Summary

Version 1.2.0 adds first‑class support for custom database table prefixes—allowing you to namespace all bkash tables via a new config option and accompanying migrations—and introduces a Laravel event (PaymentSuccessful) that fires after each successful payment, complete with configuration toggles and example listener scaffolding in the README. ([GitHub]1, [GitHub]2)
All stubs, models, and the service provider have been updated so that published migrations, runtime models, and configuration publishing now fully respect the new bkash.database.table_prefix setting. ([GitHub]1, [GitHub]1)
You can also migrate existing data from old tables to newly prefixed tables via a brand‑new update_bkash_tables_with_prefix migration stub. ([GitHub]1)

🚀 New Features

1. Custom Table Prefix Support

  • Configurable prefix via bkash.database.table_prefix (defaults to bkash_). ([GitHub]1)
  • .env variable BKASH_TABLE_PREFIX to override at deploy time. ([GitHub]1)
  • Updated migration stubs (create_bkash_payments_table.php.stub, create_bkash_refunds_table.php.stub) to read the prefix from config and create/drop tables accordingly. ([GitHub]1)
  • New migration stub update_bkash_tables_with_prefix.php.stub automatically copies data from unprefixed tables into the newly prefixed tables when you run php artisan migrate. ([GitHub]1)
  • Models BkashPayment and BkashRefund now call $this->setTable($prefix . 'payments') / $this->setTable($prefix . 'refunds') in their constructors to respect the configured prefix at runtime. ([GitHub]1)

2. Event System for Successful Payments

  • PaymentSuccessful event dispatched in src/Bkash.php immediately after a payment executes successfully (inside executePayment). ([GitHub]2)
  • New config section events.payment_success (default true) to enable/disable firing this event. ([GitHub]2)
  • README updated with detailed instructions on how to listen for Ihasan\Bkash\Events\PaymentSuccessful in your EventServiceProvider, plus an example listener class implementing ShouldQueue. ([GitHub]2)

⚙️ Configuration Changes

config/bkash.php

'database' => [
    'table_prefix' => env('BKASH_TABLE_PREFIX', 'bkash_'),
],
'events' => [
    'payment_success' => env('BKASH_FIRE_PAYMENT_SUCCESS_EVENT', true),
],
  • Inserted under existing default_intent/default_currency settings. ([GitHub]1)
  • Environment variables documented in README. ([GitHub]1)

Publishing via Service Provider

BkashServiceProvider.php now publishes:

  • The config/bkash.php file under the config tag
  • All three migration stubs (create_bkash_payments, create_bkash_refunds, update_bkash_tables_with_prefix) under the migrations tag ([GitHub]1)

🗄️ Database Migrations

  1. create_bkash_payments_table.php.stub

    • Prepends $prefix = config('bkash.database.table_prefix', 'bkash_');
    • Replaces hard‑coded Schema::create('bkash_payments', …) with Schema::create($prefix . 'payments', …). ([GitHub]1)
  2. create_bkash_refunds_table.php.stub

    • Same prefix logic applied to refunds table.
    • Foreign key now references $prefix . 'payments' instead of 'bkash_payments'. ([GitHub]1)
  3. update_bkash_tables_with_prefix.php.stub

    • Checks if prefix ≠ default and old tables exist, then:

      • Creates new prefixed tables
      • Copies data via DB::statement("INSERT INTO {$prefix}payments SELECT * FROM bkash_payments") (and likewise for refunds)
      • Leaves original tables intact for manual cleanup. ([GitHub]1)

📦 Model Updates

  • BkashPayment (src/Models/BkashPayment.php): constructor sets table name dynamically. ([GitHub]1)
  • BkashRefund (src/Models/BkashRefund.php): same prefix‑aware constructor. ([GitHub]1)

🔄 Backward‑Compatibility & Breaking Changes

  • If you change the table_prefix after data exists, new prefixed tables are created; update any raw SQL queries in your app to reference the new names. ([GitHub]1)
  • Existing published migrations (v1.1.0) will not include the update_bkash_tables_with_prefix stub—you must re‑publish migrations to get the new stub. ([GitHub]1)

Commits:

  • 0423c35 — Add database configuration and support for custom table prefixes ([GitHub]1)
  • 907f23f — Add event configuration and trigger for successful payments ([GitHub]2)