Discussions

Ask a Question
Back to All

Invalid Payload Format when creating Payment Intents

I am trying to create a payment intent using the api reference guide but the response I am getting is status code 400 with error details

{"errors":[{"code":"invalid_payload_format","detail":"attributes cannot be blank."}]}

I based my payload on the api guide, here is the payload

        const paymentIntentData = {
            attributes: {
                amount: totalAmount,
                payment_method_allowed: ['card'],
                payment_method_options: {card: { request_three_d_secure: 'any' } },
                currency: 'PHP',
                description: 'GoBigas',
                statement_descriptor: 'GoBigas',
                metadata: { 'data': 'data'}
              }
        }
        const paymentIntentOptions = {
            headers: {
                'Content-Type': 'application/json',
                Authorization: `Basic ${window.btoa(apiKey)}`
              },
        }
        const paymentIntent = await axios.post('https://api.paymongo.com/v1/payment_intents', paymentIntentData, paymentIntentOptions);