add pembayaran va

parent 69569b4a
...@@ -69,22 +69,18 @@ public function store(Request $request) { ...@@ -69,22 +69,18 @@ public function store(Request $request) {
$tglRegistrasi = Carbon::now()->format('Y-m-d h:i:s'); $tglRegistrasi = Carbon::now()->format('Y-m-d h:i:s');
// $kegiatan = Kegiatan::find($request->kegiatan); // $kegiatan = Kegiatan::find($request->kegiatan);
// $konferensi = Konferensi::find($request->konferensi); // $konferensi = Konferensi::find($request->konferensi);
$konaspi = Kegiatan::query()->where('id', '498633a9-082c-4a4a-9dbd-e20b678ec15e')->first();
$registrasi = Registrasi::query()->create($registrasi);
$id_registrasi = Registrasi::query()->create($registrasi)->id; $id_registrasi = $registrasi->id;
$kode_registrasi = $registrasi->kode_registrasi;
$multipartData = [ //inisial harga
'noid' => $id_registrasi, // dd($konaspi);
'nama' => $request->nama, $totalHarga = (int) $konaspi->harga;
'tagihan' => $tagihan
];
$generatedVa = $this->generateVa($multipartData);
foreach($request->konferensi as $kon){ foreach($request->konferensi as $kon){
$i = 0; $i = 0;
$daftarKonferensi[] = $kon; $daftarKonferensi[] = $kon;
$konferensi = Konferensi::select('nama')->where('id', $kon)->first(); $konferensi = Konferensi::query()->where('id', $kon)->first();
foreach($request->input('kegiatan'.$i) as $keg){ foreach($request->input('kegiatan'.$i) as $keg){
$daftarKegiatan[] = $keg; $daftarKegiatan[] = $keg;
...@@ -100,15 +96,38 @@ public function store(Request $request) { ...@@ -100,15 +96,38 @@ public function store(Request $request) {
'harga' => $kegiatan[$i]['harga'] 'harga' => $kegiatan[$i]['harga']
]; ];
$totalHarga += (int) $konferensi->harga;
$i++; $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){ foreach($kegiatanpeserta as $keg){
KegiatanPeserta::query()->create($keg); KegiatanPeserta::query()->create($keg);
} }
Log::debug($generatedVa);
DB::commit(); DB::commit();
// return redirect()->back() // return redirect()->back()
...@@ -131,38 +150,18 @@ private function generateVa($multipartData) ...@@ -131,38 +150,18 @@ private function generateVa($multipartData)
{ {
$client = new Client(); $client = new Client();
$options = [ $options = [
'headers' => [ 'form_params' => [
'Cookie' => 'XSRF-TOKEN=eyJpdiI6IkNNRXc1SmprYzMxL3FpQTE2NHI2UHc9PSIsInZhbHVlIjoibzlLcE80TzAyUjJYT3VLTUJSblNIRkpXdytOS0djM0U5azRrMFY1SzRwei92ZzB4VWV0bVMyeGdNSE1LZ2RxOUw4RC9QbGw4V1BWaU5id2dFTWVkbVJaZFNOOWFDRENMQVBzdlhycEE4TDRPZmRzK2xQa21ZWUJMOFg2TGJ2ZVUiLCJtYWMiOiIwMWM2MGM1ZTAyODlhOThjYWYwNDk1OWUwNTUyMWM0MWFmMTA5MDc2OGYzNzliYTViYTAxOTg0MTJjNDY1MmZkIiwidGFnIjoiIn0%3D; siva_session=eyJpdiI6Ii9qeEt5S0xDSS91QThndEp4eTRNS0E9PSIsInZhbHVlIjoiNGxJQ1oxTGtMOXFodTRPUFJRMFY0R1ZXNUNwV0FnSXhDUzJ5VkdNdmZJUWUvdlZCZzVjN3E3WE1MajZhZDlKeng5WWVhcTFOc1NXTmNPVWR1RkZpaEQ0MFdRbVJpTEp6YXo4bzUvNkJtTkpKRWRSRTRNaHEyZndLYlNtYXUxUzQiLCJtYWMiOiJkOGRjMjUwZjlhYTIzYmM4NmUwMzQ1MjhlZTNjMDdjZWI2MWNkYjQ3ZGRjZTI5MDlhZTZjODVkYjhhNDU0YTYzIiwidGFnIjoiIn0%3D' 'credential' => '$2a$08$xSX/XuObiJ3GoJWhjDTyXepT64o1ze.A/.OVYB15uzKW3V7pxgZ6O',
], 'noid' => $multipartData['noid'],
'multipart' => new MultipartStream([ 'nama' => $multipartData['nama'],
[ 'tagihan' => $multipartData['tagihan'],
'name' => 'credential', 'flag' => 'F',
'contents' => '$2a$08$xSX/XuObiJ3GoJWhjDTyXepT64o1ze.A/.OVYB15uzKW3V7pxgZ6O' 'expired_date' => '',
], 'deskripsi' => 'pembayaran konaspi'
[ ]
'name' => 'noid',
'contents' => $multipartData['noid']
],
[
'name' => 'nama',
'contents' => $multipartData['nama']
],
[
'name' => 'tagihan',
'contents' => $multipartData['tagihan']
],
[
'name' => 'flag',
'contents' => 'F'
],
[
'name' => 'expired_date',
'contents' => ''
]
])
]; ];
$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(); return $response->getBody()->getContents();
} }
......
...@@ -28,7 +28,10 @@ class Registrasi extends Model ...@@ -28,7 +28,10 @@ class Registrasi extends Model
'alamat', 'alamat',
'kode_pos', 'kode_pos',
'kota', 'kota',
'kode_registrasi' 'kode_registrasi',
'tagihan',
'status_va',
'tanggal_bayar'
]; ];
public function pkKegiatan(){ 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