Giter Site home page Giter Site logo

php-wmsigner's Introduction

WebMoney Signer

Build Status Coverage Status Packagist Dependency Status Packagist Packagist

Provides a convenient way to sign your requests to WebMoney API in PHP with no need to run executables. You may also use WebMoney API PHP Library for more transparent object-oriented code.

Requirements

WebMoney Signer requires PHP 5.3 compiled with BCMath support. GMP can increase the performance, but is not required.

Installation

  1. Install Composer:

    curl -sS https://getcomposer.org/installer | php
    
  2. Add the php-wmsigner dependency:

    php composer.phar require baibaratsky/php-wmsigner:2.0.*
    

Usage

require_once(__DIR__ . '/vendor/autoload.php'); // Require autoload file generated by composer

use baibaratsky\WebMoney\Signer;

$signer = new Signer('wmid', '/full/path/to/the/key.kwm', 'password');
$data = 'Data to be signed'; 
$signature = $signer->sign($data);

If you have your key not in a file, it is possible to provide a key as a string:

$signer = new Signer('wmid', $yourKeyData, 'password');

php-wmsigner's People

Contributors

baibaratsky avatar klkvsk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

php-wmsigner's Issues

Hash check failed. Key file seems to be corrupted.

Hash check failed. Key file seems to be corrupted.

`use baibaratsky\WebMoney\WebMoney;
use Illuminate\Database\Eloquent\Model;
use baibaratsky\WebMoney\Api\X\X2\Request;
use baibaratsky\WebMoney\Request\Requester\CurlRequester;
use baibaratsky\WebMoney\Signer;
use baibaratsky\WebMoney\Api\X\X2;

class WebMoneyService extends Model
{
private $service;

public function __construct()
{
}

public function payment()
{
     $webMoney = new WebMoney(new CurlRequester);
    $request = new Request;
    $request->setSignerWmid('wmid');
    $request->setTransactionExternalId(1); // Unique ID of the transaction in your system
    $request->setPayerPurse('YOUR PURSE');
    $request->setPayeePurse('PAYEE PURSE');
    $request->setAmount(10.23); // Payment amount
    $request->setDescription('Test payment');
   $request->sign(new Signer('wmid', app_path() . '/certs/certificate.p12', 'pass'));

    return $request;

}`

Using Laravel 5.4, Homestead on Vagrant, Ubuntu x64.

Tryied to reissue certeficate, no luck.

Maximum function nesting level of '100' reached, aborting!

Если нет GMP, возникает ошибка:

PHP Fatal error:  Maximum function nesting level of '100' reached, aborting! in /home/a/projects/webmon/php-wmsigner/Signer.php on line 193
PHP Stack trace:
PHP   1. {main}() /home/a/projects/webmon/sign.php:0
PHP   2. baibaratsky\WebMoney\Signer->__construct() /home/a/projects/webmon/sign.php:4
PHP   3. baibaratsky\WebMoney\Signer->initSignVariables() /home/a/projects/webmon/php-wmsigner/Signer.php:41
PHP   4. baibaratsky\WebMoney\Signer::reverseToDecimal() /home/a/projects/webmon/php-wmsigner/Signer.php:93
PHP   5. baibaratsky\WebMoney\Signer::hex2dec() /home/a/projects/webmon/php-wmsigner/Signer.php:166
PHP   6. baibaratsky\WebMoney\Signer::hex2decBC() /home/a/projects/webmon/php-wmsigner/Signer.php:182
PHP   7. baibaratsky\WebMoney\Signer::hex2decBC() /home/a/projects/webmon/php-wmsigner/Signer.php:202
PHP   8. baibaratsky\WebMoney\Signer::hex2decBC() /home/a/projects/webmon/php-wmsigner/Signer.php:202
PHP   9. baibaratsky\WebMoney\Signer::hex2decBC() /home/a/projects/webmon/php-wmsigner/Signer.php:202
.....
PHP  97. baibaratsky\WebMoney\Signer::hex2decBC() /home/a/projects/webmon/php-wmsigner/Signer.php:202
PHP  98. baibaratsky\WebMoney\Signer::hex2decBC() /home/a/projects/webmon/php-wmsigner/Signer.php:202
PHP  99. baibaratsky\WebMoney\Signer::hex2decBC() /home/a/projects/webmon/php-wmsigner/Signer.php:202

What is "Data to be signed"

Hello. In the example there is a line which says:
$data = 'Data to be signed';

What is 'Data to be signed'? How should I make it?

Issue with SimpleXMLElement

Hello,

Thank you for this amazing library,

Every few days (not always) I have something like this logged into error_logs:

ERROR - 2016-11-26 02:48:02 --> Severity: Warning --> SimpleXMLElement::__construct(): Entity: line 6: parser error : Opening and ending tag mismatch: hr line 5 and body /path/w_money/Api/X/X9/Response.php 24
ERROR - 2016-11-26 02:48:02 --> Severity: Warning --> SimpleXMLElement::__construct(): </body> /path/w_money/Api/X/X9/Response.php 24
ERROR - 2016-11-26 02:48:02 --> Severity: Warning --> SimpleXMLElement::__construct():        ^ /path/w_money/Api/X/X9/Response.php 24
ERROR - 2016-11-26 02:48:02 --> Severity: Warning --> SimpleXMLElement::__construct(): Entity: line 7: parser error : Opening and ending tag mismatch: body line 3 and html /path/w_money/Api/X/X9/Response.php 24
ERROR - 2016-11-26 02:48:02 --> Severity: Warning --> SimpleXMLElement::__construct(): </html> /path/w_money/Api/X/X9/Response.php 24
ERROR - 2016-11-26 02:48:02 --> Severity: Warning --> SimpleXMLElement::__construct():        ^ /path/w_money/Api/X/X9/Response.php 24
ERROR - 2016-11-26 02:48:02 --> Severity: Warning --> SimpleXMLElement::__construct(): Entity: line 8: parser error : Premature end of data in tag html line 1 /path/w_money/Api/X/X9/Response.php 24
ERROR - 2016-11-26 02:48:02 --> Severity: error --> Exception: String could not be parsed as XML /path/w_money/Api/X/X9/Response.php 24

