I am trying to get payum to work with paypal_pro_checkout, but I am stuck in the prepare.php file:
<?php
//config.php
include 'vendor/autoload.php';
use Payum\Core\PayumBuilder;
use Payum\Core\Payum;
$paymentClass = Payment::class;
/** @var Payum $payum */
$payum = (new PayumBuilder())
->addDefaultStorages()
->addGateway('gatewayName', [
'factory' => 'paypal_pro_checkout',
'username' => 'REPLACE IT',
'password' => 'REPLACE IT',
'partner' => 'REPLACE IT',
'vendor' => 'REPLACE IT',
'tender' => 'REPLACE IT',
'sandbox' => true
])
->getPayum()
;
<?php
// prepare.php
include __DIR__.'/config.php';
$gatewayName = 'paypal_pro_checkout';
/** @var \Payum\Core\Payum $payum */
$storage = $payum->getStorage($paymentClass);
$payment = $storage->create();
$payment->setNumber(uniqid());
$payment->setCurrencyCode('EUR');
$payment->setTotalAmount(123); // 1.23 EUR
$payment->setDescription('A description');
$payment->setClientId('anId');
$payment->setClientEmail('[email protected]');
$payment->setDetails(array(
// put here any fields in a gateway format.
// for example if you use Paypal ExpressCheckout you can define a description of the first item:
// 'L_PAYMENTREQUEST_0_DESC0' => 'A desc',
));
$storage->update($payment);
$captureToken = $payum->getTokenFactory()->createCaptureToken($gatewayName, $payment, 'done.php');
header("Location: ".$captureToken->getTargetUrl());
?>
This is according to the docu of Payum but with $paymentClass I run into trouble. They did not define it in the Paypal config.php, but not defining it throws an error. When I take the definition from the getting started example (as above in config, I get
Fatal error: Uncaught Payum\Core\Exception\InvalidArgumentException: A storage for model Payment was not registered. There are storages for next models: Payum\Core\Model\Payment, Payum\Core\Model\ArrayObject, Payum\Core\Model\Payout. in C:\Users\User\Desktop\www\payum_test\vendor\payum\core\Payum\Core\Registry\AbstractRegistry.php
I am using this without any framework and I am not familiar with theses Models mentioned in the error
I understand
$paymentClasscontains the payment model class. If you use standard Payum models then it can bePayum\Core\Model\Payment. Otherwise - your own model class -MyApp\Model\Payment