payum symfony 2束 - 基本配置 - 存储 [英] payum symfony 2 bundle - basic configuration - storage

查看:214
本文介绍了payum symfony 2束 - 基本配置 - 存储的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要配置payum包,以便客户端处理支付宝付款。

I need to configure the payum bundle in order to let clients process paypal payments.

我只是按照入门官方推荐,但是需要配置更多的东西,我猜(也许我没有在某个地方配置付款方式的存储)。

I just followed the getting started official recomendations, but need to configure something more, I guess (maybe I am missing to configure the storage for PaymentDetails somewhere).

我的配置文件如下:

**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

这是我的控制器操作来开始付款过程

this is my controller action to start the payment process

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类

and this is PaymentDetails class

<?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时,它出现的错误是这个

and the error it comes when I GET the doneAction() url, is this

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

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

any helps or suggestions? thank you in advance

推荐答案

只是改变了这一行

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

into

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

现在可以使用。

这篇关于payum symfony 2束 - 基本配置 - 存储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