refund front 1
This commit is contained in:
@ -1,9 +1,9 @@
|
||||
import {formatCurrency} from "./common.js"
|
||||
import { formatCurrency } from "./common.js"
|
||||
|
||||
const id = window.location.pathname.split("/").pop();
|
||||
const token = localStorage.getItem("token");
|
||||
|
||||
export function showInfo(api) {
|
||||
let token = localStorage.getItem("token");
|
||||
let id = window.location.pathname.split("/").pop();
|
||||
|
||||
const requestOptions = {
|
||||
method: 'post',
|
||||
headers: {
|
||||
@ -23,6 +23,45 @@ export function showInfo(api) {
|
||||
document.getElementById("product").innerHTML = data.widget.name
|
||||
document.getElementById("quantity").innerHTML = data.quantity
|
||||
document.getElementById("amount").innerHTML = formatCurrency(data.transaction.amount)
|
||||
document.getElementById("pi").value = data.transaction.payment_intent;
|
||||
document.getElementById("charge-amount").value = data.transaction.amount;
|
||||
document.getElementById("currency").value = data.transaction.currency;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export function refund(api) {
|
||||
Swal.fire({
|
||||
title: "Are you sure?",
|
||||
text: "You won't be able to undo this!",
|
||||
icon: "warning",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#3085d6",
|
||||
cancelButtonColor: "#d33",
|
||||
confirmButtonText: "Refund"
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
let payload = {
|
||||
pi: document.getElementById("pi").value,
|
||||
currency: document.getElementById("currency").value,
|
||||
amount: parseInt(document.getElementById("charge-amount").value, 10),
|
||||
id: parseInt(id, 10),
|
||||
};
|
||||
const requestOptions = {
|
||||
method: 'post',
|
||||
headers: {
|
||||
'Accept': `application/json`,
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': 'Bearer ' + token,
|
||||
},
|
||||
body: JSON.stringify(payload),
|
||||
};
|
||||
|
||||
fetch(api + "/api/admin/refund", requestOptions)
|
||||
.then(response => response.json())
|
||||
.then(function (data) {
|
||||
console.log(data);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user