#thereal-charge-status

1 messages ยท Page 1 of 1 (latest)

strange pilotBOT
void cape
#

i Am using django

kindred pawn
#

What's the purchase_id in this case? Is that a Stripe Charge ID? Have you tested this out?

void cape
#

ya it works with the test card, the purchase ID is the charge.id I was just wondering if this would work in production or if I'm doing it wrong

kindred pawn
void cape
#

thanks I was wondering where it was in the API ๐Ÿ™‚

strange pilotBOT
void cape
#
def check_payment_status(charge_id):
    stripe.api_key = settings.STRIPE_SECRET_KEY
    try:
        charge = stripe.Charge.retrieve(charge_id)
        if charge.status == 'pending':
            return "Payment is pending"
        elif charge.status == 'succeeded':
            return "Payment succeeded"
        elif charge.status == 'failed':
            return "Payment failed"
        else:
            return "Unknown payment status"
    except stripe.error.StripeError as e:
        return f"Error: {e}"
#

works great ๐Ÿ™‚

sacred spear
#

glad you figured it out!

#

thereal-charge-status