为Sofort集成创建模型,并从payum模块扩展付款对象,以便在捕获中使用它。
<?php
namespace Reisesparer\Model;
use Payum\Core\Model\Payment;
class SofortueberWeisung extends Payment
{
protected $id;
}
sofort的控制器方法如下所示:我创建了一个单独的模型,其中扩展到付款对象
public function sofortAction()
{
$storage = $this->getServiceLocator()->get('payum')->getStorage('Reisesparer\Model\SofortueberWeisung');
$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');
$storage->update($payment);
$captureToken = $this->getServiceLocator()->get('payum.security.token_factory')->createCaptureToken(
'sofort', $payment, 'payment_done'
);
// print_r($captureToken);
// exit();
$this->redirect()->toUrl($captureToken->getTargetUrl());
}
我的配置文件包含以下代码,用于配置项目中的payum / sofort方法。
'sofort' => $sofortFactory->create(array(
'factory' => 'sofort',
'config_key' => '12345:123456:edc788a4316ce7e2ac0ede037aa623d7',
)),
最后,我在成功付款后捕获有用信息的行动如下:
public function doneAction()
{
$token = $this->getServiceLocator()->get('payum.security.http_request_verifier')->verify($this);
$gateway = $this->getServiceLocator()->get('payum')->getgateway($token->getgatewayName());
$gateway->execute($status = new GetHumanStatus($token));
$payment = $status->getFirstModel();
$viewModel = new ViewModel(array('status' => $status->getValue(),'details'=>$payment));
$viewModel->setTemplate('layout/pay_done');
return $viewModel;
}
存储配置:
'storages' => array(
$detailsClass => new FilesystemStorage(__DIR__.'/../../data', $detailsClass, 'id'),
$paymentClass => new FilesystemStorage(__DIR__.'/../../data', $paymentClass, 'id'),
)
现在,当我继续使用软件支付方式来捕获付款时,它会给我带来错误,而不是继续进行。但另一种方法,如paypal,stripe和authorized.net在同一个项目中正常工作如何解决这个问题 错误:
Request GetHumanStatus{model: ArrayObject} is not supported.