Another Example

ERROR - 2016-11-22 15:28:24 --> Severity: Warning --> SimpleXMLElement::__construct(): Entity: line 1: parser error : Space required after the Public Identifier /path/w_money/Api/X/X2/Response.php 63
ERROR - 2016-11-22 15:28:24 --> Severity: Warning --> SimpleXMLElement::__construct(): <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/str /path/w_money/Api/X/X2/Response.php 63
ERROR - 2016-11-22 15:28:24 --> Severity: Warning --> SimpleXMLElement::__construct():                                                  ^ /path/w_money/Api/X/X2/Response.php 63
ERROR - 2016-11-22 15:28:24 --> Severity: Warning --> SimpleXMLElement::__construct(): Entity: line 3: parser error : Opening and ending tag mismatch: META line 3 and HEAD /path/w_money/Api/X/X2/Response.php 63
ERROR - 2016-11-22 15:28:24 --> Severity: Warning --> SimpleXMLElement::__construct(): <META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD> /path/w_money/Api/X/X2/Response.php 63
ERROR - 2016-11-22 15:28:24 --> Severity: Warning --> SimpleXMLElement::__construct():                                                                              ^ /path/w_money/Api/X/X2/Response.php 63
ERROR - 2016-11-22 15:28:24 --> Severity: Warning --> SimpleXMLElement::__construct(): Entity: line 6: parser error : Opening and ending tag mismatch: hr line 5 and BODY /path/w_money/Api/X/X2/Response.php 63
ERROR - 2016-11-22 15:28:24 --> Severity: Warning --> SimpleXMLElement::__construct(): </BODY></HTML> /path/w_money/Api/X/X2/Response.php 63
ERROR - 2016-11-22 15:28:24 --> Severity: Warning --> SimpleXMLElement::__construct():        ^ /path/w_money/Api/X/X2/Response.php 63
ERROR - 2016-11-22 15:28:24 --> Severity: Warning --> SimpleXMLElement::__construct(): Entity: line 6: parser error : Opening and ending tag mismatch: BODY line 4 and HTML /path/w_money/Api/X/X2/Response.php 63
ERROR - 2016-11-22 15:28:24 --> Severity: Warning --> SimpleXMLElement::__construct(): </BODY></HTML> /path/w_money/Api/X/X2/Response.php 63
ERROR - 2016-11-22 15:28:24 --> Severity: Warning --> SimpleXMLElement::__construct():               ^ /path/w_money/Api/X/X2/Response.php 63
ERROR - 2016-11-22 15:28:24 --> Severity: Warning --> SimpleXMLElement::__construct(): Entity: line 7: parser error : Premature end of data in tag HEAD line 2 /path/w_money/Api/X/X2/Response.php 63
ERROR - 2016-11-22 15:28:24 --> Severity: Warning --> SimpleXMLElement::__construct(): Entity: line 7: parser error : Premature end of data in tag HTML line 2 /path/w_money/Api/X/X2/Response.php 63
ERROR - 2016-11-22 15:28:24 --> Severity: error --> Exception: String could not be parsed as XML /path/w_money/Api/X/X2/Response.php 63

Is this an issue I should be worried about?

Hash check failed. Key file seems corrupted.

Запустил php-wmsigner по примеру в описании и получил следующую ошибку:
Hash check failed. Key file seems corrupted.

Но файл ключей точно не поврежден, WebMoney Keeper WinPro принимает его без ошибок.

Может ли проблема заключаться в среде запуска?
Пример запускался на Win7 + OpenServer

Hash check failed. Key file seems corrupted

Ошибка при проверке key-файла.
Signer.php xorStrings:149

$modifierLength = mb_strlen($modifier, 'windows-1251'); //strlen($modifier);

Signer.php xorStrings:152

 while ($i < mb_strlen($subject, 'windows-1251')) { //while ($i < strlen($subject)) {

Не работало в кодировке utf-8 при mbstring.func_overload, возможно нужно добавить в master явное указание кодировки/переписать все строковые функции через mb_*

Передача ключа в виде строки

If you have your key not in a file, it is possible to provide a key as a string:
$signer = new Signer('wmid', $yourKeyData, 'password');

Подскажите как правильно преобразовать key.kwm в строку для $yourKeyData ? Пытаюсь через base64 - ошибка Key file not found

could not load PEM client certificate

my mode is webpro and the code is:

  $request->lightAuth('certificate.p12', str_random(5), '');

what does this error mean?

Error while performing request (could not load PEM client certificate, OpenSSL error error:0909006C:PEM routines:get_name:no start line, (no key found, wrong pass phrase, or wrong file format?))

Hash check failed. Key file seems to be corrupted. (0)

Help me this is my code. key file same folder with index.php
""""""""""""

require 'vendor/autoload.php';
use baibaratsky\WebMoney\Signer;

Flight::route('/', function(){
$test = file_get_contents('test.kwm');
$signer = new Signer('wmid', $test, '12345678');
$data = 'Data to be signed';
$signature = $signer->sign($data);
echo "hello world! $signature";
});

Flight::start();

Строковый ключ

Сделай возможность указывать не путь до файла, а уже саму строку чтобы в конфиге можно было хранить всю нужную инфу по wmid, а не доп. файлы держать.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.