Skip to content

Commit

Permalink
add slack notification everytime admin stop recurring member
Browse files Browse the repository at this point in the history
  • Loading branch information
Cendekia Pramana Putra committed Jun 12, 2019
1 parent 7da53c1 commit 7dcbc07
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions config/faspay.php
Expand Up @@ -13,4 +13,10 @@
'debit' => [
//
],
'notification_class' => [
'stop_recurring' => env('FASPAY_STOP_RECURRING_NOTIF_CLASS'),
],
'notification_channel' => [
'slack' => env('SLACK_OPERATION_CHANNEL'),
]
];
12 changes: 12 additions & 0 deletions src/Http/Controllers/RecurringMemberController.php
Expand Up @@ -4,6 +4,7 @@

use Illuminate\Http\Request;
use Cendekia\FaspayTools\Traits\Faspay;
use Illuminate\Support\Facades\Notification;

class RecurringMemberController extends Controller
{
Expand All @@ -29,6 +30,17 @@ public function update(Request $request, $memberId)
->generateXml('update_recurring_member')
->execute();

if ($memberUpdate['response_code'] == 00 && $memberUpdate['response_desc'] == 'Sukses') {
$this->sendUpdateRecurringStatus($request->member);
}

return response()->json($memberUpdate);
}

private function sendUpdateRecurringStatus($data) {
if ($data['recurring_status'] == 0) {
$class = config('faspay.notification_class.stop_recurring');
Notification::route('slack', config('faspay.notification_channel.slack'))->notify(new $class($data));
}
}
}

0 comments on commit 7dcbc07

Please sign in to comment.