add pembayaran va

parent 69569b4a
......@@ -69,22 +69,18 @@ public function store(Request $request) {
$tglRegistrasi = Carbon::now()->format('Y-m-d h:i:s');
// $kegiatan = Kegiatan::find($request->kegiatan);
// $konferensi = Konferensi::find($request->konferensi);
$id_registrasi = Registrasi::query()->create($registrasi)->id;
$multipartData = [
'noid' => $id_registrasi,
'nama' => $request->nama,
'tagihan' => $tagihan
];
$generatedVa = $this->generateVa($multipartData);
$konaspi = Kegiatan::query()->where('id', '498633a9-082c-4a4a-9dbd-e20b678ec15e')->first();
$registrasi = Registrasi::query()->create($registrasi);
$id_registrasi = $registrasi->id;
$kode_registrasi = $registrasi->kode_registrasi;
//inisial harga
// dd($konaspi);
$totalHarga = (int) $konaspi->harga;
foreach($request->konferensi as $kon){
$i = 0;
$daftarKonferensi[] = $kon;
$konferensi = Konferensi::select('nama')->where('id', $kon)->first();
$konferensi = Konferensi::query()->where('id', $kon)->first();
foreach($request->input('kegiatan'.$i) as $keg){
$daftarKegiatan[] = $keg;
......@@ -100,15 +96,38 @@ public function store(Request $request) {
'harga' => $kegiatan[$i]['harga']
];
$totalHarga += (int) $konferensi->harga;
$i++;
}
$multipartData = [
'noid' => $kode_registrasi,
'nama' => $request->nama,
'tagihan' => $totalHarga
];
$generatedVa = $this->generateVa($multipartData);
$arrResponse = json_decode($generatedVa, true);
$registrasi->status_va = $arrResponse['BTNresponse'];
$registrasi->save();
if($arrResponse['BTNresponse'] != 'Request has been processed successfully'){
DB::rollBack();
Log::error('---');
Log::error($multipartData);
Log::error($arrResponse['BTNresponse']);
Log::error('---');
return redirect()->back()
->with('error', 'Data failed to save');
}
foreach($kegiatanpeserta as $keg){
KegiatanPeserta::query()->create($keg);
}
Log::debug($generatedVa);
DB::commit();
// return redirect()->back()
......@@ -131,38 +150,18 @@ private function generateVa($multipartData)
{
$client = new Client();
$options = [
'headers' => [
'Cookie' => 'XSRF-TOKEN=eyJpdiI6IkNNRXc1SmprYzMxL3FpQTE2NHI2UHc9PSIsInZhbHVlIjoibzlLcE80TzAyUjJYT3VLTUJSblNIRkpXdytOS0djM0U5azRrMFY1SzRwei92ZzB4VWV0bVMyeGdNSE1LZ2RxOUw4RC9QbGw4V1BWaU5id2dFTWVkbVJaZFNOOWFDRENMQVBzdlhycEE4TDRPZmRzK2xQa21ZWUJMOFg2TGJ2ZVUiLCJtYWMiOiIwMWM2MGM1ZTAyODlhOThjYWYwNDk1OWUwNTUyMWM0MWFmMTA5MDc2OGYzNzliYTViYTAxOTg0MTJjNDY1MmZkIiwidGFnIjoiIn0%3D; siva_session=eyJpdiI6Ii9qeEt5S0xDSS91QThndEp4eTRNS0E9PSIsInZhbHVlIjoiNGxJQ1oxTGtMOXFodTRPUFJRMFY0R1ZXNUNwV0FnSXhDUzJ5VkdNdmZJUWUvdlZCZzVjN3E3WE1MajZhZDlKeng5WWVhcTFOc1NXTmNPVWR1RkZpaEQ0MFdRbVJpTEp6YXo4bzUvNkJtTkpKRWRSRTRNaHEyZndLYlNtYXUxUzQiLCJtYWMiOiJkOGRjMjUwZjlhYTIzYmM4NmUwMzQ1MjhlZTNjMDdjZWI2MWNkYjQ3ZGRjZTI5MDlhZTZjODVkYjhhNDU0YTYzIiwidGFnIjoiIn0%3D'
],
'multipart' => new MultipartStream([
[
'name' => 'credential',
'contents' => '$2a$08$xSX/XuObiJ3GoJWhjDTyXepT64o1ze.A/.OVYB15uzKW3V7pxgZ6O'
],
[
'name' => 'noid',
'contents' => $multipartData['noid']
],
[
'name' => 'nama',
'contents' => $multipartData['nama']
],
[
'name' => 'tagihan',
'contents' => $multipartData['tagihan']
],
[
'name' => 'flag',
'contents' => 'F'
],
[
'name' => 'expired_date',
'contents' => ''
'form_params' => [
'credential' => '$2a$08$xSX/XuObiJ3GoJWhjDTyXepT64o1ze.A/.OVYB15uzKW3V7pxgZ6O',
'noid' => $multipartData['noid'],
'nama' => $multipartData['nama'],
'tagihan' => $multipartData['tagihan'],
'flag' => 'F',
'expired_date' => '',
'deskripsi' => 'pembayaran konaspi'
]
])
];
$response = $client->request('POST', 'http://neo-sidata.inf/btn_v2/create', $options);
$response = $client->request('POST', 'https://neosidata.unesa.ac.id/btn_v2/create', $options);
return $response->getBody()->getContents();
}
......
......@@ -28,7 +28,10 @@ class Registrasi extends Model
'alamat',
'kode_pos',
'kota',
'kode_registrasi'
'kode_registrasi',
'tagihan',
'status_va',
'tanggal_bayar'
];
public function pkKegiatan(){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment