paddle-php-sdk icon indicating copy to clipboard operation
paddle-php-sdk copied to clipboard

Paddle Transaction Status - Client vs. Server (Sandbox)

Open CarlsonBuma opened this issue 10 months ago • 1 comments

Describe the bug

Im using PaddleJS in Frontend and store the current Userrequest in Backend (SPA - Approach), by validating the Transaction_ID. I realized I get different kind of Transaction Status by Paddle, when Client returns Status "Completed".

  • Client - Paddle JS => response: { status: "completed" }
  • Server - API Request "https://sandbox-api.paddle.com/transactions/{transaction_id}" => response: { status: "paid" }

Steps to reproduce

  1. Client: Paddle JS Process Checkout
  2. Client -> Server Request: Each Response will be sent to Backend via API Call
  3. Server: Validate Client Request by Paddle Request "https://sandbox-api.paddle.com/transactions/{transaction_id}"

Expected behavior

Response from Client & Server should have the same Status and according attributes

Code snippets

// Client Request
// As soon we get Paddle Callback, Serverrequest is starting
const paddleInstance = await initializePaddle({
     environment: 'sandbox',
     token: props['publicKey'],
     eventCallback: function(data) {
         context.emit('paddleEvents', data)
     }
});

// Server Request (PHP)
// Validate Client Request
$this->client = new Client([
    'verify' => (bool) env('PADDLE_SANDBOX') ? false : true,
    'base_uri' => env('PADDLE_URL'),
]);

$response = $this->client->request('GET', 'transactions/' . $transactionID, [
   'headers' => [
         'Authorization' => 'Bearer ' . $this->paddle_api_key
    ],
]);

PHP version

PHP 8.1

SDK version

paddle

API version

Paddle Version 1

Additional context

Its not directly correlated to https://github.com/PaddleHQ/paddle-php-sdk, but may you can help me, or you also faced this issue?

CarlsonBuma avatar Apr 20 '24 12:04 CarlsonBuma

Hi @CarlsonBuma, Thank you for raising this issue.

It appears that you are comparing status of two different entities (checkout and transactions).

The completed status returned by PaddleJS during the checkout.completed event means the checkout is complete and payment is collected successfully. At this point, the transaction entity behind the checkout will be at paid state.

Once the transaction is paid, there are some asynchronous process running in the background before a transaction reaches completed state.

Please let us know if you need any more information.

vijayasingam-paddle avatar Apr 24 '24 09:04 vijayasingam-paddle

Hi @CarlsonBuma closing this issue as it seems it got clarified by @vijayasingam-paddle, feel free to open a new one if something else comes up.

Thank you.

vifer avatar May 30 '24 07:05 vifer