PHP code example of marekvikartovsky / trustpay-php

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

    

marekvikartovsky / trustpay-php example snippets


$trustpay = new \MarekVikartovsky\TrustPay\TrustPay(
'PROJET_ID',
'PRIVATE_KEY',
'NOTIFICATION_URL'
'SUCCESS_RETURN_URL',
'CANCEL_RETURN_URL',
'ERROR_RETURN_URL',
'en'
);

return $trustpay->payment(\MarekVikartovsky\TrustPay\PaymentMethods\CardPayment::PAYMENT_METHOD_NAME)
->setAmount((float) 10)
->setCurrency(\MarekVikartovsky\TrustPay\Enums\CurrencyEnum::EUR)
->setReference('MERCHANT_REFERENCE')
->setPaymentType('Purchase')
->getPaymentUrl();

$notification = new \MarekVikartovsky\TrustPay\CallbackHandlers\NotificationHandler('XXXXX-PRIVATE-KEY-XXXXX', new \Illuminate\Http\Request())

if($notification->hasValidSignature()){
    // do something
}

if($notification->isPaid()){
    // do something
}