1. Go to this page and download the library: Download yproximite/payum-system-pay 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/ */
yproximite / payum-system-pay example snippets
//config.php
use Payum\Core\PayumBuilder;
use Payum\Core\Payum;
/** @var Payum $payum */
$payum = (new PayumBuilder())
->addDefaultStorages()
->addGateway('gatewayName', [
'factory' => 'system_pay',
'vads_site_id' => 'change it', //
namespace App\Entity\Payment;
use Doctrine\ORM\Mapping as ORM;
use Payum\Core\Model\Payment as BasePayment;
/**
* @ORM\Table
* @ORM\Entity
*/
class Payment extends BasePayment
{
/**
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*
* @var int
*/
protected $id;
/**
* {@inheritdoc}
*/
public function getNumber()
{
return (string) $this->id;
}
}
class Payment extends BasePayment
{
// ...
/**
* @ORM\Column(type="integer", nullable=true)
*/
protected $partialAmount;
public function getPartialAmount(): ?int
{
return $this->partialAmount;
}
public function setPartialAmount(?int $partialAmount): void
{
$this->partialAmount = $partialAmount;
}
}
use App\Entity\Payment;
use Yproximite\Payum\SystemPay\Api;
use Yproximite\Payum\SystemPay\PaymentConfigGenerator;
// Define the periods
$periods = [
['amount' => 1000, 'date' => new \DateTime()],
['amount' => 2000, 'date' => (new \DateTime())->add(new \DateInterval('P1M'))],
['amount' => 3000, 'date' => (new \DateTime())->add(new \DateInterval('P2M'))],
];
// Compute total amount
$totalAmount = array_sum(array_column($periods, 'amount'));
// Compute `paymentConfig` fields that will be sent to the API
// It will generates something like this: MULTI_EXT:20190102=1000;20190202=2000;20190302=3000
$paymentConfig = (new PaymentConfigGenerator())->generate($periods);
// Then create payments
$storage = $payum->getStorage(Payment::class);
$payments = [];
foreach ($periods as $period) {
$payment = $storage->create();
$payment->setTotalAmount($totalAmount);
$payment->setPartialAmount($period['amount']);
$details = $payment->getDetails();
$details[Api::FIELD_VADS_PAYMENT_CONFIG] = $generatedPaymentConfig;
$payment->setDetails($details);
$storage->update($payment);
$payments[] = $payment;
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.