@extends('components.layouts.base')

@section('title', 'Pembayaran Midtrans')

@section('content')
    <h3>Memproses pembayaran... Mohon tunggu</h3>

    <script src="https://app.sandbox.midtrans.com/snap/snap.js"
        data-client-key="{{ config('services.midtrans.client_key') }}"></script>

    <script>
        document.addEventListener("DOMContentLoaded", function() {
            snap.pay('{{ $snapToken }}', {
                onSuccess: function(result) {
                    window.location.href = '/payment/success/' + result.order_id;
                },
                onPending: function(result) {
                    window.location.href = '/payment/pending?order_id=' + result.order_id;
                },
                onError: function(result) {
                    window.location.href = '/payment/error?order_id=' + result.order_id;
                },
            });
        });
    </script>
@endsection
