Merge branch 'master' of https://git.abbauf.com/MAGANG_TB_dan_PNP_2023/Aplikasi_Rekber into oktaa
This commit is contained in:
commit
fc0a34bc1c
@ -192,10 +192,14 @@ class UserTransactionController extends Controller
|
||||
'callbacks' => [
|
||||
'finish' => route('user-pembeli.index'),
|
||||
],
|
||||
'enabled_payments' => ['credit_card', 'gopay', 'qris'],
|
||||
'enabled_payments' => [
|
||||
'credit_card', 'shopeepay', 'gopay', 'other_qris'
|
||||
]
|
||||
];
|
||||
|
||||
$client = new Client();
|
||||
$client = new Client([
|
||||
'verify' => false
|
||||
]);
|
||||
|
||||
$auth = base64_encode(env('MIDTRANS_SERVER_KEY'));
|
||||
|
||||
@ -208,7 +212,7 @@ class UserTransactionController extends Controller
|
||||
],
|
||||
]);
|
||||
|
||||
$result = $response->getBody();
|
||||
$result = json_decode($response->getBody(), true);
|
||||
|
||||
Transaction::where('id', $query->id)->update([
|
||||
'token' => $result['token'],
|
||||
@ -415,16 +419,18 @@ class UserTransactionController extends Controller
|
||||
|
||||
$auth = base64_encode(env('MIDTRANS_SERVER_KEY'));
|
||||
|
||||
$response = Http::withHeaders([
|
||||
$response = Http::withOptions([
|
||||
'verify' => false
|
||||
])->withHeaders([
|
||||
'Content-Type' => 'application/json',
|
||||
'Authorization' => "Basic $auth",
|
||||
])->get('https://api.sandbox.midtrans.com/v2/' . $request->id . '/status');
|
||||
|
||||
$result = json_decode($response->body(), true);
|
||||
|
||||
if ($result['transaction'] == 'settlement') {
|
||||
if ($result['transaction_status'] == 'settlement') {
|
||||
$transaction = 'success';
|
||||
} elseif ($result['transaction'] == 'capture') {
|
||||
} elseif ($result['transaction_status'] == 'capture') {
|
||||
if ($result['fraud_status'] == 'accept') {
|
||||
$transaction = 'success';
|
||||
} elseif ($result['fraud_status'] == 'challenge') {
|
||||
@ -436,11 +442,10 @@ class UserTransactionController extends Controller
|
||||
|
||||
$query1 = Transaction::where('id', $request->id)->update([
|
||||
'metode_pembayaran' => $result['payment_type'],
|
||||
'tanggal_transaksi' => now(),
|
||||
'tanggal_transaksi' => $result['transaction_time'],
|
||||
'status_transaksi' => $transaction,
|
||||
'status_pembayaran' => $result['transaction_status'],
|
||||
'fraud_status' => $result['fraud_status'],
|
||||
'reference_id' => $result['reference_id'],
|
||||
'signature_key' => $result['signature_key'],
|
||||
]);
|
||||
|
||||
@ -516,7 +521,9 @@ class UserTransactionController extends Controller
|
||||
{
|
||||
$auth = base64_encode(env('MIDTRANS_SERVER_KEY'));
|
||||
|
||||
$response = Http::withHeaders([
|
||||
$response = Http::withOptions([
|
||||
'verify' => false
|
||||
])->withHeaders([
|
||||
'Content-Type' => 'application/json',
|
||||
'Authorization' => "Basic $auth",
|
||||
])->post('https://api.sandbox.midtrans.com/v2/' . $request->id . '/cancel');
|
||||
@ -526,10 +533,17 @@ class UserTransactionController extends Controller
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
|
||||
if(in_array($result['status_code'],['412','401'])){
|
||||
Transaction::where('id', $request->id)->update([
|
||||
'status_transaksi' => 'failure',
|
||||
'status_pembayaran' => 'cancel',
|
||||
]);
|
||||
}else{
|
||||
Transaction::where('id', $request->id)->update([
|
||||
'status_transaksi' => 'failure',
|
||||
'status_pembayaran' => $result['transaction_status'],
|
||||
]);
|
||||
}
|
||||
|
||||
TransactionDescription::create([
|
||||
'transaction_id' => $request->id,
|
||||
@ -554,6 +568,7 @@ class UserTransactionController extends Controller
|
||||
return response()->json([
|
||||
'status' => false,
|
||||
'message' => 'Transaksi gagal dibatalkan',
|
||||
'data' => $result
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,6 @@ return new class extends Migration
|
||||
$table->double('total_harga'); // gross amount
|
||||
$table->double('total_bayar');
|
||||
$table->string('signature_key')->nullable();
|
||||
$table->string('reference_id')->nullable();
|
||||
$table->string('token')->nullable();
|
||||
$table->string('metode_pembayaran')->nullable();
|
||||
$table->string('fraud_status')->nullable();
|
||||
|
@ -140,124 +140,8 @@
|
||||
const token = $(this).data('token');
|
||||
const csrfToken = $('meta[name="csrf-token"]').attr('content');
|
||||
|
||||
// snap.pay(token, {
|
||||
// onSuccess: function(result) {
|
||||
// // $.ajaxSetup({
|
||||
// // headers: {
|
||||
// // 'X-CSRF-TOKEN': csrfToken
|
||||
// // }
|
||||
// // });
|
||||
|
||||
// // $.ajax({
|
||||
// // url: "{{ route('user-pembeli.pay', ':id') }}"
|
||||
// // .replace(':id', id),
|
||||
// // type: "POST",
|
||||
// // contentType: false,
|
||||
// // processData: false,
|
||||
// // success: function(response) {
|
||||
// // Swal.fire({
|
||||
// // title: response.status ? 'Berhasil' :
|
||||
// // 'Gagal',
|
||||
// // text: response.message,
|
||||
// // icon: response.status ? 'success' :
|
||||
// // 'error',
|
||||
// // confirmButtonText: 'OK'
|
||||
// // }).then(function() {
|
||||
// // location.reload();
|
||||
// // });
|
||||
// // console.log(response);
|
||||
// // },
|
||||
// // error: function(error) {
|
||||
// // Swal.fire({
|
||||
// // title: 'Gagal',
|
||||
// // text: 'Gagal mengupdate pembayaran ke database',
|
||||
// // icon: 'error'
|
||||
// // });
|
||||
// // console.log(result);
|
||||
// // }
|
||||
// // });
|
||||
// console.log(result);
|
||||
// },
|
||||
// onPending: function(result) {
|
||||
// // $.ajaxSetup({
|
||||
// // headers: {
|
||||
// // 'X-CSRF-TOKEN': csrfToken
|
||||
// // }
|
||||
// // });
|
||||
|
||||
// // $.ajax({
|
||||
// // url: "{{ route('user-pembeli.pay', ':id') }}"
|
||||
// // .replace(':id', id),
|
||||
// // type: "POST",
|
||||
// // contentType: false,
|
||||
// // processData: false,
|
||||
// // success: function(response) {
|
||||
// // Swal.fire({
|
||||
// // title: 'Berhasil',
|
||||
// // text: response.message,
|
||||
// // icon: 'info',
|
||||
// // confirmButtonText: 'OK'
|
||||
// // });
|
||||
// // console.log(response);
|
||||
// // },
|
||||
// // error: function(error) {
|
||||
// // Swal.fire({
|
||||
// // title: 'Gagal',
|
||||
// // text: 'Gagal mengupdate pembayaran ke database',
|
||||
// // icon: 'error'
|
||||
// // });
|
||||
// // console.log(error);
|
||||
// // }
|
||||
// // });
|
||||
// console.log(result);
|
||||
// },
|
||||
// onError: function(result) {
|
||||
// // $.ajaxSetup({
|
||||
// // headers: {
|
||||
// // 'X-CSRF-TOKEN': csrfToken
|
||||
// // }
|
||||
// // });
|
||||
|
||||
// // $.ajax({
|
||||
// // url: "{{ route('user-pembeli.pay', ':id') }}"
|
||||
// // .replace(':id', id),
|
||||
// // type: "POST",
|
||||
// // contentType: false,
|
||||
// // processData: false,
|
||||
// // success: function(response) {
|
||||
// // Swal.fire({
|
||||
// // title: 'Gagal',
|
||||
// // text: response.message,
|
||||
// // icon: 'error',
|
||||
// // });
|
||||
// // console.log(response);
|
||||
// // },
|
||||
// // error: function(error) {
|
||||
// // Swal.fire({
|
||||
// // title: 'Gagal',
|
||||
// // text: 'Gagal mengupdate pembayaran ke database',
|
||||
// // icon: 'error'
|
||||
// // });
|
||||
// // console.log(error);
|
||||
// // }
|
||||
// // });
|
||||
// // Swal.fire({
|
||||
// // title: 'Gagal',
|
||||
// // text: 'Terjadi kesalahan karena ' + result,
|
||||
// // icon: 'error'
|
||||
// // });
|
||||
// console.log(result);
|
||||
// },
|
||||
// onClose: function(error) {
|
||||
// Swal.fire({
|
||||
// title: 'Ditunda',
|
||||
// text: 'Kamu menutup halaman pembayaran. Silahkan lakukan pembayaran nanti',
|
||||
// icon: 'info'
|
||||
// });
|
||||
// console.log(error);
|
||||
// }
|
||||
// });
|
||||
|
||||
snap.pay(token, {
|
||||
onSuccess: function(result) {
|
||||
Swal.fire({
|
||||
html: '<div class="mt-3"><lord-icon src="https://cdn.lordicon.com/etwtznjn.json" trigger="loop" colors="primary:#0ab39c,secondary:#405189" style="width:120px;height:120px"></lord-icon><div class="mt-4 pt-2 fs-15"><h4>Form Anda sedang diproses!</h4><p class="text-muted mx-4 mb-0">Mohon tunggu...</p></div></div>',
|
||||
allowEscapeKey: false,
|
||||
@ -281,9 +165,11 @@
|
||||
},
|
||||
success: function(response) {
|
||||
Swal.fire({
|
||||
title: response.status ? 'Berhasil' : 'Gagal',
|
||||
title: response.status ? 'Berhasil' :
|
||||
'Gagal',
|
||||
text: response.message,
|
||||
icon: response.status ? 'success' : 'error'
|
||||
icon: response.status ? 'success' :
|
||||
'error'
|
||||
}).then(function() {
|
||||
if (response.status) {
|
||||
location.reload();
|
||||
@ -300,6 +186,87 @@
|
||||
console.log(error);
|
||||
}
|
||||
});
|
||||
console.log(result);
|
||||
},
|
||||
onPending: function(result) {
|
||||
// $.ajaxSetup({
|
||||
// headers: {
|
||||
// 'X-CSRF-TOKEN': csrfToken
|
||||
// }
|
||||
// });
|
||||
|
||||
// $.ajax({
|
||||
// url: "{{ route('user-pembeli.pay', ':id') }}"
|
||||
// .replace(':id', id),
|
||||
// type: "POST",
|
||||
// contentType: false,
|
||||
// processData: false,
|
||||
// success: function(response) {
|
||||
// Swal.fire({
|
||||
// title: 'Berhasil',
|
||||
// text: response.message,
|
||||
// icon: 'info',
|
||||
// confirmButtonText: 'OK'
|
||||
// });
|
||||
// console.log(response);
|
||||
// },
|
||||
// error: function(error) {
|
||||
// Swal.fire({
|
||||
// title: 'Gagal',
|
||||
// text: 'Gagal mengupdate pembayaran ke database',
|
||||
// icon: 'error'
|
||||
// });
|
||||
// console.log(error);
|
||||
// }
|
||||
// });
|
||||
console.log(result);
|
||||
},
|
||||
onError: function(result) {
|
||||
// $.ajaxSetup({
|
||||
// headers: {
|
||||
// 'X-CSRF-TOKEN': csrfToken
|
||||
// }
|
||||
// });
|
||||
|
||||
// $.ajax({
|
||||
// url: "{{ route('user-pembeli.pay', ':id') }}"
|
||||
// .replace(':id', id),
|
||||
// type: "POST",
|
||||
// contentType: false,
|
||||
// processData: false,
|
||||
// success: function(response) {
|
||||
// Swal.fire({
|
||||
// title: 'Gagal',
|
||||
// text: response.message,
|
||||
// icon: 'error',
|
||||
// });
|
||||
// console.log(response);
|
||||
// },
|
||||
// error: function(error) {
|
||||
// Swal.fire({
|
||||
// title: 'Gagal',
|
||||
// text: 'Gagal mengupdate pembayaran ke database',
|
||||
// icon: 'error'
|
||||
// });
|
||||
// console.log(error);
|
||||
// }
|
||||
// });
|
||||
// Swal.fire({
|
||||
// title: 'Gagal',
|
||||
// text: 'Terjadi kesalahan karena ' + result,
|
||||
// icon: 'error'
|
||||
// });
|
||||
console.log(result);
|
||||
},
|
||||
onClose: function(error) {
|
||||
Swal.fire({
|
||||
title: 'Ditunda',
|
||||
text: 'Kamu menutup halaman pembayaran. Silahkan lakukan pembayaran nanti',
|
||||
icon: 'info'
|
||||
});
|
||||
console.log(error);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('#table-3').on('click', '#cancel', function() {
|
||||
@ -332,7 +299,7 @@
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
url: "{{ route('user-pembeli.cancel', ':id') }}",
|
||||
url: "{{ route('user-pembeli.cancel') }}",
|
||||
type: "PUT",
|
||||
data: {
|
||||
id: id
|
||||
|
Loading…
Reference in New Issue
Block a user