baibaratsky / php-webmoney

WebMoney API PHP Library
Other
73 stars 32 forks source link

Add the php-webmoney dependency error #63

Closed luyenok closed 9 years ago

luyenok commented 9 years ago

I got error when Adding the php-webmoney dependency:

root@do [/home/the247/public_html/wmzapi]# php composer.phar require baibaratsky/php-webmoney:0.10.*
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - The requested package baibaratsky/php-webmoney 1.0.0 could not be found.

Potential causes:
 - A typo in the package name
 - The package is not available in a stable-enough version according to your minimum-stability setting
   see <https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion> for more details.

Read <http://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.

Installation failed, reverting ./composer.json to its original content.
root@do [/home/the247/public_html/wmzapi]#
baibaratsky commented 9 years ago

Could you show your composer.json?

luyenok commented 9 years ago
{
    "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\\": ""
        }
    }
}
luyenok commented 9 years ago

I just downloaded and uploaded to my server, did not change anythings.

baibaratsky commented 9 years ago

It's my composer.json. Please show me one from your project root directory.

luyenok commented 9 years ago

sorry, I have not anything, I justed downloaed php-webmoney-master.zip file and uploaded to my server :(

baibaratsky commented 9 years ago

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.

luyenok commented 9 years ago

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.

baibaratsky commented 9 years ago

Could you attach your code please?

luyenok commented 9 years ago

yes, how to attach ? This form accept image file only.

baibaratsky commented 9 years ago

Just put your code in the message here. Please use markdown to highlight the code.

luyenok commented 9 years ago
<?
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;
    }
}

?>
luyenok commented 9 years ago

the result is Request errors: Array ( [1] => Array ( [0] => transactionExternalId ) ) - Array

baibaratsky commented 9 years ago

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.

luyenok commented 9 years ago

thank you for your support, I got new error: Payment error: signature is incorrect. planstr=1427764213510054Z222213656185Z2820325325120.010Test payment0 step=5

baibaratsky commented 9 years ago

Does payerPurse belong to signerWmid?

luyenok commented 9 years ago

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;
    }
}

?>
baibaratsky commented 9 years ago

There was a small bug with the signature in the X2 request class. Please update the library and try again.

luyenok commented 9 years ago

yahoooooooooooo !!!!!!!!!!!!!!!!!! Successful payment, transaction id: 1175379855

thank you very much,

baibaratsky commented 9 years ago

You’re welcome!

luyenok commented 9 years ago

Hic, it not working more, got the below error Payment error: Out of present range. step=91

baibaratsky commented 9 years ago
    /**
     * 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)
luyenok commented 9 years ago

what's your mean ?

luyenok commented 9 years ago

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.

baibaratsky commented 9 years ago

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.