PHP code example of superbrave / partnerize-bundle
1. Go to this page and download the library: Download superbrave/partnerize-bundle 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/ */
superbrave / partnerize-bundle example snippets
// app/AppKernel.php
// ...
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
// ...
new Superbrave\PartnerizeBundle\SuperbravePartnerizeBundle(),
);
// ...
}
// ...
}
public function createConversion(Sale $sale): string;
public function approveConversion(string $conversionId): Job;
public function rejectConversion(string $conversionId, string $reason): Job;
public function getJobUpdate(string $id): Job;
public function getJobResponse(string $id): Response;
class PartnerizeHandler
{
private $client;
public function __construct(Superbrave\PartnerizeBundle\Client\PartnerizeClient $client)
{
$this->client = $client;
}
public function sendConversionToPartnerize(): void
{
$item = new Superbrave\PartnerizeBundle\Model\Item('yourCategory', 1 /* quantity */);
$item->setProductBrand('productBrand');
$item->setProductName('productName');
$item->setProductType('productType');
$item->setSku('productSku');
$item->setValue(10.00);
$sale = new Superbrave\PartnerizeBundle\Model\Sale('yourClickReference', 'yourConversionReference');
$sale->setConversionTime(new \DateTime());
$sale->setCountry('NL');
$sale->setCurrency('EUR');
$sale->setCustomerReference('customer123456')
$sale->setCustomerType(Superbrave\PartnerizeBundle\Model\Sale::CUSTOMERTYPE_NEW);
$sale->setVoucher('yourVoucherCode');
$sale->addItem($item);
$conversionId = $this->client->createConversion($sale);
$job = $this->client->approveConversion($conversionId);
if ($job->getStatus() === Superbrave\PartnerizeBundle\Model\Job::STATUS_COMPLETE) {
$response = $this->client->getJobResponse($job->getJobId());
// Use $response->getErrors() and $response->getErrorsCount() to check for any errors
// Use $response->getConversionItems() to get the conversion that was approved, if it is
// empty your conversion was already approved (or rejected).
} else {
// Wait some time and check again with getJobUpdate()
}
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.