demo transaksi
This commit is contained in:
@@ -65,9 +65,31 @@ class Merchant extends REST_Controller
|
||||
|
||||
$data = file_get_contents("php://input");
|
||||
$decoded_data = json_decode($data);
|
||||
$no_telepon_val =
|
||||
isset($decoded_data->no_telepon) ? trim((string)$decoded_data->no_telepon) : '';
|
||||
$email_val = isset($decoded_data->email)
|
||||
? trim((string)$decoded_data->email)
|
||||
: '';
|
||||
|
||||
if (!$decoded_data || !isset($decoded_data->password) || ($no_telepon_val === '' && $email_val === '')) {
|
||||
$this->response(array('code' => '400', 'message' => 'Invalid request', 'data' => []), 200);
|
||||
return;
|
||||
}
|
||||
$login_by_phone = $no_telepon_val !== '';
|
||||
if (function_exists('fcm_v1_validate_login_device_token_from_app')) {
|
||||
$fcm_err = fcm_v1_validate_login_device_token_from_app($decoded_data);
|
||||
if (is_array($fcm_err)) {
|
||||
$this->response(
|
||||
array('code' => $fcm_err['code'], 'message' => $fcm_err['message'], 'data' => []),
|
||||
200
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Only save FCM token when valid (relogin overwrites invalid/placeholder tokens).
|
||||
$token = isset($decoded_data->token) ? trim((string) $decoded_data->token) : '';
|
||||
$token = (isset($decoded_data->reg_id) && trim((string) $decoded_data->reg_id) !== '') ? trim((string) $decoded_data->reg_id) : $token;
|
||||
$token = function_exists('fcm_v1_device_token_from_request')
|
||||
? fcm_v1_device_token_from_request($decoded_data)
|
||||
: '';
|
||||
$reg_id = array();
|
||||
if ($token !== '' && function_exists('fcm_v1_is_valid_device_token') && fcm_v1_is_valid_device_token($token)) {
|
||||
$reg_id['token_merchant'] = $token;
|
||||
@@ -75,10 +97,18 @@ class Merchant extends REST_Controller
|
||||
|
||||
$condition = array(
|
||||
'password' => sha1($decoded_data->password),
|
||||
'telepon_mitra' => $decoded_data->no_telepon,
|
||||
//'token' => $decoded_data->token
|
||||
);
|
||||
$check_banned = $this->Merchantapi_model->check_banned($decoded_data->no_telepon);
|
||||
|
||||
if ($login_by_phone) {
|
||||
$condition['telepon_mitra'] = $no_telepon_val;
|
||||
} else {
|
||||
$condition['email_mitra'] = $email_val;
|
||||
}
|
||||
|
||||
$check_banned = $login_by_phone
|
||||
? $this->Merchantapi_model->check_banned($no_telepon_val)
|
||||
: $this->Merchantapi_model->check_banned_by_email($email_val);
|
||||
if ($check_banned) {
|
||||
$message = array(
|
||||
'message' => 'banned',
|
||||
@@ -90,7 +120,19 @@ class Merchant extends REST_Controller
|
||||
$message = array();
|
||||
if ($cek_login->num_rows() > 0) {
|
||||
if (!empty($reg_id)) {
|
||||
$this->Merchantapi_model->edit_profile_token($reg_id, $decoded_data->no_telepon);
|
||||
$loginRow = $cek_login->row();
|
||||
$phone_for_token = '';
|
||||
if ($login_by_phone) {
|
||||
$phone_for_token = $no_telepon_val;
|
||||
} else if (!empty($loginRow) && isset($loginRow->telepon_merchant) && $loginRow->telepon_merchant !== '') {
|
||||
$phone_for_token = $loginRow->telepon_merchant;
|
||||
} else if (!empty($loginRow) && isset($loginRow->telepon_mitra) && $loginRow->telepon_mitra !== '') {
|
||||
$phone_for_token = $loginRow->telepon_mitra;
|
||||
}
|
||||
|
||||
if ($phone_for_token !== '') {
|
||||
$this->Merchantapi_model->edit_profile_token($reg_id, $phone_for_token);
|
||||
}
|
||||
}
|
||||
$get_pelanggan = $this->Merchantapi_model->get_data_merchant($condition);
|
||||
$message = array(
|
||||
@@ -102,7 +144,7 @@ class Merchant extends REST_Controller
|
||||
} else {
|
||||
$message = array(
|
||||
'code' => '404',
|
||||
'message' => 'nomor hp atau password salah!',
|
||||
'message' => 'nomor hp/email atau password salah!',
|
||||
'data' => []
|
||||
);
|
||||
$this->response($message, 200);
|
||||
@@ -450,24 +492,24 @@ class Merchant extends REST_Controller
|
||||
$token = $this->wallet->gettoken($iduser);
|
||||
$regid = $this->wallet->getregid($iduser);
|
||||
$tokenmerchant = $this->wallet->gettokenmerchant($iduser);
|
||||
|
||||
if ($token == NULL and $tokenmerchant == NULL and $regid != NULL) {
|
||||
|
||||
$topic = null;
|
||||
if ($token == NULL and $tokenmerchant == NULL and $regid != NULL && !empty(trim((string) $regid['reg_id']))) {
|
||||
$topic = $regid['reg_id'];
|
||||
} else if ($regid == NULL and $tokenmerchant == NULL and $token != NULL) {
|
||||
} else if ($regid == NULL and $tokenmerchant == NULL and $token != NULL && !empty(trim((string) $token['token']))) {
|
||||
$topic = $token['token'];
|
||||
} else if ($regid == NULL and $token == NULL and $tokenmerchant != NULL) {
|
||||
} else if ($regid == NULL and $token == NULL and $tokenmerchant != NULL && !empty(trim((string) $tokenmerchant['token_merchant']))) {
|
||||
$topic = $tokenmerchant['token_merchant'];
|
||||
}
|
||||
|
||||
|
||||
$title = 'Sukses';
|
||||
$message = 'Permintaan berhasil dikirim';
|
||||
$saldo = $this->wallet->getsaldo($iduser);
|
||||
|
||||
|
||||
|
||||
|
||||
$this->wallet->ubahsaldo($iduser, $amount, $saldo);
|
||||
//$this->wallet->ubahstatuswithdrawbyid($id);
|
||||
$this->wallet->send_notif($title, $message, $topic);
|
||||
if ($topic !== null) {
|
||||
$this->wallet->send_notif($title, $message, $topic);
|
||||
}
|
||||
|
||||
/* END EDIT */
|
||||
$message = array(
|
||||
|
||||
Reference in New Issue
Block a user