Skip to content

Commit 5d8326c

Browse files
committed
Initial commit
0 parents  commit 5d8326c

21 files changed

Lines changed: 864 additions & 0 deletions
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**Describe the bug**
11+
A clear and concise description of what the bug is.
12+
13+
**To Reproduce**
14+
Steps to reproduce the behavior:
15+
1. Go to '...'
16+
2. Click on '....'
17+
3. Scroll down to '....'
18+
4. See error
19+
20+
**Expected behavior**
21+
A clear and concise description of what you expected to happen.
22+
23+
**Screenshots**
24+
If applicable, add screenshots to help explain your problem.
25+
26+
**Desktop (please complete the following information):**
27+
- OS: [e.g. iOS]
28+
- Browser [e.g. chrome, safari]
29+
- Version [e.g. 22]
30+
31+
**Smartphone (please complete the following information):**
32+
- Device: [e.g. iPhone6]
33+
- OS: [e.g. iOS8.1]
34+
- Browser [e.g. stock browser, safari]
35+
- Version [e.g. 22]
36+
37+
**Additional context**
38+
Add any other context about the problem here.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**Is your feature request related to a problem? Please describe.**
11+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12+
13+
**Describe the solution you'd like**
14+
A clear and concise description of what you want to happen.

.github/pull_request_template.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
### Description
2+
3+
Explain what are you submitting.
4+
5+
### Fixes
6+
7+
Enter the issue you are fixing (e.g. This fixes #1.).
8+
9+
10+
11+

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/.idea

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 CodeTech
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# Laravel EuPago
2+
3+
A Laravel package for making payments through the EuPago API.
4+
5+
6+
## Installation
7+
8+
9+
Install the PHP dependency
10+
```
11+
composer require codetech/laravel-eupago
12+
```
13+
14+
Publish the migration
15+
```
16+
php artisan vendor:publish --provider=CodeTech\\EuPago\\Providers\\EuPagoServiceProvider --tag=migrations
17+
```
18+
19+
Run the migration
20+
```
21+
php artisan migrate
22+
```
23+
24+
Publish the configuration file (optional)
25+
```
26+
php artisan vendor:publish --provider=CodeTech\\EuPago\\Providers\\EuPagoServiceProvider --tag=config
27+
```
28+
29+
Publish the translations files (optional)
30+
```
31+
php artisan vendor:publish --provider=CodeTech\\EuPago\\Providers\\EuPagoServiceProvider --tag=translations
32+
```
33+
34+
35+
## Configurations
36+
37+
### Environment
38+
39+
There are two environments available for you to use: "test" and "prod". As you may have guessed,
40+
you can use the "test" environment during the development stage of your application. Switch to "prod"
41+
environment when your application is ready for production.
42+
43+
44+
## Usage
45+
46+
Use the trait on the models for which you want to generate MB Way references:
47+
48+
```
49+
50+
use CodeTech\EuPago\Traits\Mbwayable;
51+
52+
class Order extends Model
53+
{
54+
use Mbwayable;
55+
56+
```
57+
58+
59+
Retrieve the MB Way references:
60+
61+
```
62+
$order = Order::find(1);
63+
64+
$mbwayReferences = $order->mbwayReferences;
65+
```
66+
67+
## MBWay
68+
69+
### Callback
70+
71+
The package already handles the callback, updating the payment reference state and triggering an `MBWayReferencePaid` event.
72+
73+
```
74+
GET
75+
76+
/eupago/mbway/callback
77+
```
78+
79+
####Params
80+
81+
| Name | Type |
82+
|---------------|:---------:|
83+
| valor | float |
84+
| canal | string |
85+
| referencia | string |
86+
| transacao | string |
87+
| identificador | integer |
88+
| mp | string |
89+
| chave_api | string |
90+
| data | date time |
91+
| entidade | string |
92+
| comissao | float |
93+
| local | string |

composer.json

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"name": "codetech/laravel-eupago",
3+
"description": "A Laravel package for making payments through the EuPago API.",
4+
"keywords": [
5+
"eupago",
6+
"mb references",
7+
"laravel-eupago",
8+
"laravel",
9+
"codetech"
10+
],
11+
"authors": [
12+
{
13+
"name": "José Osório",
14+
"email": "jfrosorio@gmail.com",
15+
"role": "Developer"
16+
}
17+
],
18+
"license": "MIT",
19+
"require": {
20+
"php": "^8.0",
21+
"laravel/framework": "^8.29"
22+
},
23+
"autoload": {
24+
"psr-4": {
25+
"CodeTech\\EuPago\\": "src/"
26+
}
27+
},
28+
"minimum-stability": "dev",
29+
"prefer-stable": true,
30+
"extra": {
31+
"laravel": {
32+
"providers": [
33+
"CodeTech\\EuPago\\Providers\\EuPagoServiceProvider"
34+
]
35+
}
36+
}
37+
}

config/eupago.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
return [
4+
5+
/*
6+
|--------------------------------------------------------------------------
7+
| Environment
8+
|--------------------------------------------------------------------------
9+
|
10+
| While you're developing your application, you might want to use the
11+
| sandbox environment. When your application is ready for production
12+
| switch to the production environment for making real payments.
13+
|
14+
| Environments:
15+
| - test: https://sandbox.eupago.pt/clientes/rest_api
16+
| - prod: https://clientes.eupago.pt/clientes/rest_api
17+
|
18+
*/
19+
20+
'env' => env('EUPAGO_ENV', 'test'),
21+
22+
23+
/*
24+
|--------------------------------------------------------------------------
25+
| API
26+
|--------------------------------------------------------------------------
27+
*/
28+
29+
'api_key' => env('EUPAGO_API_KEY'),
30+
31+
32+
/*
33+
|--------------------------------------------------------------------------
34+
| Channel
35+
|--------------------------------------------------------------------------
36+
*/
37+
38+
'channel' => env('EUPAGO_CHANNEL', 'demo'),
39+
40+
];
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
class CreateMbwayReferencesTable extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*
12+
* @return void
13+
*/
14+
public function up()
15+
{
16+
Schema::create('mbway_references', function (Blueprint $table) {
17+
$table->id();
18+
$table->unsignedBigInteger('reference')->unique();
19+
$table->float('value', 10, 2)->default(0);
20+
$table->string('alias');
21+
$table->integer('state')->default(0);
22+
$table->morphs('mbwayable');
23+
$table->timestamps();
24+
});
25+
}
26+
27+
/**
28+
* Reverse the migrations.
29+
*
30+
* @return void
31+
*/
32+
public function down()
33+
{
34+
Schema::dropIfExists('mbway_references');
35+
}
36+
}

resources/lang/en/mbway.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
return [
4+
5+
'errors' => [
6+
'0' => 'Success',
7+
'-7' => 'Inactive service',
8+
'-8' => 'Invalid reference',
9+
'-9' => 'Incorrect values',
10+
'-10' => 'Invalid API key',
11+
]
12+
13+
];

0 commit comments

Comments
 (0)