Coinbase - put checkout Id in success page link when creating a charge

Viewed 58

So when I am specifying the success page link when creating a charge I want to put the id in the link so I can retrieve the data from the checkout session

This is my code:

    app.get('/checkout', async (req, res) => {
        const chargeData = {
            name: 'test',
            local_price: {
                amount: '1.00',
                currency: 'USD'
            },
            pricing_type: 'fixed_price',
            redirect_url: 'http://localhost:3000/order',
            cancel_url: 'http://localhost:3000/cancel'
        }
    
        const charge = await Charge.create(chargeData)
    
        res.send(charge)
    })

And I want to make something like this

    app.get('/checkout', async (req, res) => {
        const chargeData = {
            name: 'test',
            local_price: {
                amount: '1.00',
                currency: 'USD'
            },
            pricing_type: 'fixed_price',
            redirect_url: 'http://localhost:3000/order?id=/*checkout id*/',
            cancel_url: 'http://localhost:3000/cancel'
        }
    
        const charge = await Charge.create(chargeData)
    
        res.send(charge)
    })
0 Answers
Related