xsolla / xsolla-sdk-php Goto Github PK
View Code? Open in Web Editor NEWXsolla SDK for PHP
Home Page: https://developers.xsolla.com/doc/sdk/#php_sdk
License: MIT License
Xsolla SDK for PHP
Home Page: https://developers.xsolla.com/doc/sdk/#php_sdk
License: MIT License
"php": ">=7.1.3 <=7.3"
this involves using the maximum version 7.3.0. It may be worth changing to
"php": "~7.1.3 | ~7.2 | ~7.3" or "php": ">=7.1.3 <7.4"
Currently the sdk requires guzzle in version ~6.0
and actually tries to install version 6.5.5
.
New features and also security update seem to only happen for version ^7.0. Also added php 8.x support and so on are features, that at least we use in our code base, so right now we are not able to install both guzzle ^7.0 and the sdk simultaneously.
I checked the sdk and the guzzle changelog. There don't seem to be any BC breaks relevant for the sdk itself.
Of course there is the new implementation of get
, head
, put
and so on methods, which might be relevant for XsollaClient::__call()
, however I don't think it should be that big a problem, as the README promotes using the custom methods the XsollaClient::class
adds.
Still the upgrade should probably be a major version, as users of the sdk might configure the guzzle client a bit differently than default. Especially concerning would be the dropped/changed request and pool options.
Если на сервере включено PHP-FPM, то подсказка из хелпа
RewriteEngine On
RewriteCond %{HTTP:Authorization} ^(.+)$
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
не работает.
Потому что Authorization теперь выглядит как
[REDIRECT_HTTP_AUTHORIZATION] => Signature 89b146d1f356337ac3b5813a1e0fed76fb7fd34b
и, конечно же, в headers не попадает. В webhook проверку авторизации не проходит.
Я не гуру в php, но вот этот костыль работает (WebhookAuthentificator.php)
public function authenticateSignature(WebhookRequest $webhookRequest)
{
$headers = [];
if (isset($_SERVER["REDIRECT_HTTP_AUTHORIZATION"]))
$headers = array('authorization' => $_SERVER["REDIRECT_HTTP_AUTHORIZATION"]);
else
$headers = $webhookRequest->getHeaders();
...
Happens due to class WebhookAutheticator in function authenticateSignature:
//This checks for case sensitive key: "authorization"
if (!array_key_exists('authorization', $headers)) {
throw new InvalidSignatureException('"Authorization" header not found in Xsolla webhook request. Please check troubleshooting section in README.md https://github.com/xsolla/xsolla-sdk-php#troubleshooting');
}
In my case I was getting the key "Authorization" (with capital 'A') in the header and it was throwing InvalidSignatureException.
Quick Solution for individual is to dump your headers and check for this key and make changes according.
A more permanent solution will be to read case insensitive header key to avoid this issue.
Hi, Xsolla is still marked as abandoned on packagist.
https://packagist.org/packages/xsolla/xsolla-sdk-php
What seems is no longer true.
Could you remove it from that? Thanks.
There's currently a version requirement of <7.3
. I tried the package with 7.3 and it seems to work fine in my (basic) test.
Please check this
https://basecamp.com/2008053/projects/10975817/messages/51091739
Hello! I need help with integration xsolla-sdk-php, as I can not understand how can I install the mobile payments to your online project.
I get this error when creating a client:
Fatal error: Uncaught GuzzleHttp\Exception\ClientException: Client error: 'POST https://api.xsolla.com/merchant/v2/merchants/xxxxxx/token' resulted in a '422 Unprocessable Entity' response: { "http_status_code": 422, "message": "JSON is not valid against json schema, please check documentation https:\ (truncated...) in E:\xamppp\htdocs\vendor\guzzlehttp\guzzle\src\Exception\RequestException.php:113 Stack trace: #0 E:\xamppp\htdocs\vendor\guzzlehttp\guzzle\src\Middleware.php(65): GuzzleHttp\Exception\RequestException::create(Object(GuzzleHttp\Psr7\Request), Object(GuzzleHttp\Psr7\Response)) #1 E:\xamppp\htdocs\vendor\guzzlehttp\promises\src\Promise.php(203): GuzzleHttp\Middleware::GuzzleHttp\{closure}(Object(GuzzleHttp\Psr7\Response)) #2 E:\xamppp\htdocs\vendor\guzzlehttp\promises\src\Promise.php(156): GuzzleHttp\Promise\Promise::callHandler(1, Object(GuzzleHttp\Psr7\Response), Array) #3 E:\xamppp\htdocs\vendor\guzzlehttp\promises\src\TaskQueue.php(47): GuzzleHttp\Promise\Promise::GuzzleHttp\Promise\{closure}() #4 in E:\xamppp\htdocs\vendor\xsolla\xsolla-sdk-php\src\Exception\API\XsollaAPIException.php on line 46
How to fix?
[InvalidArgumentException]
Package xsolla/xsolla-sdk-php at version 4.1.0 has a PHP requirement incompatible with your PHP version (7.4.0)
😒😥 please add ^PHP7.4 support
hm...
[InvalidArgumentException] Package xsolla/xsolla-sdk-php at version 4.1.0 has a PHP requirement incompatible with your PHP version (7.3.12)
Code
define('MERCHANT_ID', '***');
define('API_KEY', '***');
define('SECRET_KEY', '***');
define('PROJECT_ID', '***');
define('USER_ID', '***');
$tokenRequest = new TokenRequest(PROJECT_ID, MERCHANT_ID);
$tokenRequest->setUserEmail('[email protected]')
->setExternalPaymentId(12345)
->setSandboxMode(true)
->setUserName('USER_NAME')
->setCustomParameters(array('key1' => 'value1', 'key2' => 'value2'));
$xsollaClient = new XsollaClient(MERCHANT_ID, API_KEY);
$token = $xsollaClient->createPaymentUITokenFromRequest($tokenRequest);
Error
An uncaught Exception was encountered
Type: Guzzle\Common\Exception\InvalidArgumentException
Message: Config must be an array or Collection
Filename: /vendor/guzzle/guzzle/src/Guzzle/Http/Client.php
Line Number: 93
Backtrace:
File: /vendor/guzzle/guzzle/src/Guzzle/Http/Client.php
Line: 75
Function: setConfig
guzzle3 has been deprecated since the start of 2015, are there any plans to release a new version of the SDK with updated dependencies?
In it's current state we cannot use the sdk in a production environment.
I don't know if it's unlucky me, but I'm using Apache and php7.3, everything is working fine except the array_key_exists('authorization', $headers)
in the WebhookAuthentication which I had to change to array_key_exists('Authorization', $headers)
might be just me tho
Add to your documentation how to respond to webhook errors.
I've been working on various payment modules, but I've never seen a case where the documentation was messed up like Xsolla.
Seriosly no answers from developers in Xsolla?
There is pull request which will be work with higher version of php, it's really problem to merge it and test it?
I am using this SDK with laravel project. I am using api for creating virtual item. There is no document how to use with php and also request parameters are also different then mentioned in API reference of the official document. I somehow found the code from the source of the sdk. I did following code.
$virtualItem = [
'sku' => $request->sku,
'name' => [
'en' => $request->name,
],
'description' => [
'en' => $request->description,
],
'prices' => [
'USD' => $request->price,
],
'default_currency' => 'USD',
'enabled' => $request->enabled,
'free' => $request->free,
'disposable' => false,
];
$client = XsollaClient::factory(array(
'merchant_id' => config('configuration.xsolla_merchant_id'),
'api_key' => config('configuration.xsolla_api_key'),
));
$response = $client->CreateVirtualItem([
'project_id' => config('configuration.xsolla_project_id'),
'request' => $virtualItem,
]);
As you can see for the php SDK there is difference with API reference. Now I want to create virtual item which is Nonconsumable. I tried item_type=>'Consumable'
, item_type=>Nonconsumable'
, is_consumable=>false'
, but nothing seems working.
Please help me how to do that also where can I find proper documentation.
Hi,
I wanted to give Xsolla a try in my Laravel 7.16.1 project but unfortunately the command composer require xsolla/xsolla-sdk-php
fails with the following error log: https://pastebin.com/raw/R9hh2BLD
A couple weeks ago I tried the same, but then a PHP error occurred. This error has been fixed by some PR I assume but now I am facing this issue.
Hope someone is able to help me out. I assume that there should be a new update coming that will cover this issue.
Thanks :)
Edit: I assume the composer package did not get updated yet, according to this reply.
The latest SDK (v4.2.0) doesn't support:
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.