Skip to content

Commit a6848c3

Browse files
committed
Merge branch 'master' of github.com:akaunting/module-paypal-standard
2 parents 930907e + e0a1153 commit a6848c3

File tree

5 files changed

+320
-22
lines changed

5 files changed

+320
-22
lines changed

.github/workflows/releases.yml

Lines changed: 286 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,286 @@
1+
name: Releases
2+
3+
on:
4+
release:
5+
types: [released]
6+
7+
jobs:
8+
check-json-version:
9+
10+
runs-on: ubuntu-20.04
11+
12+
steps:
13+
- name: Checkout module
14+
uses: actions/checkout@v2
15+
16+
- id: set_var
17+
run: |
18+
content=`cat ./module.json`
19+
# the following lines are only required for multi line json
20+
content="${content//'%'/'%25'}"
21+
content="${content//$'\n'/'%0A'}"
22+
content="${content//$'\r'/'%0D'}"
23+
# end of optional handling for multi line json
24+
echo "::set-output name=moduleJson::$content"
25+
26+
- name: Set env
27+
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
28+
29+
- name: Check version equality
30+
run: |
31+
if [ "${{fromJson(steps.set_var.outputs.moduleJson).version}}" == $RELEASE_VERSION ]; then
32+
exit 0
33+
else
34+
exit 1
35+
fi
36+
37+
tests:
38+
39+
needs: [check-json-version]
40+
41+
name: PHP ${{ matrix.php }}
42+
43+
runs-on: ubuntu-20.04
44+
45+
strategy:
46+
matrix:
47+
php: ['7.3', '7.4']
48+
49+
steps:
50+
- name: Checkout Akaunting
51+
uses: actions/checkout@v2
52+
with:
53+
repository: akaunting/akaunting
54+
55+
- name: Checkout module to tmp path
56+
uses: actions/checkout@v2
57+
with:
58+
path: tmp-path-for-module
59+
60+
- id: set_var
61+
run: |
62+
content=`cat ./tmp-path-for-module/module.json`
63+
# the following lines are only required for multi line json
64+
content="${content//'%'/'%25'}"
65+
content="${content//$'\n'/'%0A'}"
66+
content="${content//$'\r'/'%0D'}"
67+
# end of optional handling for multi line json
68+
echo "::set-output name=moduleJson::$content"
69+
70+
- name: Create module folder name which is PascalCase
71+
run: |
72+
MODULE_FOLDER_NAME=$(echo -n ${{fromJson(steps.set_var.outputs.moduleJson).alias}} | sed -r 's/(^|-)([a-z])/\U\2/g')
73+
echo "MODULE_FOLDER_NAME=${MODULE_FOLDER_NAME}" >> $GITHUB_ENV
74+
75+
- name: Remove the tmp folder
76+
run: rm -rf tmp-path-for-module
77+
78+
- name: Checkout module
79+
uses: actions/checkout@v2
80+
with:
81+
path: modules/${{ env.MODULE_FOLDER_NAME }}
82+
83+
- name: Cache Composer
84+
uses: actions/cache@v1
85+
with:
86+
path: ~/.composer/cache/files
87+
key: php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}
88+
89+
- name: Setup PHP
90+
uses: shivammathur/setup-php@v2
91+
with:
92+
php-version: ${{ matrix.php }}
93+
extensions: bcmath, ctype, dom, fileinfo, intl, gd, json, mbstring, pdo, pdo_sqlite, openssl, sqlite, xml, zip
94+
coverage: none
95+
96+
- name: Copy .env
97+
run: cp .env.testing .env
98+
99+
- name: Install Composer
100+
run: cd "modules/${{ env.MODULE_FOLDER_NAME }}" ; composer test ; cd ../.. ; composer test
101+
102+
- name: Execute tests
103+
run: php artisan test --parallel
104+
105+
build:
106+
107+
needs: [tests]
108+
109+
runs-on: ubuntu-20.04
110+
111+
steps:
112+
- name: Checkout Akaunting
113+
uses: actions/checkout@v2
114+
with:
115+
repository: akaunting/akaunting
116+
117+
- name: Checkout module to tmp path
118+
uses: actions/checkout@v2
119+
with:
120+
path: tmp-path-for-module
121+
122+
- id: set_var
123+
run: |
124+
content=`cat ./tmp-path-for-module/module.json`
125+
# the following lines are only required for multi line json
126+
content="${content//'%'/'%25'}"
127+
content="${content//$'\n'/'%0A'}"
128+
content="${content//$'\r'/'%0D'}"
129+
# end of optional handling for multi line json
130+
echo "::set-output name=moduleJson::$content"
131+
132+
- name: Remove the tmp folder
133+
run: rm -rf tmp-path-for-module
134+
135+
- name: Create module folder name which is PascalCase
136+
run: |
137+
MODULE_FOLDER_NAME=$(echo -n ${{fromJson(steps.set_var.outputs.moduleJson).alias}} | sed -r 's/(^|-)([a-z])/\U\2/g')
138+
echo "MODULE_FOLDER_NAME=${MODULE_FOLDER_NAME}" >> $GITHUB_ENV
139+
140+
- name: Checkout module
141+
uses: actions/checkout@v2
142+
with:
143+
path: modules/${{ env.MODULE_FOLDER_NAME }}
144+
145+
- name: Cache Composer
146+
uses: actions/cache@v1
147+
with:
148+
path: ~/.composer/cache/files
149+
key: php-7.3-composer-${{ hashFiles('composer.json') }}
150+
151+
- name: Setup PHP
152+
uses: shivammathur/setup-php@v2
153+
with:
154+
php-version: '7.3'
155+
extensions: bcmath, ctype, dom, fileinfo, intl, gd, json, mbstring, pdo, pdo_sqlite, openssl, sqlite, xml, zip
156+
coverage: none
157+
158+
- name: Copy .env
159+
run: cp .env.testing .env
160+
161+
- name: Install Composer
162+
run: cd "modules/${{ env.MODULE_FOLDER_NAME }}" ; composer install --no-dev ; cd ../.. ; composer install --no-dev
163+
164+
- name: Run npm install for Akaunting
165+
run: npm install
166+
167+
- name: Run npm install for the module
168+
run: |
169+
cd "modules/${{ env.MODULE_FOLDER_NAME }}"
170+
npm install
171+
172+
- name: Compile module assets
173+
run: |
174+
cd "modules/${{ env.MODULE_FOLDER_NAME }}"
175+
npm run production
176+
177+
- name: Install zip
178+
run: sudo apt install zip
179+
180+
- name: Delete sass folder
181+
run: |
182+
cd "modules/${{ env.MODULE_FOLDER_NAME }}/Resources/assets"
183+
rm -rf sass
184+
185+
- name: Delete mix-manifest.json file
186+
run: |
187+
cd "modules/${{ env.MODULE_FOLDER_NAME }}"
188+
rm -f mix-manifest.json
189+
190+
- name: Delete non .min.js files
191+
run: |
192+
cd "modules/${{ env.MODULE_FOLDER_NAME }}/Resources/assets/js"
193+
find . -type f ! -name '*.min.js' -delete
194+
195+
- name: ZIP
196+
run: cd "modules/${{ env.MODULE_FOLDER_NAME }}" ; zip -r ../../final-build.zip . * -x '*.git*' -x '*node_modules*' -x 'composer.json' -x 'composer.lock' -x 'crowdin.yml' -x 'package-lock.json' -x 'package.json' -x 'README.md' -x 'webpack.mix.js' ; cd ..
197+
198+
- uses: actions/upload-artifact@master
199+
with:
200+
name: final-build
201+
path: ${{ github.workspace }}/final-build.zip
202+
203+
upload-to-site:
204+
205+
needs: [build]
206+
207+
runs-on: ubuntu-20.04
208+
209+
steps:
210+
- uses: actions/download-artifact@master
211+
with:
212+
name: final-build
213+
214+
- name: Install unzip
215+
run: sudo apt install unzip
216+
217+
- name: UNZIP
218+
run: unzip final-build.zip -d src
219+
220+
- id: set_var
221+
run: |
222+
content=`cat ./src/module.json`
223+
# the following lines are only required for multi line json
224+
content="${content//'%'/'%25'}"
225+
content="${content//$'\n'/'%0A'}"
226+
content="${content//$'\r'/'%0D'}"
227+
# end of optional handling for multi line json
228+
echo "::set-output name=moduleJson::$content"
229+
230+
- name: Rename zip archive
231+
run: mv final-build.zip ${{fromJson(steps.set_var.outputs.moduleJson).alias}}-v${{fromJson(steps.set_var.outputs.moduleJson).version}}.zip
232+
233+
- name: Upload to release
234+
uses: svenstaro/upload-release-action@v2
235+
with:
236+
repo_token: ${{ secrets.GITHUB_TOKEN }}
237+
file: ${{fromJson(steps.set_var.outputs.moduleJson).alias}}-v${{fromJson(steps.set_var.outputs.moduleJson).version}}.zip
238+
tag: ${{ github.ref }}
239+
overwrite: true
240+
241+
- name: Upload to Akaunting Site
242+
run: |
243+
curl \
244+
-H "Authorization: Bearer ${{ secrets.AKAUNTING_SITE_AUTH_BEARER }}" \
245+
-H "Module-Version: ${{fromJson(steps.set_var.outputs.moduleJson).version}}" \
246+
-F "file=@./${{fromJson(steps.set_var.outputs.moduleJson).alias}}-v${{fromJson(steps.set_var.outputs.moduleJson).version}}.zip" \
247+
--retry 5 \
248+
--retry-delay 60 \
249+
${{ secrets.AKAUNTING_SITE_API_DOMAIN }}/${{ secrets.AKAUNTING_SITE_API_MODULES_ENDPOINT }}/${{fromJson(steps.set_var.outputs.moduleJson).alias}}
250+
251+
update-cloud:
252+
253+
needs: [upload-to-site]
254+
255+
runs-on: ubuntu-20.04
256+
257+
steps:
258+
- uses: actions/download-artifact@master
259+
with:
260+
name: final-build
261+
262+
- name: Install unzip
263+
run: sudo apt install unzip
264+
265+
- name: UNZIP
266+
run: unzip final-build.zip -d src
267+
268+
- id: set_var
269+
run: |
270+
content=`cat ./src/module.json`
271+
# the following lines are only required for multi line json
272+
content="${content//'%'/'%25'}"
273+
content="${content//$'\n'/'%0A'}"
274+
content="${content//$'\r'/'%0D'}"
275+
# end of optional handling for multi line json
276+
echo "::set-output name=moduleJson::$content"
277+
278+
- name: Update the Cloud
279+
uses: appleboy/ssh-action@master
280+
with:
281+
host: ${{ secrets.AKAUNTING_CLOUD_HOST }}
282+
username: ${{ secrets.AKAUNTING_CLOUD_USERNAME }}
283+
key: ${{ secrets.AKAUNTING_CLOUD_SSH_PRIVATE }}
284+
script: |
285+
cd /${{ secrets.AKAUNTING_CLOUD_PATH }}
286+
${{ secrets.AKAUNTING_CLOUD_UPDATE_COMMAND }} ${{fromJson(steps.set_var.outputs.moduleJson).alias}} 1 ${{fromJson(steps.set_var.outputs.moduleJson).version}}

