jeudi 9 juillet 2020

Laravel: Function expecting argument as an array but still throwing error

I am passing card data on my frontend with an axios post and I'm getting back an error that says argument 1 in addPaymentProfile() must be of type array. Null was given. I cannot seem to tell why. I tried making $card another data type by doing $cardArray = (array)$card and passing it that but it's the same issue.

axios.post('/api/payment-profile', {
   card_data: {
              card_number: cardNumber,
              exp_month: expMonth,
              exp_year: expYear,
              cv_code: cvCode
            }
})

Laravel

public function paymentProfile(Request $request) 
{
    $card = $request->input('card_data');
    $this->addNewAuthorizePaymentProfile($card);

}

public function addPaymentProfile(array $cardDetails)
{
   // method from Authorize.net payment processor that adds card
}


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire