PHP code example of khalyomede / systempay

1. Go to this page and download the library: Download khalyomede/systempay library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

khalyomede / systempay example snippets




use Khalyomede\Systempay\Payment;
use Khalyomede\Systempay\Currency;
use Khalyomede\Systempay\ContextMode;
use Khalyomede\Systempay\HashAlgorithm;
use Khalyomede\Systempay\PaymentConfiguration;

$payment = new Payment;
$payment->setKey("foo")
    ->setSiteId("12345678")
    ->setTotalAmount(199.99)
    ->setContextMode(ContextMode::TEST)
    ->setCurrency(Currency::EUR)
    ->setPaymentConfiguration(PaymentConfiguration::SINGLE) // One shot payment
    ->setTransactionDate(new DateTime("NOW"))
    ->setTransactionId("xrT15p")
    ->setHashAlgorithm(HashAlgorithm::SHA256);

$fields = $payment->getHtmlFormFields();
$url = $payment->getFormUrl();


use Khalyomede\Systempay\PaymentNotification;
use Khalyomede\Systempay\TransactionStatus;

$notification = new PaymentNotification($_POST);
$notification->setKey("the-private-key");

if ($notification->hasValidSignature() && $notification->getTransactionStatus() === TransactionStatus::AUTHORISED) {
	echo "all went good";
} else {
	echo "depending the transaction status, you should perform a custom action";
}

public function getHashAlgorithm(): string;

public function getTotalAmount(): float;

public function getFormTotalAmount(): int;

public function getSiteId(): string;

public function getContextMode(): string;

public function getCurrencyNumericCode(): int;

public function getPaymentConfiguration(): string;

public function getTransactionDate(): DateTime;

public function getFormTransactionDate(): string;

public function getTransactionId(): string;

public function getVersion(): string;

public function getActionMode(): string;

public function getPageAction(): string;

public function getHtmlFormFields(): string;

public function getKey(): string;

public function getFormUrl(): string;

public function setHashAlgorithm(string $algorithm): Payment;

public function setTotalAmount(float $amount): Payment;

public function setSiteId(string $siteId): Payment;

public function setContextMode(string $mode): Payment;

public function setCurrency(string $currency): Payment;

public function setPaymentConfiguration(string $configuration): Payment;

public function setTransactionDate(DateTime $date): Payment;

public function setTransactionId(string $transactionId): Payment;

public function setKey(string $key): Payment;

public function __construct(string $mode);

public function isAllowed(): bool;

public static function getAllowedToString(): string;

public function __construct(string $algorithm);

public function isSupported(): bool;

public function isAllowed(): bool;

public static function getAllowedToString(): string;

public function __construct(string $configuration);

public function isAllowed(): bool;

public static function getAllowedToString(): string;

public function __construct(array $paymentResultData)

public function setKey(string $key): PaymentNotification

public function setHashAlgorithm(string $algorithm): PaymentNotification