starkpay-php/starkpay

Starkpay PHP Payment Client Library

0.0.4 2020-06-12 14:21 UTC

This package is auto-updated.

Last update: 2024-11-13 00:10:59 UTC


README

Integrated crypto payments for global businesses

https://starkpayments.com/

Requirements

PHP 5.3.0 and later.

Installation

Via Composer

composer require starkpay-php/starkpay

Basic Usage

<?php
// including autoload file.
require __DIR__.'/vendor/autoload.php';

// Creating a new payment object ($apiKey) visit http://dashboard.starkpayments.net to get API Key
$payment = new \Starkpayments\Payment('<api_key>');

// Get pay object ($amount, $currency (EUR,USD etc), $description, $returnUrl)
$pay =  $payment->getUrl(23.5, 'USD', 'Invoice 2223', 'https://mydomain.com/payment_return.php');

if ($pay->isSuccess()) {
	//redirect URL
	 $redirect_url = $pay->getRedirectUrl();
	 header("location: $redirect_url");
} else {
	echo $pay->getErrorMessage();
}

?>

Payment Validation On CallBack Page

<?php
if ($payment->paymentIsValid()) {
	echo "Payment Successful";
} else {
	echo "Payment Failed, Error : ". $payment->getErrorMessage();
}
?>

PHP Unit

PHP unit test

./vendor/bin/phpunit --bootstrap vendor/autoload.php tests/ --coverage-html reports --whitelist src

License

The MIT License (MIT). Please see License File for more information.