Resources/views/show.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939
<input type="hidden" name="no_note" value="1" />
4040
<input type="hidden" name="no_shipping" value="1" />
4141
<input type="hidden" name="charset" value="utf-8" />
42-
<input type="hidden" name="return" value="{{ route('portal.invoices.paypal-standard.return', $invoice->id) }}" />
43-
<input type="hidden" name="notify_url" value="{{ route('portal.invoices.paypal-standard.complete', $invoice->id) }}" />
42+
<input type="hidden" name="return" value="{{ route('portal.paypal-standard.invoices.return', $invoice->id) }}" />
43+
<input type="hidden" name="notify_url" value="{{ route('portal.paypal-standard.invoices.complete', $invoice->id) }}" />
4444
<input type="hidden" name="cancel_return" value="{{ $invoice_url }}" />
4545
<input type="hidden" name="paymentaction" value="{{ $setting['transaction'] }}" />
4646
<input type="hidden" name="custom" value="{{ $invoice->id }}" />

Routes/guest.php

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
<?php
22

3-
Route::group([
4-
'prefix' => 'portal',
5-
'middleware' => 'guest',
6-
'namespace' => 'Modules\PaypalStandard\Http\Controllers'
7-
], function () {
8-
Route::post('invoices/{invoice}/paypal-standard/return', 'Payment@return')->name('portal.invoices.paypal-standard.return');
9-
Route::post('invoices/{invoice}/paypal-standard/complete', 'Payment@complete')->name('portal.invoices.paypal-standard.complete');
10-
});
3+
use Illuminate\Support\Facades\Route;
4+
5+
/**
6+
* 'guest' middleware and 'portal/paypal-standard' prefix applied to all routes (including names)
7+
*
8+
* @see \App\Providers\Route::register
9+
*/
10+
11+
Route::portal('paypal-standard', function () {
12+
Route::get('invoices/{invoice}/complete', 'Payment@return')->name('invoices.return');
13+
Route::post('invoices/{invoice}/complete', 'Payment@complete')->name('invoices.complete');
14+
}, ['middleware' => 'guest']);

