Reputation: 21
i'm working for project that's use Midtrans payment, so i use Api curl from ixudra/curl, from that i try to implemen to my controller i got this code
public function index()
{
$response = Curl::to('https://api.sandbox.midtrans.com/v2/token')
->withHeader('Content-Type: application/json')
->withHeader('Accept: application/json')
->withHeader('Authorization: Basic xxxxxxxxxxx')
->withData( array( 'card_number' => '4811111111111114' ) )
->withData( array( 'card_cvv' => '123' ) )
->withData( array( 'card_exp_month' => '01' ) )
->withData( array( 'card_exp_year' => '2020' ) )
->withData( array( 'client_key' => 'SB-Mid-client-xxxxxxxxxx' ) )
->asJson()
->returnResponseObject()
->get();
return response()->json($response);
}
then i got this return json
content
status_code "400"
status_message "One or more parameters in the payload is invalid."
id "49ab5da0-6df2-4843-a1ed-cfedfea61798"
validation_messages
0 "unsupported token request parameter(s)"
status 200
contentType "application/json"
i think there's somwthing wrong with my code because, i try implement to postman, and it's working and return token
Upvotes: 0
Views: 936
Reputation: 21
problem solved, i change all ->withData() whith this
->withData( array( 'card_number' => '4811111111111114','card_cvv' => '123','card_exp_month' => '01','card_exp_year' => '2020','client_key' => 'xxxxxxx' ) )
Upvotes: 0