PHP code example of nexi-checkout / php-payment-sdk
1. Go to this page and download the library: Download nexi-checkout/php-payment-sdk 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/ */
nexi-checkout / php-payment-sdk example snippets
use NexiCheckout\Factory\HttpClientFactory;
use NexiCheckout\Factory\PaymentApiFactory;
use NexiCheckout\Model\Request\Payment;
use NexiCheckout\Factory\Provider\HttpClientConfigurationProvider
$factory = new HttpClientFactory($psrClient, $psrFactory, $psrStreamFactory);
$provider = new HttpClientConfigurationProvider();
$api = (new PaymentApiFactory($factory, $provider))->create($secretKey, $isLiveMode);
// Hosted checkout
$hostedPayment = $api->createHostedPayment(new Payment(...));
// Embedded checkout
$embeddedPayment = $api->createEmbeddedPayment(new Payment(...));
// Subscription related calls
$subscriptionApi = (new PaymentApiFactory($factory, $provider))->createSubscriptionApi($secretKey, $isLiveMode);
$subscriptionApi->retrieveSubscription('d079718b-ff63-45dd-947b-4950c023750f');
use NexiCheckout\Model\Webhook\WebhookBuilder;
use Psr\Http\Message\StreamInterface;
/** @var StreamInterface $request */
$payload = $request->getContents();
$result = WebhookBuilder::fromJson($payload);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.