Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ composer require codetech/laravel-eupago
Publish the migrations:

```bash
php artisan vendor:publish --provider="CodeTech\EuPago\Providers\EuPagoServiceProvider" --tag=migrations
php artisan vendor:publish --provider="CodeTech\EuPago\Providers\EuPagoServiceProvider" --tag=eupago-migrations
```

Run the migrations:
Expand Down
48 changes: 48 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,53 @@
# Upgrading

## From v3.9.x to v3.10.0

The publish tags are now prefixed with the package name: `eupago-migrations`, `eupago-config` and `eupago-translations`. The old `migrations`, `config` and `translations` tags keep working.

On MySQL and MariaDB, the migrations for the `paysafecard_references` and `credit_card_references` tables used to fail with "Identifier name ... is too long", leaving the table created but the migration unrecorded. If that happened to you, drop the table the error names:

```bash
php artisan tinker --execute="Schema::dropIfExists('paysafecard_references')"
```

Delete the published copy of that migration, since publishing never overwrites an existing file:

```bash
rm database/migrations/2026_06_29_000000_create_paysafecard_references_table.php
```

Re-publish the migrations to get the fixed version:

```bash
php artisan vendor:publish --provider=CodeTech\\EuPago\\Providers\\EuPagoServiceProvider --tag=eupago-migrations
```

Run the migrations:

```bash
php artisan migrate
```

If the error named `credit_card_references` instead, repeat the same steps with that table and `2026_09_05_000000_create_credit_card_references_table.php`.

Translations used to be published to `resources/lang/vendor/eupago`. Creating `resources/lang` makes Laravel use it as the app's lang path, so an app that keeps its translations in `lang/` stopped loading them. If you published the translations, create the new location:

```bash
mkdir -p lang/vendor
```

Move the package's translations there:

```bash
mv resources/lang/vendor/eupago lang/vendor/eupago
```

If `resources/lang` is now empty, remove it so Laravel goes back to `lang/`:

```bash
rmdir resources/lang/vendor resources/lang
```

## From v3.8.x to v3.9.0

