Add mode of payment to payment in rider api #424

This commit is contained in:
Kendrick Chan 2020-06-21 15:52:34 +08:00
parent fe363e1df6
commit 4ec5ddd993
2 changed files with 15 additions and 5 deletions

View file

@ -4,13 +4,15 @@ namespace App\Ramcar;
class CMBModeOfPayment extends NameValue
{
const CASH = 'cash';
const SHOPEE = 'shopee';
const LAZADA = 'lazada';
const CREDIT_CARD = 'credit_card';
const BANK_TRANSFER = 'bank_transfer';
const ONLINE_TRANSFER = 'online_transfer';
const COLLECTION = [
'cash' => 'Cash',
'shopee' => 'Shopee',
'lazada' => 'Lazada',
'credit_card' => 'Credit Card',
'bank_transfer' => 'Bank Transfer',
'online_transfer' => 'Online Transfer',
];
}

View file

@ -1007,7 +1007,10 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
public function payment(Request $req)
{
$required_params = ['jo_id'];
$required_params = [
'jo_id',
'mode_of_payment',
];
$data = $this->checkActiveJO($req, $required_params, $jo);
if (isset($data['error']))
{
@ -1015,6 +1018,11 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
return $data;
}
// add mode of payment
$mode = $req->request->get('mode_of_payment');
$jo->setModeOfPayment($mode);
// set invoice to paid
$jo->getInvoice()->setStatus(InvoiceStatus::PAID);