繁体   English   中英

laravel 5.5 Midtrans Api卷发

[英]laravel 5.5 Midtrans Api curl

我正在为使用Midtrans付款的项目工作,所以我使用了ixudra / curl的 Api curl, 从那我尝试实现到我的控制器我得到了这段代码

 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);
}

然后我得到了这个返回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"

我认为我的代码有什么问题,因为我尝试实施邮递员,并且该代码正常工作并返回令牌

首先看一下标题

->withHeader('Content-Type: application/json')
->withHeader('Accept: application/json')

方法get

问题解决了,我全部更改-> withData()

->withData( array( 'card_number' => '4811111111111114','card_cvv' => '123','card_exp_month' => '01','card_exp_year' => '2020','client_key' => 'xxxxxxx' ) )

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM