Untitled

mail@pastecode.io avatar
unknown
plain_text
8 months ago
25 kB
3
Indexable
Never
public function paymentConfirmation()
	{
		DB::beginTransaction();
		$payment 			= new OyiPay;
		$confirmPayment 	= $payment->callback();
		
		$vaTagihanBayar 	= VaTagihan::where('kode',$confirmPayment->partner_trx_id)->first();
		if(!$vaTagihanBayar){
			return "kode tidak ditemukan";
		}

		$vaAkun 			= VaAkun::find($vaTagihanBayar->va_akun_id);
		// get list akun VA aja
		$vaAkunList 		= VaAkun::whereHas('bank',function($q){
								$q->whereIn('kode',['002','008','009','013','014','022','213']);
							})->where('pelanggan_id',$vaAkun->pelanggan_id)->where('va_number','!=',$vaAkun->va_number)->where('va_status',1)->get();

		$this->checkVaTagihanDetail($vaTagihanBayar,$vaAkun);

		if($vaTagihanBayar && $vaTagihanBayar->status > 0){
			$formatTanggal 						= str_replace('/','-',$confirmPayment->settlement_time);
			$vaTagihanBayar->settlement_time 	= Carbon::parse($formatTanggal)->format('Y-m-d H:i:s');
			$vaTagihanBayar->settlement_status 	= $confirmPayment->settlement_status;
			$vaTagihanBayar->save();
		}
		else{
			$formatTBayar 		= str_replace('/','-',$confirmPayment->tx_date);
			$tanggalBayar 		= Carbon::parse($formatTBayar)->timezone('Asia/Jakarta')->format('Y-m-d H:i:s');
			$bankBayar 			= $vaTagihanBayar ? $vaTagihanBayar->bank : NULL;
			$nominalCallback 	= $bankBayar ? $confirmPayment->amount - $bankBayar->biaya_transfer_pelanggan : $confirmPayment->amount;
			if($confirmPayment->success && $vaTagihanBayar && (int)$vaTagihanBayar->nominal == (int)$nominalCallback){
				$formatTSettlement 	= str_replace('/','-',$confirmPayment->settlement_time);
				$tanggalSettlement 	= Carbon::parse($formatTSettlement)->format('Y-m-d H:i:s');
				$pelanggan 			= $vaAkun->pelanggan;
				$oyiPayAPI 			= new OyiPay;
				// UPDATE TAGIHAN BARU KE VA BAYAR
				$kodeCabang 		= $pelanggan->cabang->kode;

			    $nominalVa = $this->getNominalVa($pelanggan);
				// FORMAT PARTNER TRX ID => [kode cabang]-[nopel]-[kode channel]-[bulan tagihan start]-[bln tagihan end]-[tagihan terbayar + 1]
				$kodeTagihanBaru    = $kodeCabang.'-'.$pelanggan->no_pelanggan.'-'.strtoupper($bankBayar->kode).'-'.$nominalVa['periode_tagihan'].'-'.$nominalVa['next_tagihan'];

			    $arrayDataUpdate = array(
			        'va_id'      		=> $vaAkun->va_id,
			        'amount'       		=> (int)$nominalVa['total'] + $bankBayar->biaya_transfer_pelanggan,
			        'is_lifetime'       => true,
			        'expiration_time'   => -1,
			        'partner_trx_id'    => $kodeTagihanBaru,
			    );
				// CALL API UPDATE
				$updateVa 			= $oyiPayAPI->updateVA($arrayDataUpdate);
				$jsonDecodeUpdate 	= json_decode($updateVa);
				
				if($jsonDecodeUpdate->status->code == '246'){ // insert ke queue update va
					$this->insertUpdateVAQueue($vaAkun->id,$arrayDataUpdate);
				}

				if($jsonDecodeUpdate->status->code == '000' || $vaAkun->va_status == 0 || $jsonDecodeUpdate->status->code == '246'){ // kalau status nya 0 -> nonaktif di skip
					$countUpdateBerhasil 	= 0;
					$arrayVaTagihanId 		= array();
					// UPDATE TAGIHAN BARU KE VA TIDAK BAYAR
					foreach($vaAkunList as $akunList){
						$vaTagihanUpdate 	= VaTagihan::where('va_akun_id',$akunList->id)->where('status',0)->first();
						$bankAkun 			= $akunList->bank;
						if($vaTagihanUpdate){
							$arrayUpdateVa = array(
						        'va_id'      		=> $akunList->va_id,
						        'amount'       		=> (int)$nominalVa['total'] + $bankAkun->biaya_transfer_pelanggan,
						        'is_lifetime'       => true,
						        'expiration_time'   => -1,
						        'partner_trx_id'    => $vaTagihanUpdate->kode,
						    );
						    // CALL API UPDATE
							$updateVaAkun 	= $oyiPayAPI->updateVA($arrayUpdateVa);
							$updateDecode 	= json_decode($updateVaAkun);
							if($updateDecode->status->code == '000' || $updateDecode->status->code == '246'){ // UPDATE TAGIHAN VA
								if($vaTagihanUpdate->voucher_id){
									$vaTagihanUpdate->voucher_id 		= NULL;
									$vaTagihanUpdate->catatan_voucher 	= NULL;
								}
								// UPDATE TAGIHAN VA
								$vaTagihanUpdate->nominal     		= $nominalVa['total'];
								$vaTagihanUpdate->harga_tv 			= $nominalVa['tv'];
								$vaTagihanUpdate->harga_internet 	= $nominalVa['internet'];
								$vaTagihanUpdate->updated_at  		= Carbon::now();
								$vaTagihanUpdate->save();
								$countUpdateBerhasil += 1;
								$arrayVaTagihanId[] = $vaTagihanUpdate->id;

								if($updateDecode->status->code == '246'){ // insert ke queue update va
									$this->insertUpdateVAQueue($akunList->id,$arrayUpdateVa);
								}

							}else{
								Log::useFiles(storage_path().'/logs/callback-va-fail.log');
								Log::info($bankAkun->nama);
								Log::info($updateVaAkun);
							}
						}
					}
					if(@count($vaAkunList) == $countUpdateBerhasil){
						// INSERT CALLBACK VA
						VaCallback::insert(array(
				            'id' 					=> Uuid::uuid4()->toString(),
							'va_penyedia_id' 		=> $vaAkun->bank->va_penyedia_id,
							'va_akun_id' 			=> $vaAkun->id,
							'kode_tagihan' 			=> $confirmPayment->partner_trx_id,
							'nominal' 				=> $nominalCallback,
							'tanggal_bayar' 		=> $tanggalBayar,
							'status' 				=> 'SUKSES',
							'keterangan' 			=> 'CALLBACK '.$vaAkun->va_number.' : '.$confirmPayment->partner_trx_id,
							'transfer_referensi' 	=> $confirmPayment->trx_id,
							'created_at' 			=> Carbon::now(),
							'updated_at' 			=> Carbon::now(),
				        ));
				        // DATA PREPARATION
						$tagihanId 			= VaTagihanDetail::where('va_tagihan_id',$vaTagihanBayar->id)->pluck('tagihan_id')->toArray();
						$listTagihan 		= Tagihan::whereIn('id',$tagihanId)->orderBy('tanggal_jatuh_tempo')->get();
						$countTagihan 		= @count($tagihanId);
						$jtTerbayar 		= array();
						$pegawaiId 			= $bankBayar->pegawai_id;
						$nominalTagihan 	= array_sum($listTagihan->pluck('total')->toArray());
						$nominalTagihanVa 	= $vaTagihanBayar->nominal;
						$nominalPotongan 	= $nominalTagihan - $nominalTagihanVa;
						// UPDATE TAGIHAN VA
						$vaTagihanBayar->status 			= 1;
						$vaTagihanBayar->tanggal_bayar 		= $tanggalBayar;
						$vaTagihanBayar->settlement_time 	= $tanggalSettlement;
						$vaTagihanBayar->settlement_status 	= $confirmPayment->settlement_status;
						$vaTagihanBayar->updated_at 		= Carbon::now();
						$vaTagihanBayar->save();

						
						// CREATE PEMBAYARAN
						$pembayaranId = Uuid::uuid4()->toString();
				        Pembayaran::insert(array(
				            'id'                        => $pembayaranId,
				            'kode'                      => "PAYWW".(time()+rand(1,100)),
				            'deskripsi'                 => "Pembayaran tagihan ".$countTagihan." bulan. Pelanggan ".$pelanggan->no_pelanggan.".",
				            'tahun_tagihan'             => Carbon::now()->year,
				            'tipe_pembayaran_id'        => 2,
				            'total_kotor'               => $nominalTagihan,
				            'total_potongan'            => $nominalPotongan,
				            'total_akhir'               => $nominalTagihanVa,
				            'tanggal_bayar'             => $tanggalBayar,
				            'metode_pembayaran_id'      => 2,
				            'status_pembayaran_id'      => 2,
				            'voucher_id'                => $vaTagihanBayar->voucher_id,
				            'keterangan'                => NULL,
				            'created_at'                => Carbon::now(),
				            'updated_at'                => Carbon::now(),
				            'catatan_voucher'           => $vaTagihanBayar->catatan_voucher,
				            'penerima_pembayaran_id'    => $pegawaiId,
				            'pelanggan_id'              => $pelanggan->id,
				            'jumlah_tagihan'            => $countTagihan,
				        ));
						//KIRIM NOTIFIKASI EMAIL
						$this->sendReceipt($pembayaranId);
						//KIRIM NOTIFIKASI FIREBASE
						$this->sendFirebaseNotification($pelanggan,$vaTagihanBayar);
						
				        // UPDATE TAGIHAN
				        foreach($listTagihan as $tagihan){
				            Tagihan::where('id',$tagihan->id)->update(array(
				                'lunas'         => 1,
				                'tanggal_bayar' => $tanggalBayar,
				                'tanggal_cetak' => $tanggalBayar,
				                'kolektor_id'   => $pegawaiId,
				                'pembayaran_id' => $pembayaranId,
				            ));
				            DetailTagihan::insert(array(
				                'id'                    => Uuid::uuid4()->toString(),
				                'tagihan_id'            => $tagihan->id,
				                'tipe_pembayaran_id'    => 2,
				                'deskripsi'             => "Tagihan Bulanan Pelanggan ".$pelanggan->no_pelanggan." Paket ".$pelanggan->paket->nama,
				                'total'                 => $pelanggan->paket->biaya_perbulan,
				                'harga_satuan'          => $pelanggan->paket->biaya_perbulan,
				                'jumlah'                => 1,
				                'created_at'            => Carbon::now(),
				                'updated_at'            => Carbon::now(),
				            ));
				            $jtTerbayar[] = array(
				            	'bulan_tagihan' 		=> $tagihan->bulan_tagihan,
				            	'tahun_tagihan' 		=> $tagihan->tahun_tagihan,
				            	'tanggal_jatuh_tempo'	=> $tagihan->tanggal_jatuh_tempo,
				            );
				        }

						

				        // GENERATE TAGIHAN BARU
						$tagihanBaruId 			= array();
						$checkTagihanBelumLunas = Tagihan::where('pelanggan_id',$pelanggan->id)->whereNotNull('bulan_tagihan')->where('lunas',0)
												->orderBy('tahun_tagihan')->orderBy('bulan_tagihan')->get();
			            if(@count($checkTagihanBelumLunas) == 0){
			                $lunas  = Tagihan::where('pelanggan_id',$pelanggan->id)->whereNotNull('bulan_tagihan')->where('lunas','>',0)
			                        ->orderBy('tahun_tagihan','desc')->orderBy('bulan_tagihan','desc')->first();
			                // GENERATE NEXT TANGGAL JATUH TEMPO
			                $tempTime 	= $lunas->bulan_tagihan < 10 ? $lunas->tahun_tagihan.'-0'.$lunas->bulan_tagihan.'-01' : $lunas->tahun_tagihan.'-'.$lunas->bulan_tagihan.'-01';
			                $nextDate   = date('Y-m-d',strtotime('+1 month',strtotime($tempTime)));
			                $explodeNew = explode('-', $nextDate);
			                $carbonDate = Carbon::now();
			                if($pelanggan->jatuh_tempo){
			                    if($pelanggan->jatuh_tempo == 31){
			                        $hariTempo = date('t',strtotime($nextDate));
			                    }
			                    elseif((int)$explodeNew[1] == 2 && $pelanggan->jatuh_tempo >= 28){
			                        $hariTempo = date('t',strtotime($nextDate));
			                    }
			                    else{
			                        $hariTempo = $pelanggan->jatuh_tempo < 10 ? '0'.$pelanggan->jatuh_tempo : $pelanggan->jatuh_tempo;
			                    }
			                }
			                elseif(empty($pelanggan->jatuh_tempo) && $pelanggan->tanggal_pasang){
			                    $tanggalPasang = (int)date('d',strtotime($pelanggan->tanggal_pasang));
			                    if($tanggalPasang == 31){
			                        $hariTempo = date('t',strtotime($nextDate));
			                    }
			                    elseif((int)$explodeNew[1] == 2 && $tanggalPasang >= 28){
			                        $hariTempo = date('t',strtotime($nextDate));
			                    }
			                    else{
			                        $hariTempo = $tanggalPasang < 10 ? '0'.$tanggalPasang : $tanggalPasang;
			                    }
			                }
			                else{
			                    if($carbonDate->day == 31){
			                        $hariTempo = date('t',strtotime($nextDate));
			                    }
			                    elseif($carbonDate->month == 2 && $carbonDate->day >= 28){
			                        $hariTempo = date('t',strtotime($nextDate));
			                    }
			                    else{
			                        $hariTempo = $date->day < 10 ? '0'.$date->day : $date->day;
			                    }
			                }
			                $jatuhTempo = date('Y-m-',strtotime($nextDate)).$hariTempo;
			                // CEK PROMO
			                if($pelanggan->paket->promo_jenis){ // PAKET PROMO
			                    if(strtotime($pelanggan->paket->promo_berlaku_dari) <= strtotime($pelanggan->tanggal_pasang) &&
			                        strtotime($pelanggan->paket->promo_berlaku_hingga) >= strtotime($pelanggan->tanggal_pasang)){ // TANGGAL PASANG DI ANTARA RENTANG PROMO BERLAKU
			                        if($pelanggan->paket->jenis_pembayaran == 1){ // PRABAYAR
			                            $jatahPromo         = $pelanggan->paket->promo_jatah_bulan - 1;
			                            $firstDate          = date('Y-m-',strtotime($pelanggan->tanggal_pasang)).'01';
			                            $batasAwalPromo     = $firstDate;
			                            $batasAkhirPromo    = date('Y-m-t',strtotime('+'.$jatahPromo.' months',strtotime($firstDate)));
			                        }
			                        else{ // PASCABAYAR
			                            $jatahPromo         = $pelanggan->paket->promo_jatah_bulan;
			                            $firstDate          = date('Y-m-',strtotime($pelanggan->tanggal_pasang)).'01';
			                            $batasAwalPromo     = date('Y-m-d',strtotime('+ 1 months',strtotime($firstDate)));
			                            $batasAkhirPromo    = date('Y-m-t',strtotime('+'.$jatahPromo.' months',strtotime($batasAwalPromo)));
			                        }
			                        if(strtotime($jatuhTempo) <= strtotime($batasAkhirPromo) && strtotime($jatuhTempo) >= strtotime($batasAwalPromo)){ // BULAN SEKARANG MASIH TERMASUK PADA BULAN JATAH PROMO
			                            $total_tagihan  = $pelanggan->paket->biaya_perbulan;
			                            $tempTv         = ($pelanggan->paket->layananTv) ? $pelanggan->paket->layananTv->iuran : 0;
			                            $tempInternet   = ($pelanggan->paket->layananInternet) ? $pelanggan->paket->layananInternet->iuran : 0;
			                            if($pelanggan->paket->promo_jenis == 1){ // POTONGAN NOMINAL FIX
			                                $hargaLayananTv         = $tempTv - $pelanggan->paket->promo_tv;
			                                $hargaLayananInternet   = $tempInternet - $pelanggan->paket->promo_internet;
			                                $totalTagihan           = $hargaLayananTv + $hargaLayananInternet;
			                            }
			                            else{ // POTONGAN PERSEN;
			                                $hargaLayananTv         = $tempTv - (($tempTv * $pelanggan->paket->promo_persen) / 100);
			                                $hargaLayananInternet   = $tempInternet - (($tempInternet * $pelanggan->paket->promo_persen) / 100);
			                                $totalTagihan           = $total_tagihan - (($total_tagihan * $pelanggan->paket->promo_persen) / 100);
			                            }
			                        }
			                        else{ // BULAN SEKARANG SUDAH TIDAK TERMASUK PADA BULAN JATAH PROMO
			                            $totalTagihan           = $pelanggan->paket->biaya_perbulan;
			                            $hargaLayananTv         = ($pelanggan->paket->layananTv) ? $pelanggan->paket->layananTv->iuran : 0;
			                            $hargaLayananInternet   = ($pelanggan->paket->layananInternet) ? $pelanggan->paket->layananInternet->iuran : 0;
			                        }
			                    }
			                    else{ // TANGGAL PASANG TIDAK DI ANTARA RENTANG PROMO BERLAKU
			                        $totalTagihan           = $pelanggan->paket->biaya_perbulan;
			                        $hargaLayananTv         = ($pelanggan->paket->layananTv) ? $pelanggan->paket->layananTv->iuran : 0;
			                        $hargaLayananInternet   = ($pelanggan->paket->layananInternet) ? $pelanggan->paket->layananInternet->iuran : 0;
			                    }
			                }
			                else{ // PAKET BUKAN PROMO
			                    $totalTagihan           = $pelanggan->paket->biaya_perbulan;
			                    $hargaLayananTv         = ($pelanggan->paket->layananTv) ? $pelanggan->paket->layananTv->iuran : 0;
			                    $hargaLayananInternet   = ($pelanggan->paket->layananInternet) ? $pelanggan->paket->layananInternet->iuran : 0;
			                }
			                // GENERATE TAGIHAN BULAN SELANJUTNYA
			                $kodeTagihanBaru                    = $pelanggan->no_pelanggan.(Carbon::now()->timestamp + rand(1,10000));
			                $addTagihan                         = new Tagihan;
			                $addTagihan->id                     = Uuid::uuid4()->toString();
			                $addTagihan->kode                   = $kodeTagihanBaru;
			                $addTagihan->pelanggan_id           = $pelanggan->id;
			                $addTagihan->total                  = $totalTagihan;
			                $addTagihan->harga_layanan_tv       = $hargaLayananTv;
			                $addTagihan->harga_layanan_internet = $hargaLayananInternet;
			                $addTagihan->tahun_tagihan          = $explodeNew[0];
			                $addTagihan->bulan_tagihan          = (int)$explodeNew[1];
			                $addTagihan->tanggal_jatuh_tempo    = $jatuhTempo;
			                $addTagihan->deskripsi              = "Iuran Bulanan Paket ".$pelanggan->paket->nama;
			                $addTagihan->paket_id               = $pelanggan->paket_id;
			                $addTagihan->save();
			                // VALUE UNTUK DATA VA
			                $tagihanBaruId[] = $addTagihan->id;
			            }
			            // INSERT TAGIHAN VA
						$tableTagihan 						= new VaTagihan;
						$tableTagihan->id 					= Uuid::uuid4()->toString();
						$tableTagihan->va_akun_id 			= $vaAkun->id;
						$tableTagihan->va_bank_id 			= $vaAkun->va_bank_id;
						$tableTagihan->kode 				= $arrayDataUpdate['partner_trx_id'];
						$tableTagihan->nominal 				= $nominalVa['total'];
						$tableTagihan->harga_tv 			= $nominalVa['tv'];
						$tableTagihan->harga_internet 		= $nominalVa['internet'];
						$tableTagihan->status 				= 0;
						$tableTagihan->tanggal_bayar 		= NULL;
						$tableTagihan->tanggal_disbursement = NULL;
						$tableTagihan->keterangan 			= NULL;
						$tableTagihan->created_at 			= Carbon::now();
						$tableTagihan->updated_at 			= Carbon::now();
						$tableTagihan->save();
						// INSERT DETAIL TAGIHAN VA
						foreach($tagihanBaruId as $idTagihan){
							$arrayDetail = array(
								'va_tagihan_id' => $tableTagihan->id,
								'tagihan_id'	=> $idTagihan,
								'created_at'	=> Carbon::now(),
								'updated_at'	=> Carbon::now(),
							);
							VaTagihanDetail::insert($arrayDetail);
						}
						// UPDATE DETAIL TAGIHAN VA TIDAK BAYAR
						if(@count($arrayVaTagihanId) > 0){
							foreach($arrayVaTagihanId as $vaTagihanIdValue){
								// DELETE RECORD VA TAGIHAN DETAIL
								VaTagihanDetail::where('va_tagihan_id',$vaTagihanIdValue)->delete();
								// INSERT RECORD VA TAGIHAN DETAIL
								foreach($tagihanBaruId as $idTagihan){
									$arrayDetailTagihan = array(
										'va_tagihan_id' => $vaTagihanIdValue,
										'tagihan_id'	=> $idTagihan,
										'created_at'	=> Carbon::now(),
										'updated_at'	=> Carbon::now(),
									);
									VaTagihanDetail::insert($arrayDetailTagihan);
								}
							}
						}
						// KIRIM EMAIL NOTIFIKASI PEMBAYARAN
						$emailCheck = $pelanggan->email ? $this->checkEmail($pelanggan->email) : FALSE;
						$getKey     = env('BROADCAST_EMAIL_CLIENT_KEY');
						if($pelanggan->email && $emailCheck && $getKey){
							$bulanTagihan = array(
			                    '1'  => 'Januari',
			                    '2'  => 'Februari',
			                    '3'  => 'Maret',
			                    '4'  => 'April',
			                    '5'  => 'Mei',
			                    '6'  => 'Juni',
			                    '7'  => 'Juli',
			                    '8'  => 'Agustus',
			                    '9'  => 'September',
			                    '10' => 'Oktober',
			                    '11' => 'November',
			                    '12' => 'Desember'
			                );
			                $indexAkhir  	= $countTagihan - 1;
							$tanggalAwal 	= $bulanTagihan[$jtTerbayar[0]['bulan_tagihan']].' - '.$jtTerbayar[0]['tahun_tagihan'];
							$tanggalAkhir 	= $bulanTagihan[$jtTerbayar[$indexAkhir]['bulan_tagihan']].' - '.$jtTerbayar[$indexAkhir]['tahun_tagihan'];
							$bulanBayar 	= (int)date('m',strtotime($tanggalBayar));
							$tahunBayar 	= (int)date('Y',strtotime($tanggalBayar));
							// CEK PAKET
							$paketInternet 	= $pelanggan->paket->layanan_internet_id ? $pelanggan->paket->layananInternet->up_to ? $pelanggan->paket->layananInternet->up_to : '-' : '-';
							// FORMAT PARAMETER EMAIL NOTIFIKASI PEMBAYARAN
							$notifParam = array(
					            'client_key'=> $getKey,
					            'invoice' 	=> array(
					            	'title' 	=> $pelanggan->cabang->nama.' - PEMBAYARAN TAGIHAN '.$tanggalAwal.' / '.$tanggalAkhir,
					                'no_invoice'=> $vaTagihanBayar->kode.'/'.$kodeCabang.'/'.$bulanBayar.'/'.$tahunBayar,
					                'customer'  	=> array(
					                    'id'        => $pelanggan->no_pelanggan,
					                    'name'      => $pelanggan->nama,
					                    'email'     => $pelanggan->email,
					                    'address'   => $pelanggan->alamat,
					                    'state'     => $pelanggan->cabang->kota_id ? $pelanggan->cabang->kota->provinsi->nama : '-',
					                    'country'   => 'Indonesia',
					                ),
					                'due_date'			=> date('Y-m-d',strtotime($jtTerbayar[0]['tanggal_jatuh_tempo'])),
					                'po_wo_contract_no' => NULL,
					                'package'           => array(
					                    array(
					                        'name'                  => $pelanggan->paket->nama,
					                        'price'                 => $pelanggan->paket->biaya_perbulan,
					                        'speed'                 => $paketInternet,
					                        'usage_start'           => date('Y-m-d',strtotime($jtTerbayar[0]['tanggal_jatuh_tempo'])),
					                        'usage_end'             => date('Y-m-d',strtotime($jtTerbayar[$indexAkhir]['tanggal_jatuh_tempo'])),
					                        'total_current_charge'  => $nominalTagihanVa,
					                    ),
					                ),
					                'installation_address'  => $pelanggan->alamat,
					                'payment_channel'       => 'VIRTUAL ACCOUNT',
					                'payment_bank_name'     => $vaAkun->bank->nama,
					                'payment_account_name'	=> $vaAkun->pelanggan->nama,
					                'payment_account_number'=> $vaAkun->va_number,
					            ),
					        );
							$kirimEmail = $this->sendMail($notifParam);
						}
					}
					else{
						// INSERT CALLBACK VA
						VaCallback::insert(array(
				            'id' 					=> Uuid::uuid4()->toString(),
							'va_penyedia_id' 		=> $vaAkun->bank->va_penyedia_id,
							'va_akun_id' 			=> $vaAkun->id,
							'kode_tagihan' 			=> $confirmPayment->partner_trx_id,
							'nominal' 				=> $nominalCallback,
							'tanggal_bayar' 		=> $tanggalBayar,
							'status' 				=> 'GAGAL',
							'keterangan' 			=> 'GAGAL UPDATE AKUN VA SELAIN AKUN BAYAR',
							'transfer_referensi' 	=> $confirmPayment->trx_id,
							'created_at' 			=> Carbon::now(),
							'updated_at' 			=> Carbon::now(),
				        ));
					}
				}
				else{
					// INSERT CALLBACK VA
					VaCallback::insert(array(
			            'id' 					=> Uuid::uuid4()->toString(),
						'va_penyedia_id' 		=> $vaAkun->bank->va_penyedia_id,
						'va_akun_id' 			=> $vaAkun->id,
						'kode_tagihan' 			=> $confirmPayment->partner_trx_id,
						'nominal' 				=> $nominalCallback,
						'tanggal_bayar' 		=> $tanggalBayar,
						'status' 				=> 'GAGAL',
						'keterangan' 			=> $jsonDecodeUpdate->status->message,
						'transfer_referensi' 	=> $confirmPayment->trx_id,
						'created_at' 			=> Carbon::now(),
						'updated_at' 			=> Carbon::now(),
			        ));
				}
			}
			else{
				$keteranganCC 	= 'CALLBACK '.$vaAkun->va_number.' : '.$confirmPayment->partner_trx_id;
				$keterangan 	= !$vaTagihanBayar ? 'KODE TAGIHAN TIDAK DITEMUKAN; '.$keteranganCC : $keteranganCC;
				// INSERT CALLBACK VA
				VaCallback::insert(array(
		            'id' 					=> Uuid::uuid4()->toString(),
					'va_penyedia_id' 		=> $vaAkun->bank->va_penyedia_id,
					'va_akun_id' 			=> $vaAkun->id,
					'kode_tagihan' 			=> $confirmPayment->partner_trx_id,
					'nominal' 				=> $nominalCallback,
					'tanggal_bayar' 		=> $tanggalBayar,
					'status' 				=> 'GAGAL',
					'keterangan' 			=> $keterangan,
					'transfer_referensi' 	=> $confirmPayment->trx_id,
					'created_at' 			=> Carbon::now(),
					'updated_at' 			=> Carbon::now(),
		        ));
			}
		}
		DB::commit();
		return 'OK';
	}