Open SlayerAnsh opened 2 years ago
Targets issues: #64 #51 #38 #12
wrote this small function that does the trick, let me know
import fetch from "node-fetch";
const cancelCharge = async (chargeCode: string, apiKey: string): Promise<void> => {
try {
await fetch(
`https://api.commerce.coinbase.com/charges/${chargeCode}/cancel`,
{
method: "POST",
headers: {
"X-CC-Api-Key": apiKey,
"X-CC-Version": "2018-03-22",
},
}
);
} catch (error) {
console.log("cancelCharge error:", error);
}
};
wrote this small function that does the trick, let me know
const cancelCoinbaseCharge = async (chargeCode: string, apiKey: string): Promise<void> => { try { await fetch( `https://api.commerce.coinbase.com/charges/${chargeCode}/cancel`, { method: "POST", headers: { "X-CC-Api-Key": apiKey, "X-CC-Version": "2018-03-22", }, } ); } catch (error) { console.log("cancelCoinbaseCharge error:", error); } };
Yes, this works. I am using same using node-fetch
in express backend. You can remove X-CC-Api-Key
header as it is not required. (It should be required though)
wrote this small function that does the trick, let me know
const cancelCoinbaseCharge = async (chargeCode: string, apiKey: string): Promise<void> => { try { await fetch( `https://api.commerce.coinbase.com/charges/${chargeCode}/cancel`, { method: "POST", headers: { "X-CC-Api-Key": apiKey, "X-CC-Version": "2018-03-22", }, } ); } catch (error) { console.log("cancelCoinbaseCharge error:", error); } };
Yes, this works. I am using same using
node-fetch
in express backend. You can removeX-CC-Api-Key
header as it is not required. (It should be required though)
real weird the api key isn't required, I shall keep it tho, just in case since it should be
This pull request targets on adding
Cancel Charge
feature.Important use case:
Changes:
Note: Verification with actual api call is left. If someone can verify it, it would be really helpful.