Closed luyenok closed 9 years ago
Could you show your composer.json?
{
"name": "baibaratsky/php-webmoney",
"description": "WebMoney API PHP Library",
"keywords": ["webmoney", "megastock", "capitaller", "WMXI", "WMSigner"],
"license": "BSD-3-Clause",
"homepage": "http://github.com/baibaratsky/php-webmoney",
"authors": [
{
"name": "Andrei Baibaratsky",
"email": "andrei@baibaratsky.com"
},
{
"name": "Constantin Chuprik",
"email": "constantinchuprik@gmail.com"
}
],
"require": {
"php": ">=5.3",
"baibaratsky/php-wmsigner": "1.1.*"
},
"autoload": {
"psr-4": {
"baibaratsky\\WebMoney\\": ""
}
}
}
I just downloaded and uploaded to my server, did not change anythings.
It's my composer.json. Please show me one from your project root directory.
sorry, I have not anything, I justed downloaed php-webmoney-master.zip file and uploaded to my server :(
If you want to use Composer, you don’t have to upload any files from this repository. Please read the Composer docs to discover how to use it.
To use the library without Composer, add require
calls for all the library files.
thank you, I have added require calls for all the library files and tested X2 (transfer fund), I got the error: Request errors: - Array I try to print_r ($request->getErrors()); and result is: Array ( [1] => Array ( [0] => transactionExternalId ) )
Can you help me ? I just want to using X2 to transfer fund to other purse.
Could you attach your code please?
yes, how to attach ? This form accept image file only.
Just put your code in the message here. Please use markdown to highlight the code.
<?
require_once('WebMoney.php');
require_once('Signer.php');
require_once('Request/Requester/CurlRequester.php');
require_once('Request/Requester/AbstractRequester.php');
require_once('Api/X/X2/Request.php');
require_once('Api/X/X2/Response.php');
use baibaratsky\WebMoney\WebMoney;
use baibaratsky\WebMoney\Signer;
use baibaratsky\WebMoney\Request\Requester\CurlRequester;
use baibaratsky\WebMoney\Api\X\X2;
$webMoney = new WebMoney(new CurlRequester);
$request = new X2\Request;
$request->setSignerWmid('removed');
$request->setPayerPurse('removed');
$request->setPayeePurse('removed');
$request->setAmount(0.01); // Payment amount
$request->setDescription('Test payment');
$request->setInvoiceId(0);
$request->sign(new Signer('removed', 'removed.kwm', 'removed'));
if ($request->validate()) {
/** @var X2\Response $response */
$response = $webMoney->request($request);
if ($response->getReturnCode() === 0) {
echo 'Successful payment, transaction id: ' . $response->getTransactionId();
} else {
echo 'Payment error: ' . $response->getReturnDescription();
}
} else {
echo 'Request errors: ' . PHP_EOL;
print_r ($request->getErrors());
foreach ($request->getErrors() as $error) {
echo ' - ' . $error . PHP_EOL;
}
}
?>
the result is Request errors: Array ( [1] => Array ( [0] => transactionExternalId ) ) - Array
You have to set a required parameter transactionExternalId
. Put this string in your code:
$request->setTransactionExternalId($myTransactionId); // Unique ID of the transaction in your system
$myTransactionId
should be a positive integer, unique for the WMID that signs the request. It’s not allowed to perform two transactions with the same ID.
thank you for your support, I got new error:
Payment error: signature is incorrect. planstr=1427764213510054Z222213656185Z2820325325120.010Test payment0 step=5
Does payerPurse
belong to signerWmid
?
yes, payerPurse belong to signerWmid, I have tested X9 and it working file (show Purse's balance), but got error with X2 :(, the code is below
<?
require_once('WebMoney.php');
require_once('Signer.php');
require_once('Request/Requester/CurlRequester.php');
require_once('Request/Requester/AbstractRequester.php');
require_once('Api/X/X2/Request.php');
require_once('Api/X/X2/Response.php');
use baibaratsky\WebMoney\WebMoney;
use baibaratsky\WebMoney\Signer;
use baibaratsky\WebMoney\Request\Requester\CurlRequester;
use baibaratsky\WebMoney\Api\X\X2;
$webMoney = new WebMoney(new CurlRequester);
$request = new X2\Request;
$request->setSignerWmid('removed');
$request->setPayerPurse('removed');
$request->setPayeePurse('removed');
$request->setAmount(0.01); // Payment amount
$request->setTransactionExternalId(310315079999);
$request->setDescription('Test');
$request->setInvoiceId(0);
$request->sign(new Signer('removed', 'removed.kwm', 'removed'));
if ($request->validate()) {
/** @var X2\Response $response */
$response = $webMoney->request($request);
if ($response->getReturnCode() === 0) {
echo 'Successful payment, transaction id: ' . $response->getTransactionId();
} else {
echo 'Payment error: ' . $response->getReturnDescription();
echo '<hr />'.$response->getReturnCode();
}
} else {
echo 'Request errors: ' . PHP_EOL;
print_r ($request->getErrors());
echo "<br /><hr />";
foreach ($request->getErrors() as $error) {
echo ' - ' . $error . PHP_EOL;
}
}
?>
There was a small bug with the signature in the X2 request class. Please update the library and try again.
yahoooooooooooo !!!!!!!!!!!!!!!!!!
Successful payment, transaction id: 1175379855
thank you very much,
You’re welcome!
Hic, it not working more, got the below error
Payment error: Out of present range. step=91
/**
* Set ID of the transaction in your system
*
* @param int $transactionExternalId should be a positive integer, unique for the WMID that signs the request
* It’s not allowed to perform two transactions with the same ID.
* The uniqueness of ID is verified at least for one year.
*/
public function setTransactionExternalId($transactionExternalId)
what's your mean ?
same problem here https://translate.google.com.vn/translate?hl=vi&sl=ru&tl=en&u=http%3A%2F%2Fcafe.owebmoney.ru%2Findex.php%3Fshowtopic%3D6206
it working if TransactionExternalId lenght < 10
only, got error Out of present range if TransactionExternalId lenght >10
.
I thought you use the same value for transactionExternalId
.
Since transactionExternalId
is a 32-bit integer, you shouldn’t use values greater than (2^32)-1
.
I got error when Adding the php-webmoney dependency: