Payum / PayumLaravelPackage

Payum offers everything you need to work with payments. From simplest use cases to very advanced ones.
https://payum.forma-pro.com/
MIT License
122 stars 38 forks source link

Request GetHumanStatus{model: ArrayObject} is not supported on payment done controller #12

Closed ateixeira closed 10 years ago

ateixeira commented 10 years ago

Hello,

I'm working with the new 0.11.1 package (thanks for the corrections), and facing the above error on:

$status = new GetHumanStatus($token);
$payment->execute($status);

i.e.: I'm redirected from PaypalController on

return $captureToken->getTargetUrl(); 

to http://localhost:8000/csi/payment_done?payum_token=_lLGI4Mxk-UKX4FNUiyq0j94IrY_iLjRoMZfWc8Bdg0

I can see on my storage the files payum-model-_lLGI4Mxk-UKX4FNUiyq0j94IrY_iLjRoMZfWc8Bdg0 and payum-model-5417d0934a306

The $token resultant from

$request = \App::make('request');
$request->attributes->set('payum_token', $payum_token);
$token = $this->getHttpRequestVerifier()->verify($request);

Gives me the result:

$token->getDetails() = Payum\Core\Model\ArrayObject#5417d0934a306
$token->getHash() = _lLGI4Mxk-UKX4FNUiyq0j94IrY_iLjRoMZfWc8Bdg0
$token->getPaymentName() = paypal-pro

If I try to reach payment_done controller with an invalid payum_token, it gives the error: A token with hash _lLGI4Mxk-UKX4FNUiyq0j94IrY_iLjRoMZfWc8Bdg1 could not be found. and if I try it with a valid token the Request GetHumanStatus{model: ArrayObject} is not supported. As I can see on storage a token with equivalent $token details arrayobject ID, I guess my $payments is not properly constructed on config.php.

Can you guys give me a hint on how to validate it?

Regards

makasim commented 10 years ago

Could you please post your models, configs and etc

ateixeira commented 10 years ago

Hello Makasim,

This is my config.php

<?php

use Payum\Core\Storage\FilesystemStorage;

use Buzz\Client\Curl;
use Payum\Paypal\ProCheckout\Nvp\PaymentFactory as PaypalProPaymentFactory;
use Payum\Paypal\ProCheckout\Nvp\Api as PaypalProApi;

$detailsClass = 'Payum\Core\Model\ArrayObject';
$tokenClass = 'Payum\Core\Model\Token';

$payments['paypal-pro'] = PaypalProPaymentFactory::create(new PaypalProApi(
    new Curl,
    array(
        'username' => 'xxxxx',
        'password' => 'xxxxx',
        'partner' => 'xxxxx',
        'vendor' => 'xxxxx',
        'sandbox' => true
    )
));

return array(
    // You can pass on object or a service id from container.
    'token_storage' => new FilesystemStorage(__DIR__.'/../../../../../storage/payments', $tokenClass, 'hash'),
    'payments' => $payments,
    'storages' => array(
        $detailsClass => new FilesystemStorage(__DIR__.'/../../../../../storage/payments', $detailsClass),
    )
);

My PaypalController where I still have stub payment data

<?php namespace DeansHomer\Controllers;
// app/controllers/PaypalController.php

use Payum\Core\Security\SensitiveValue;

use \Redirect;
use \Log;

class PaypalController extends BaseController
{
    public function prepareCheckout()
    {
        $storage = \App::make('payum')->getStorage('Payum\Core\Model\ArrayObject');

        $paymentDetails = $storage->createModel();
        $paymentDetails['CURRENCY'] = 'USD';
        $paymentDetails['AMT'] = '0.01';
        $paymentDetails['ACCT'] = '5105105105105100';
        $paymentDetails['EXPDATE'] = '1214';
        $paymentDetails['CVV2'] = '123';
        $paymentDetails['billtofirstname'] = 'MyFirstName';
        $paymentDetails['billtolastname'] = 'Test';
        $paymentDetails['billtostreet'] = '123 Main St.';
        $paymentDetails['billtocity'] = 'San Jose';
        $paymentDetails['billtostate'] = 'CA';
        $paymentDetails['billtozip'] = '95101';
        $paymentDetails['billtocountry'] = 'US';
        $storage->updateModel($paymentDetails);

        $captureToken = \App::make('payum.security.token_factory')->createCaptureToken('paypal-pro', $paymentDetails, 'csi/payment_done');

        // return $captureToken->getTargetUrl();
        return Redirect::to($captureToken->getTargetUrl());
    }
}

And the payment_done controller

<?php namespace DeansHomer\Controllers;

use Payum\Core\Registry\RegistryInterface;
use Payum\Core\Request\GetHumanStatus;
use Payum\Core\Security\HttpRequestVerifierInterface;
use Symfony\Component\HttpFoundation\Request;

use \Input;
use \Log;

class PaymentController extends BaseController
{
    public function done()
    {

        $payum_token = urldecode(Input::get('payum_token'));

        /** @var Request $request */
        $request = \App::make('request');
        $request->attributes->set('payum_token', $payum_token);

        $token = $this->getHttpRequestVerifier()->verify($request);
        $payment = $this->getPayum()->getPayment($token->getPaymentName());

        $status = new GetHumanStatus($token);

        $payment->execute($status);

        return \Response::json(array(
            'status' => $status->getStatus(),
            'details' => iterator_to_array($status->getModel())
        ));
    }
makasim commented 10 years ago

I cannot find any bugs, everything looks correct.

makasim commented 10 years ago

there was a bug in the lib, again. Fixed it https://github.com/Payum/Payum/commit/0507dea8271a66a30a500638a7a0adbc3067dad8

I am going to tag this now

makasim commented 10 years ago

has to fixed in: https://github.com/Payum/Payum/releases/tag/0.11.2 and https://github.com/Payum/PaypalProCheckoutNvp/releases/tag/0.11.2

shoaibgits commented 7 years ago

I got the error: Request GetHumanStatus{model: ArrayObject} is not supported. while using the Sofort payment method