我正在尝试使用paypal_pro_checkout获得payum,但我被困在prepare.php文件中:
<?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('foo@example.com');
$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());
?>
根据the docu of Payum,但是$ paymentClass我遇到了麻烦。他们没有在Paypal config.php中定义它,但没有定义它会引发错误。当我从入门示例中获取定义时(如上所述,我得到
致命错误:未捕获的Payum \ Core \ Exception \ InvalidArgumentException:未注册模型付款的存储空间。有下一个型号的存储:Payum \ Core \ Model \ Payment,Payum \ Core \ Model \ ArrayObject,Payum \ Core \ Model \ Payout。在C:\ Users \ User \ Desktop \ www \ payum_test \ vendor \ payum \ core \ Payum \ Core \ Registry \ AbstractRegistry.php
我在没有任何框架的情况下使用它,我不熟悉错误中提到的这些模型
答案 0 :(得分:0)
我了解$paymentClass
包含付款模型类。如果您使用标准的Payum模型,则可以为Payum\Core\Model\Payment
。否则-您自己的模型类-MyApp\Model\Payment