mirror of
https://github.com/AustinKelsay/plebdevs.git
synced 2025-05-18 04:05:51 +00:00
Fix 0 amount invoice bug
This commit is contained in:
parent
a08d6a7af3
commit
410ee763cd
@ -71,9 +71,16 @@ const CoursePaymentButton = ({ lnAddress, amount, onSuccess, onError, courseId }
|
|||||||
const fetchInvoice = async () => {
|
const fetchInvoice = async () => {
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
try {
|
try {
|
||||||
|
if (discountApplied && calculateDiscount(amount).discountedAmount === 0) {
|
||||||
|
handlePaymentSuccess({ paid: true, preimage: 'course_pass' });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const ln = new LightningAddress(lnAddress);
|
const ln = new LightningAddress(lnAddress);
|
||||||
await ln.fetch();
|
await ln.fetch();
|
||||||
const invoice = await ln.requestInvoice({ satoshi: discountApplied ? calculateDiscount(amount).discountedAmount : amount });
|
const invoice = await ln.requestInvoice({
|
||||||
|
satoshi: discountApplied ? calculateDiscount(amount).discountedAmount : amount
|
||||||
|
});
|
||||||
setInvoice(invoice);
|
setInvoice(invoice);
|
||||||
setDialogVisible(true);
|
setDialogVisible(true);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -176,7 +183,7 @@ const CoursePaymentButton = ({ lnAddress, amount, onSuccess, onError, courseId }
|
|||||||
{discountApplied && (
|
{discountApplied && (
|
||||||
<div className="text-xs text-gray-500 flex items-center gap-1">
|
<div className="text-xs text-gray-500 flex items-center gap-1">
|
||||||
<span className="line-through">{amount} sats</span>
|
<span className="line-through">{amount} sats</span>
|
||||||
<span className="text-green-500 font-semibold"><EFBFBD><EFBFBD><EFBFBD> {calculateDiscount(amount).discountedAmount} sats</span>
|
<span className="text-green-500 font-semibold">{calculateDiscount(amount).discountedAmount} sats</span>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user