zhiyu
zhiyu

Reputation: 67

Laravel PUT Method Not Working

updated - I am trying to use the API documentation to change the billing date using the PUT method in Http and Guzzle in Laravel, however, the JSON file would return but it will not change the billing date at all.

My code in detail:

public function changeYearlySubscriptionBillingDate(Request $request)
{
    $user = $request->user();
    $subscriptionId = $user->subscription->subscription_id;
    $nextBilling = Carbon::now()->addYear();
    $hostname = env('CHARGIFY_HOSTNAME');

    $headers = [
        'authorization' => 'Basic ANIDIANDIAJIJCQ',
        'content-type' => 'application/json'
    ];

    $body = ["subscription" => ["next_billing_at" =>[ $nextBilling ]]];

    $config = [
        'headers' => $headers,
        'form_param' => $body
    ];

    $client = new Client($config);

    $res = $client->put("https://$hostname/subscriptions/$subscriptionId.json");

    echo $res->getBody();
}

Upvotes: 1

Views: 1167

Answers (1)

Rob
Rob

Reputation: 361

Changes this:

echo $response->getBody();

to

dd($response->getBody());

and repost the response data is returned.

Upvotes: 0

Related Questions