gpt4 book ai didi

symfony - payum symfony 2 bundle - 基本配置 - 存储

转载 作者:太空宇宙 更新时间:2023-11-03 16:29:23 27 4
gpt4 key购买 nike

我需要配置 payum 包,以便让客户处理 paypal 付款。

我刚刚关注了 getting started官方推荐,但我想还需要配置更多东西(也许我缺少在某处配置 PaymentDetails 的存储)。

我的配置文件如下:

**app/config.yml**
doctrine:

orm:
auto_generate_proxy_classes: true
entity_managers:
default:
mappings:
WebsiteDeviceBundle: ~
WebsiteOnePageBundle: ~
payum:
is_bundle: false
type: xml
dir: %kernel.root_dir%/../vendor/payum/payum/src/Payum/Core/Bridge/Doctrine/Resources/mapping
prefix: Payum\Core\Model
payum:
security:
token_storage:
Website\Bundle\DeviceBundle\Entity\PaymentToken: { doctrine: orm }
storages:
Website\Bundle\DeviceBundle\Entity\PaymentDetails: { doctrine: orm }

contexts:
express_euro:
paypal_express_checkout_nvp:
username: ''
password: ''
signature: ''
sandbox: true

这是我启动支付流程的 Controller 操作

public function prepareAction(){
$paymentName = 'express_euro';

$storage = $this->get('payum')->getStorage('Website\DeviceBundle\Entity\PaymentDetails');

$order = $storage->createModel();
$order->setNumber(uniqid());
$order->setCurrencyCode('EUR');
$order->setTotalAmount($this->view['user']->money);
$order->setDescrizione('annual account subscription');
$order->setUser($this->view['user']->getId());
$order->setCreatedAt(new \DateTime());
$order->setClientEmail($this->view['user']->getEmail());

$storage->updateModel($order);

$captureToken = $this->get('payum.security.token_storage')->createCaptureToken(
$paymentName,
$order,
'done' // the route to redirect after capture;
);

return $this->redirect($captureToken->getTargetUrl());
}

这是 PaymentDetails 类

<?php

namespace Website\Bundle\DeviceBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Payum\Core\Model\ArrayObject;

/**
* PaymentDetails
*
* @ORM\Table(name="PaymentDetails", indexes={@ORM\Index(name="user", columns={"user"})})
* @ORM\Entity(repositoryClass="Website\Bundle\DeviceBundle\Entity\PaymentsDetailsRepository")
*/
class PaymentDetails extends ArrayObject
{
/**
* @var string
*
* @ORM\Column(name="currency_code", type="string", length=255, nullable=false)
*/
private $currencyCode;

/**
* @var string
*
* @ORM\Column(name="description", type="text", nullable=true)
*/
private $description;

/**
* @var \DateTime
*
* @ORM\Column(name="created_at", type="datetime", nullable=true)
*/
private $createdAt;

/**
* @var integer
*
* @ORM\Column(name="number", type="integer", nullable=false)
*/
private $number;

/**
* @var integer
*
* @ORM\Column(name="total_amount", type="integer", nullable=false)
*/
private $totalAmount;

/**
* @var string
*
* @ORM\Column(name="client_email", type="text", nullable=false)
*/
private $clientEmail;

/**
* @var integer
*
* @ORM\Column(name="id", type="bigint")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;

/**
* @var \Website\Bundle\DeviceBundle\Entity\Users
*
* @ORM\ManyToOne(targetEntity="Website\Bundle\DeviceBundle\Entity\Users")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="user", referencedColumnName="id")
* })
*/
private $user;

当我获取 doneAction() url 时出现的错误是这样的

A storage for model Website\DeviceBundle\Entity\PaymentDetails was not registered. There are storages for next models: Website\Bundle\DeviceBundle\Entity\PaymentDetails. 

有什么帮助或建议吗?提前谢谢你

最佳答案

只是改变了这一行

$storage = $this->get('payum')->getStorage('Website\DeviceBundle\Entity\PaymentDetails');

进入

$storage = $this->get('payum')->getStorage('Website\Bundle\DeviceBundle\Entity\PaymentDetails');

现在可以了。

关于symfony - payum symfony 2 bundle - 基本配置 - 存储,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26425127/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com