PHP code example of quellabs / canvas-payments-contracts
1. Go to this page and download the library: Download quellabs/canvas-payments-contracts 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/ */
quellabs / canvas-payments-contracts example snippets
use Quellabs\Payments\Contracts\PaymentInterface;
use Quellabs\Payments\Contracts\PaymentRequest;
use Quellabs\Payments\Contracts\PaymentInitiationException;
class CheckoutService {
public function __construct(private PaymentInterface $payment) {}
public function pay(): string {
try {
$result = $this->payment->initiate(new PaymentRequest(
paymentModule: 'mollie_ideal',
amount: 999,
currency: 'EUR',
description: 'Order #12345',
));
return $result->redirectUrl;
} catch (PaymentInitiationException $e) {
// handle error
}
}
}
use Quellabs\Payments\Contracts\PaymentException;
use Quellabs\Payments\Contracts\PaymentInitiationException;
use Quellabs\Payments\Contracts\PaymentRefundException;
// Catch all payment failures
} catch (PaymentException $e) {
$e->getProvider(); // e.g. 'mollie'
$e->getErrorId(); // provider error ID
$e->getMessage(); // human-readable message
}
// Or catch specific failures
} catch (PaymentInitiationException $e) { ... } // initiate() failed
} catch (PaymentRefundException $e) { ... } // refund() or getRefunds() failed
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.