Discussions

Ask a Question
Back to All

attributes cannot be blank

Why i have this error, i check attribute and it is not empty

+"code": "invalid_payload_format"
+"detail": "attributes cannot be blank."

im using this code below

public function pay()
{
$data = [
'data' => [
'attributes' => [
'amount' => 10000,
'payment_method_allowed' => [
'atome',
'card',
'dob',
'paymaya',
'billease',
'gcash',
'grab_pay'
],
'payment_method_options' => [
'card' => [
'request_three_d_secure' => 'any'
]
],
'currency' => 'PHP',
'capture_type' => 'automatic'
]
]
];

    // Send the API request to create a payment intent
    $response = Curl::to('https://api.paymongo.com/v1/payment_intents')
        ->withHeader('accept: application/json')
        ->withHeader('authorization: Basic ' . env('AUTH_PAY'))
        ->withHeader('content-type: application/json')
        ->withData(json_encode($data))
        ->asJson()
        ->post();
        dd($response);
    // Check if the payment intent creation was successful
    if ($response->data && $response->data->id) {
        // Store the payment intent ID in the session
 
        \Session::put('payment_intent_id', $response->data->id);

        // Redirect the user to the checkout URL
        return redirect()->to($response->data->attributes->checkout_url);
    } else {
        // Handle the case when the payment intent creation fails
        // You can display an error message or redirect the user to an error page
    }
}