Payum - PaymentDetails object in done action where is

旧街凉风 提交于 2019-12-25 12:38:09

问题


im on done aciton and dont know how to get paymentDetails object...

here is manual : http://payum.forma-dev.com/documentation/0.8/PayumBundle/purchase_done_action

i try get object PaymentDetails from step before 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);

give

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

回答1:


Payum\Core\Model\Identificator is expected result. There two ways to get details:

  1. Using storage:

    <?php
    $registry = $this->get('payum');
    $storage = $registry->getStorageForClass(
        $token->getDetails()->getClass(), 
        $token->getPaymentName()
    );
    
    $details = $storage->findModelByIdentificator($token->getDetails());
    
  2. Executing a request. Here StorageExtension will set it to the request.

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



回答2:


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

if you are using 0.13 then make sure to include the use Payum\Core\Request\GetHumanStatus; in order to get the human readable status. To do it in 0.13 use the code provided in the documentation

here is a code example

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


来源:https://stackoverflow.com/questions/21313775/payum-paymentdetails-object-in-done-action-where-is

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!