sverraest/pomelo-php

View on GitHub
src/Crypt/Signature.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php
namespace PomeloPHP\Crypt;

use PomeloPHP\Model\Transaction;

class Signature
{
    /**
     * @var Transaction
     */
    private $transaction;


    /**
     * @var string
     */
    private $apiKey;

    /**
     * Signature constructor.
     * @param Transaction $transaction
     * @param string $apiKey
     */
    public function __construct(Transaction $transaction, $apiKey)
    {
        $this->transaction = $transaction;
        $this->apiKey = $apiKey;
    }

    /**
     * @return string
     */
    public function sign()
    {
        $str = 'amount='.$this->transaction->getAmount().
            '&currency='.$this->transaction->getCurrency().
            '&apiKey='.$this->apiKey;

        return sha1($str);
    }
}