Laravel cashier-paddle Simple Charge The checkout id issue

1.4k Views Asked by At
  • Cashier Paddle Version: 1.0@beta
  • Laravel Version: 7.0
  • PHP Version: 7.2.5

I am using cashier-paddle for one of my laravel 7 projects. I'm trying to apply a "one off" charge (Simple Charge) against a customer. I've followed the official documentation to integrate the package in my project but I am getting this issue "Simple Charge The checkout id must be a valid checkout id". Here are the steps that I have already completed.

  • Installed the official laravel cashier-paddle package using composer require laravel/cashier-paddle

  • Published necessary migrations and added the necessary API Keys on my env file

  • Added the @paddlejs in may master layout blade file and updated the VerifyCsrfToken middleware so it except routes paddle/*

  • Added the Billable trait to the User model Configured the webhook route and controller

    // Route example
    Route::post('paddle/webhook','WebhookController@handleWebhook')->name('cashier.webhook')
    
    // WebhookController
    namespace App\Http\Controllers;
    use Illuminate\Http\Request;
    use Laravel\Paddle\Http\Controllers\WebhookController as CashierController;
    
    class WebhookController extends CashierController
    {
        public function handleWebhook(Request $request)
        {
    
            logger('I can reach here!');
        }
    
        public function handlePaymentSucceeded($payload)
        {
    
        }
    }
    
  • Generated the paylink variable using my controller.

    // paylink variable from controller
    $payLink = auth()->user()->charge(12.99, 'Test Product Title');
    
  • Finally used the variable on the paddle-button Blade component

    // Blade file
    <x-paddle-button :url="$payLink" class="px-8 py-4">
        Buy
    </x-paddle-button>
    

Note: The simple charge is not working but the charge for a specific product is working fine. For example this one auth()->user()->chargeProduct(619859) is working fine.

These are the steps that I have already followed to integrate the paddle simple chare on my laravel application. Hope that information may help you. Let me know if I am doing anything wrong or missed any steps. I will be really very thankful if anyone can help me to solve the issue. Thanks in advance.

1

There are 1 best solutions below

1
Alok Paul. On

Thanks for visiting the question. After doing some research I've fixed the issue. Everything was fine. Just need to specify the webhook URL in the charge method. I think it was not mentioned in laravel documentation. I'm posting the answer so anyone can get a solution in the future.

// paylink variable from controller
$payLink = auth()->user()->charge($total, 'Product Title', [
   'webhook_url' => 'webhook URL here',

]);