Payum - PaymentDetails对象在完成的操作中所在的位置

时间:2014-01-23 16:22:05

标签: php symfony payum

im on done aciton并且不知道如何获得paymentDetails对象......

这里是手册: http://payum.forma-dev.com/documentation/0.8/PayumBundle/purchase_done_action

我尝试从之前的步骤获取对象PaymentDetails http://payum.forma-dev.com/documentation/0.8/PayumBundle/simple_purchase_examples/paypal_express_checkout

UPDATE1

public function doneAction(){

    $request = $this->getRequest();

    /**
     * @var $token PayumSecurityToken
     */
    $token = $this->get('payum.security.http_request_verifier')->verify($request);

    /**
     * @var $details PaymentDetails
     */
    $details = $token->getDetails();


    var_dump($details);

object(Payum\Core\Model\Identificator)[345]
  protected 'class' => string 'ed\partnerBundle\Entity\PaymentDetails' (length=38)
  protected 'id' => int 1

UPDATE2

 $details = unserialize($token->getDetails());

ContextErrorException: Notice: unserialize(): Error at offset 0 of 40 bytes in /home/grek/public_html/edpartner/src/ed/partnerBundle/Controller/PaymentController.php line 110

2 个答案:

答案 0 :(得分:5)

Payum\Core\Model\Identificator是预期的结果。有两种获取细节的方法:

  1. 使用存储空间:

    <?php
    $registry = $this->get('payum');
    $storage = $registry->getStorageForClass(
        $token->getDetails()->getClass(), 
        $token->getPaymentName()
    );
    
    $details = $storage->findModelByIdentificator($token->getDetails());
    
  2. 执行请求。此处StorageExtension会将其设置为请求。

    <?php
    $status = new BinaryMaskStatusRequest($token);
    
    $this->get('payum')->getPayment($token->getPaymentName())->execute($status);
    
    $details = $status->getModel();
    

答案 1 :(得分:0)

<?php
$registry = $this->get('payum');
$storage = $registry->getStorage(
    $token->getDetails()->getClass(), 
    $token->getPaymentName()
);

如果您使用0.13,请确保包含使用Payum \ Core \ Request \ GetHumanStatus;为了获得人类可读的状态。要在0.13中执行此操作,请使用文档中提供的代码

这是一个代码示例

$token = $this->get('payum.security.http_request_verifier')->verify($request);
$payment = $this->get('payum')->getPayment($token->getPaymentName());
$status->getValue();