PHP code example of starkpay-php / starkpay

1. Go to this page and download the library: Download starkpay-php/starkpay 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/ */

    

starkpay-php / starkpay example snippets



// including autoload file.
 ($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();
}



if ($payment->paymentIsValid()) {
	echo "Payment Successful";
} else {
	echo "Payment Failed, Error : ". $payment->getErrorMessage();
}
 bash
composer 
 bash
./vendor/bin/phpunit --bootstrap vendor/autoload.php tests/ --coverage-html reports --whitelist src