finish refund
This commit is contained in:
		@ -570,6 +570,17 @@ func (app *application) RefundCharge(w http.ResponseWriter, r *http.Request) {
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// update status in DB
 | 
			
		||||
	err = app.DB.UpdateOrderStatus(chargeToRefund.ID, 2)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		app.badRequest(
 | 
			
		||||
			w,
 | 
			
		||||
			r,
 | 
			
		||||
			errors.New("the charge was refunded, but the database could not be updated"),
 | 
			
		||||
		)
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	var resp jsonResponse
 | 
			
		||||
	resp.OK = true
 | 
			
		||||
	resp.Message = "Charge refunded"
 | 
			
		||||
 | 
			
		||||
@ -12,6 +12,7 @@ All Sales
 | 
			
		||||
            <th>Customer</th>
 | 
			
		||||
            <th>Product</th>
 | 
			
		||||
            <th>Amount</th>
 | 
			
		||||
            <th>Status</th>
 | 
			
		||||
        </tr>
 | 
			
		||||
    </thead>
 | 
			
		||||
    <tbody>
 | 
			
		||||
 | 
			
		||||
@ -1,28 +1,33 @@
 | 
			
		||||
{{template "base" .}}
 | 
			
		||||
 | 
			
		||||
{{define "title"}}
 | 
			
		||||
{{index .StringMap "title"}}
 | 
			
		||||
{{end}}
 | 
			
		||||
{{define "content"}}
 | 
			
		||||
{{ template "base" . }}
 | 
			
		||||
{{ define "title" }}
 | 
			
		||||
{{ index .StringMap "title" }}
 | 
			
		||||
{{ end }}
 | 
			
		||||
{{ define "content" }}
 | 
			
		||||
<h2 class="mt-5">Sale</h2>
 | 
			
		||||
<span id="refunded" class="badge bg-danger d-none">Refunded</span>
 | 
			
		||||
<span id="charged" class="badge bg-success d-none">Charged</span>
 | 
			
		||||
<hr>
 | 
			
		||||
<div class="alert alert-danger text-center d-none" id="messages"></div>
 | 
			
		||||
<div>
 | 
			
		||||
    <strong>Order No:</strong> <span id="order-no"></span><br>
 | 
			
		||||
    <strong>Customer:</strong> <span id="customer"></span><br>
 | 
			
		||||
    <strong>Product:</strong> <span id="product"></span><br>
 | 
			
		||||
    <strong>Quantity:</strong> <span id="quantity"></span><br>
 | 
			
		||||
    <strong>Total Sale:</strong> <span id="amount"></span><br>
 | 
			
		||||
    <strong>Order No:</strong> <span id="order-no"></span>
 | 
			
		||||
    <br>
 | 
			
		||||
    <strong>Customer:</strong> <span id="customer"></span>
 | 
			
		||||
    <br>
 | 
			
		||||
    <strong>Product:</strong> <span id="product"></span>
 | 
			
		||||
    <br>
 | 
			
		||||
    <strong>Quantity:</strong> <span id="quantity"></span>
 | 
			
		||||
    <br>
 | 
			
		||||
    <strong>Total Sale:</strong> <span id="amount"></span>
 | 
			
		||||
    <br>
 | 
			
		||||
</div>
 | 
			
		||||
<hr>
 | 
			
		||||
<a href='{{index .StringMap "cancel"}}' class="btn btn-info">Cancel</a>
 | 
			
		||||
<a id="refund-btn" href="#!" class="btn btn-warning">Refund Order</a>
 | 
			
		||||
<a href='{{ index .StringMap "cancel" }}' class="btn btn-info">Cancel</a>
 | 
			
		||||
<a id="refund-btn" href="#!" class="btn btn-warning d-none">Refund Order</a>
 | 
			
		||||
<input type="hidden" id="pi" value="">
 | 
			
		||||
<input type="hidden" id="charge-amount" value="">
 | 
			
		||||
<input type="hidden" id="currency" value="">
 | 
			
		||||
 | 
			
		||||
{{end}}
 | 
			
		||||
 | 
			
		||||
{{define "js"}}
 | 
			
		||||
{{ end }}
 | 
			
		||||
{{ define "js" }}
 | 
			
		||||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
 | 
			
		||||
<script type="module">
 | 
			
		||||
    import {showInfo, refund} from "/static/js/sale.js"
 | 
			
		||||
@ -31,4 +36,4 @@
 | 
			
		||||
        refund({{.API}});
 | 
			
		||||
    });
 | 
			
		||||
</script>
 | 
			
		||||
{{end}}
 | 
			
		||||
{{ end }}
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user