PHP code example of unipayment / client
1. Go to this page and download the library: Download unipayment/client 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/ */
unipayment / client example snippets
$configuration = new \UniPayment\SDK\Configuration();
$configuration->setClientId('your client id');
$configuration->setClientSecret('your secret key');
$configuration->setAppId('your app id');
$configuration->setIsSandbox(false);
$configuration = new \UniPayment\SDK\Configuration();
$configuration->setClientId('your client id');
$configuration->setClientSecret('your secret key');
$configuration->setAppId('your app id');
$configuration->setIsSandbox(true);
$configuration->setDebug(true);
$createInvoiceRequest = new \UniPayment\SDK\Model\CreateInvoiceRequest();
$createInvoiceRequest->setAppId($configuration->getAppId());
$createInvoiceRequest->setOrderId(Uuid::uuid4());
$createInvoiceRequest->setPriceAmount(1.0);
$createInvoiceRequest->setPriceCurrency('USD');
$createInvoiceRequest->setLang("en");
$createInvoiceRequest->setExtArgs("Merchant Pass Through Data");
$billingAPI = new \UniPayment\SDK\BillingAPI($configuration);
try{
$createInvoiceResponse = $billingAPI->createInvoice($createInvoiceRequest);
} catch (\UniPayment\SDK\UnipaymentSDKException $e) {
...
}
use UniPayment\SDK\Utils\WebhookSignatureUtil;
//Use raw json payload (no formatting or pretty print)
$payload = 'json payload';
$secretKey = 'your secret key';
$signature = 'signature to verify';
$valid = WebhookSignatureUtil::isValid($payload, $secretKey, $signature);
bash
curl -sS https://getcomposer.org/installer | php