Error in Making Payment Method Resource on Javascript Client Side

Discussions

Ask a Question
Back to All

Error in Making Payment Method Resource on Javascript Client Side

Hello. I am trying to create a Payment Method Resource on Javascript Client Side.But I got this error.

{"readyState":4,"responseText":"{"errors":[{"code":"parameter_data_type_invalid","detail":"details.exp_month should be an integer.","source":{"pointer":"details.exp_month","attribute":"exp_month"}},{"code":"parameter_data_type_invalid","detail":"details.exp_year should be an integer.","source":{"pointer":"details.exp_year","attribute":"exp_year"}}]}","responseJSON":{"errors":[{"code":"parameter_data_type_invalid","detail":"details.exp_month should be an integer.","source":{"pointer":"details.exp_month","attribute":"exp_month"}},{"code":"parameter_data_type_invalid","detail":"details.exp_year should be an integer.","source":{"pointer":"details.exp_year","attribute":"exp_year"}}]},"status":400,"statusText":"error"}

var authorizationHeader = 'Basic ' + btoa('pk_test_mycode');
$.ajax({
method:'POST', url:'https://api.paymongo.com/v1/payment_methods', headers:{Authorization:authorizationHeader, contentType:'application/json', dataType:'json'},
data:{
data:{
attributes:{
type:'card',
details:{
card_number:'4343434343434345', exp_month:5, exp_year:2026, cvc:'111'
}
}
}
},
success: function(data, status, xhr){
alert('success ' + data);
},
error: function (xhr, status, error){
var errmsg = JSON.stringify(xhr) + '

' + status + '

' + error;
alert(errmsg);
}
});

Please tell me what is wrong. Please respond immediately. Thank you.