1. Go to this page and download the library: Download getpayin/paylink 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/ */
getpayin / paylink example snippets
use GetPayin\Paylink\Core\PaylinkClient;
$paylink = new PaylinkClient(
publicToken: getenv('PAYLINK_PUBLIC_TOKEN'),
hashToken: getenv('PAYLINK_HASH_TOKEN'), // secret — server-side only
);
$checkout = $paylink->invoices->create([
'firstName' => 'John',
'lastName' => 'Doe',
'email' => '[email protected]',
'orderTitle' => 'Gold Plan',
'orderAmount' => '250.00', // pass money as strings for an exact wire form
'currency' => 'USD',
]);
// ['checkoutUrl' => ..., 'invoiceId' => ..., 'expiresAt' => ...]
// Redirect the payer to the returned checkout URL.
header('Location: '.$checkout['checkoutUrl']);
$checkout = $paylink->invoices->create([
'firstName' => 'John',
'lastName' => 'Doe',
'email' => '[email protected]',
'orderTitle' => 'Gold Plan',
'orderAmount' => '250.00',
'currency' => 'USD',
'iframe' => true, // embed the returned checkout URL in an <iframe>
]);
use Illuminate\Support\Facades\Log;
$paylink = new PaylinkClient(
publicToken: config('services.paylink.public_token'),
hashToken: config('services.paylink.hash_token'),
logger: Log::channel('paylink'),
);
use GetPayin\Paylink\Core\PaylinkClient;
use Illuminate\Http\RedirectResponse;
final class CheckoutController
{
public function __construct(
private readonly PaylinkClient $paylink,
) {}
public function store(): RedirectResponse
{
$checkout = $this->paylink->invoices->create([
'firstName' => 'John',
'lastName' => 'Doe',
'email' => '[email protected]',
'orderTitle' => 'Gold Plan',
'orderAmount' => '250.00',
'currency' => 'USD',
]);
return redirect()->away($checkout['checkoutUrl']);
}
}
use GetPayin\Paylink\Core\PaylinkClient;
use GetPayin\Paylink\Laravel\Facades\Paylink;
public function checkout(PaylinkClient $paylink)
{
return $paylink->invoices->create([/* ... */]);
}
Paylink::invoices()->create([/* ... */]);
$event = Paylink::webhooks()->verify(request()->getContent());
use GetPayin\Paylink\Laravel\LaravelHttpTransport;
$paylink = new PaylinkClient(
publicToken: config('paylink.public_token'),
hashToken: config('paylink.hash_token'),
transport: new LaravelHttpTransport(),
logger: Log::channel('paylink'),
);