Multibanco, MB WAY, PayShop and PaysafeCard references now store the Eupago transaction their callback delivers, so a paid reference can be refunded through `$reference->transaction_id`. A new migration adds the column. Re-publish the migrations, which leaves the existing files untouched:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function up()
$table->text('url')->nullable();
$table->decimal('value', 10, 2)->default(0);
$table->integer('state')->default(0);
$table->morphs('paysafecardable');
$table->morphs('paysafecardable', 'paysafecard_references_morph_index');
$table->timestamps();
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,18 @@
* reference with an equality lookup — float rounding could make a
* legitimate callback miss the row, leaving a real payment pending.
*
* Skipped on SQLite: its column types are only affinities, so FLOAT and
* DECIMAL compare alike, and on Laravel 10 changing a SQLite column
* requires doctrine/dbal, which would abort every later migration.
*
* @return void
*/
public function up()
{
if (Schema::getConnection()->getDriverName() === 'sqlite') {
return;
}

Schema::table('mbway_references', function (Blueprint $table) {
$table->decimal('value', 10, 2)->default(0)->change();
});
Expand All @@ -33,6 +41,10 @@ public function up()
*/
public function down()
{
if (Schema::getConnection()->getDriverName() === 'sqlite') {
return;
}

Schema::table('mbway_references', function (Blueprint $table) {
$table->float('value')->default(0)->change();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function up()
$table->text('url')->nullable();
$table->decimal('value', 10, 2)->default(0);
$table->integer('state')->default(0);
$table->morphs('creditcardable');
$table->morphs('creditcardable', 'credit_card_references_morph_index');
$table->timestamps();
});
}
Expand Down
2 changes: 1 addition & 1 deletion docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ The package supports two levels of usage:
- **Full integration** (default): use the traits and models to persist references, and let the
package handle Eupago's webhooks — it registers the callback routes (`/eupago/*/callback`)
automatically.
- **Thin API client**: use only the payment classes (e.g. `new MB(...)->create()`) and handle
- **Thin API client**: use only the payment classes (e.g. `(new MB(...))->create()`) and handle
persistence and webhooks yourself.

If you only need the thin client, disable the automatic route registration:
Expand Down
29 changes: 16 additions & 13 deletions docs/credit-card.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,20 @@ own `id` (e.g. the order id), which Eupago echoes back in the callback as
`identificador`, the customer's email, and the three URLs the customer is forwarded to
when the payment succeeds, fails, or they press back on the form.

References are stored against your own models, so add the `HasCreditCardReferences` trait to each
model that takes Credit Card payments:

```php
use CodeTech\EuPago\Traits\HasCreditCardReferences;

class Order extends Model
{
use HasCreditCardReferences;
}
```

Then create the payment and save it through the trait's relationship:

```php
use CodeTech\EuPago\CreditCard\CreditCard;

Expand Down Expand Up @@ -85,20 +99,9 @@ $creditCard->getErrors();
// ['APIKEY_MISSING' => 'API Key was not available in the request']
```

## Using the trait

Alternatively, use the `HasCreditCardReferences` trait:

```php
use CodeTech\EuPago\Traits\HasCreditCardReferences;

class Order extends Model
{
use HasCreditCardReferences;
}
```
## Creating and saving in one call

With the trait applied, you can create and persist a reference in a single call. It
The trait can also create and persist a reference in a single call. It
returns the persisted reference (whose `url` you redirect to) on success, or the errors
on failure:

Expand Down
6 changes: 3 additions & 3 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ The service provider is registered automatically via package discovery.
Publish the migrations:

```bash
php artisan vendor:publish --provider="CodeTech\EuPago\Providers\EuPagoServiceProvider" --tag=migrations
php artisan vendor:publish --provider="CodeTech\EuPago\Providers\EuPagoServiceProvider" --tag=eupago-migrations
```

Run the migrations:
Expand All @@ -27,11 +27,11 @@ php artisan migrate
Optionally, publish the configuration file:

```bash
php artisan vendor:publish --provider="CodeTech\EuPago\Providers\EuPagoServiceProvider" --tag=config
php artisan vendor:publish --provider="CodeTech\EuPago\Providers\EuPagoServiceProvider" --tag=eupago-config
```

You can also publish the translations:

```bash
php artisan vendor:publish --provider="CodeTech\EuPago\Providers\EuPagoServiceProvider" --tag=translations
php artisan vendor:publish --provider="CodeTech\EuPago\Providers\EuPagoServiceProvider" --tag=eupago-translations
```
30 changes: 18 additions & 12 deletions docs/mbway.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,21 @@ group: Payment methods
---

Create an MB WAY payment request — the customer confirms it on their phone through the
MB WAY app:
MB WAY app.

References are stored against your own models, so add the `HasMbWayReferences` trait to each
model that takes MB WAY payments:

```php
use CodeTech\EuPago\Traits\HasMbWayReferences;

class Order extends Model
{
use HasMbWayReferences;
}
```

Then create the payment and save it through the trait's relationship:

```php
use CodeTech\EuPago\MBWay\MBWay;
Expand All @@ -32,18 +46,10 @@ try {
}
```

## Using the trait

Alternatively, use the `HasMbWayReferences` trait:

```php
use CodeTech\EuPago\Traits\HasMbWayReferences;
## Creating and saving in one call

class Order extends Model
{
use HasMbWayReferences;
}
```
The trait can also create and persist a reference in a single call. It returns the
persisted reference on success, or the errors on failure:

```php
$reference = $order->createMbwayReference($value, $id, $alias);
Expand Down
34 changes: 19 additions & 15 deletions docs/multibanco.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,19 @@ weight: 5
group: Payment methods
---

Create an MB reference:
References are stored against your own models, so add the `HasMultibancoReferences` trait to each
model that takes MB references:

```php
use CodeTech\EuPago\Traits\HasMultibancoReferences;

class Order extends Model
{
use HasMultibancoReferences;
}
```

Then create the payment and save it through the trait's relationship:

```php
use CodeTech\EuPago\MB\MB;
Expand Down Expand Up @@ -44,24 +56,16 @@ try {
'entity' => "82167",
'reference' => "000001236",
'value' => "3.00000",
'min_value' => "3.00000",
'max_value' => "3.00000",
'start_date' => "2026-06-01",
'end_date' => "2026-06-04",
]
```

## Using the trait

Alternatively, use the `HasMultibancoReferences` trait on the models for which you want
to generate MB references:

```php
use CodeTech\EuPago\Traits\HasMultibancoReferences;

class Order extends Model
{
use HasMultibancoReferences;
}
```
## Creating and saving in one call

With the trait applied, you can create and persist a reference in a single call. It
The trait can also create and persist a reference in a single call. It
returns the persisted reference on success, or the errors on failure:

```php
Expand Down
29 changes: 16 additions & 13 deletions docs/paysafecard.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,20 @@ returns a payment `url` that you must redirect the customer to, along with a
and you may optionally pass a `url_retorno` to control where the customer lands
after paying.

References are stored against your own models, so add the `HasPaysafeCardReferences` trait to each
model that takes PaysafeCard payments:

```php
use CodeTech\EuPago\Traits\HasPaysafeCardReferences;

class Order extends Model
{
use HasPaysafeCardReferences;
}
```

Then create the payment and save it through the trait's relationship:

```php
use CodeTech\EuPago\PaysafeCard\PaysafeCard;

Expand Down Expand Up @@ -52,20 +66,9 @@ try {
]
```

## Using the trait

Alternatively, use the `HasPaysafeCardReferences` trait:

```php
use CodeTech\EuPago\Traits\HasPaysafeCardReferences;

class Order extends Model
{
use HasPaysafeCardReferences;
}
```
## Creating and saving in one call

With the trait applied, you can create and persist a reference in a single call. It
The trait can also create and persist a reference in a single call. It
returns the persisted reference (whose `url` you redirect to) on success, or the errors
on failure:

Expand Down
28 changes: 16 additions & 12 deletions docs/payshop.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,19 @@ weight: 7
group: Payment methods
---

Create a PayShop reference:
References are stored against your own models, so add the `HasPayShopReferences` trait to each
model that takes PayShop references:

```php
use CodeTech\EuPago\Traits\HasPayShopReferences;

class Order extends Model
{
use HasPayShopReferences;
}
```

Then create the payment and save it through the trait's relationship:

```php
use CodeTech\EuPago\PayShop\PayShop;
Expand Down Expand Up @@ -41,18 +53,10 @@ try {
]
```

## Using the trait
## Creating and saving in one call

Alternatively, use the `HasPayShopReferences` trait:

```php
use CodeTech\EuPago\Traits\HasPayShopReferences;

class Order extends Model
{
use HasPayShopReferences;
}
```
The trait can also create and persist a reference in a single call. It returns the
persisted reference on success, or the errors on failure:

```php
$reference = $order->createPayShopReference($value, $id);
Expand Down
12 changes: 8 additions & 4 deletions src/Providers/EuPagoServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,20 @@ private function loadRoutes()
*/
private function setPublishableFiles()
{
// The unprefixed tags are kept for backward compatibility; the docs use the prefixed ones.
$this->publishes([
__DIR__.'/../../database/migrations/' => database_path('migrations'),
], 'migrations');
], ['eupago-migrations', 'migrations']);

// Publishing into resources/lang would create that directory, and Laravel
// then uses it as the app's lang path instead of lang/, hiding the app's
// own translations.
$this->publishes([
__DIR__.'/../../resources/lang' => resource_path('lang/vendor/eupago'),
], 'translations');
__DIR__.'/../../resources/lang' => $this->app->langPath('vendor/eupago'),
], ['eupago-translations', 'translations']);

$this->publishes([
__DIR__.'/../../config/eupago.php' => config_path('eupago.php'),
], 'config');
], ['eupago-config', 'config']);
}
}
Loading
Loading