paddlehq / paddle-php-sdk Goto Github PK
View Code? Open in Web Editor NEWPHP SDK for working with the Paddle API in server-side apps.
Home Page: https://developer.paddle.com/
License: Apache License 2.0
PHP SDK for working with the Paddle API in server-side apps.
Home Page: https://developer.paddle.com/
License: Apache License 2.0
I am encountering an Error 500 when trying to list products using the Paddle PHP SDK in the Sandbox environment. The API key is validated, and the client seems to be implemented correctly. The issue arises when calling $client->products->list();
which triggers an error from the Paddle API.
{
"type": "https://tools.ietf.org/html/rfc2616#section-10",
"title": "An error occurred",
"status": 500,
"detail": "Paddle API can't process your request"
}
$client->products->list();
.A successful API call returning a list of products.
// Initialize the API
$this->api = new Client(
$this->params->get('app.paddle')['api_key'],
new Options(
$this->params->get('app.paddle')['is_sandbox'] ?
Environment::SANDBOX :
Environment::PRODUCTION
),
$this->asyncClient,
);
$this->api->products->list();
PHP 8.1
0.1.0
V1
$payload
is null
, the serialization process converts it to a string "null", which is then incorrectly included in the GET request body.The method of serializing the payload in the SDK seems to convert a null
value into a string "null", which is then included in the body of the GET request. This behavior is not standard for GET requests and could be causing the Paddle API to return an error.
Review and modify the serialization process in the SDK to ensure that a null
payload does not result in a string "null" being included in the GET request body. It might involve adding a condition to check if the payload is null
before serializing it. This change could prevent the inclusion of inappropriate data in the GET request body, potentially resolving the error.
===
P.s.: Thank you for this SDK. It comes just in time! I've already seen myself having to implement a PHP client myself in the next few weeks. ๐
Dear team,
we use the SDK to verify webhooks and it works for 99% of the cases.
For the failing ones we noticed that the customer have special characters e.g. in the customer name (e.g ร ร ร for German customers or ร
/รฅ) and the validation fails.
We added a unit test for these payloads and its reproducible - but we cant share it because it contains customer data.
How can we validate in these cases?
Thanks,
Max
Added the following test with a vailing JSON payload.
Also tested it with a valid one to ensure that the code works.
Webhook validation successful
/** @test */
public function it_verifies_a_signature2(): void
{
$json = '<PAYLOAD WITH SPECIAL CHARACTERS>';
$request = Psr17FactoryDiscovery::findRequestFactory()
->createRequest('POST', '/paddle/notifications')
->withHeader(
PaddleSignature::HEADER,
'<header>',
)
->withBody(
Psr17FactoryDiscovery::findStreamFactory()->createStream($json),
);
$secrets = [
// The correct key
new Secret('<KEY>'),
];
self::assertTrue((new Verifier(null))->verify($request, ...$secrets));
}
### PHP version
PHP 8.2.7
### SDK version
latest
### API version
version 1
### Additional context
I can share the json payload / key via email if needed: firstname@lastname dot it
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".
Response from Client & Server should have the same Status and according attributes
// 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 8.1
paddle
Paddle Version 1
Its not directly correlated to https://github.com/PaddleHQ/paddle-php-sdk, but may you can help me, or you also faced this issue?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.