Routes/portal.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
<?php
22

3-
Route::group([
4-
'prefix' => 'portal',
5-
'middleware' => 'portal',
6-
'namespace' => 'Modules\PaypalStandard\Http\Controllers'
7-
], function () {
8-
Route::get('invoices/{invoice}/paypal-standard', 'Payment@show')->name('portal.invoices.paypal-standard.show');
3+
use Illuminate\Support\Facades\Route;
4+
5+
/**
6+
* 'portal' middleware and 'portal/paypal-standard' prefix applied to all routes (including names)
7+
*
8+
* @see \App\Providers\Route::register
9+
*/
10+
11+
Route::portal('paypal-standard', function () {
12+
Route::get('invoices/{invoice}', 'Payment@show')->name('invoices.show');
913
});

Routes/signed.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
<?php
22

3-
Route::group([
4-
'prefix' => 'signed',
5-
'middleware' => 'signed',
6-
'namespace' => 'Modules\PaypalStandard\Http\Controllers'
7-
], function () {
8-
Route::get('invoices/{invoice}/paypal-standard', 'Payment@show')->name('signed.invoices.paypal-standard.show');
3+
use Illuminate\Support\Facades\Route;
4+
5+
/**
6+
* 'signed' middleware and 'signed/paypal-standard' prefix applied to all routes (including names)
7+
*
8+
* @see \App\Providers\Route::register
9+
*/
10+
11+
Route::signed('paypal-standard', function () {
12+
Route::get('invoices/{invoice}', 'Payment@show')->name('invoices.show');
913
});

0 commit comments

Comments
 (0)