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

时间:2014-10-17 12:33:43

标签: symfony paypal doctrine-orm payum

我需要配置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

这是我启动付款流程的控制器操作

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. 

任何帮助或建议? 提前谢谢你

1 个答案:

答案 0 :(得分:1)

刚刚改变了这一行

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

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

现在可行。