I want to use the PayumLaravelPackage with Payum/Payex , I followed the documentation here and tried to do a purchase,
every thing done well, But when I am redirected to:
http://project.dev:8000/en/payment/done/PMFgtu2IOoEWUTRZhF95slwNw95mDW5B6cF826J-fi8
, an error is triggered:
Request GetHumanStatus{model: ArrayObject} is not supported. Make sure the gateway supports the requests and there is an action which supports this request (The method returns true). There may be a bug, so look for a related issue on the issue tracker.
,,
my AppServiceProvider is:
public function register()
{
$this->app->resolving('payum.builder', function(\Payum\Core\PayumBuilder $payumBuilder) {
$payumBuilder
// this method registers filesystem storages, consider to change them to something more
// sophisticated, like eloquent storage
->addDefaultStorages()
->addGateway('payex', [
'factory' => 'payex',
'account_number' => 'my account number',
'encryption_key' => 'my key',
'sandbox' => true
]);
});
}
and my Payment Controller :
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Payum\Core\Request\GetHumanStatus;
use Payum\LaravelPackage\Controller\PayumController;
class PaymentController extends PayumController
{
public function done($payum_token, Request $request)
{
$request->attributes->set('payum_token', $payum_token);
$token = $this->getPayum()->getHttpRequestVerifier()->verify($request);
$gateway = $this->getPayum()->getGateway($token->getGatewayName());
$gateway->execute($status = new GetHumanStatus($token));
return response([
'status' => $status->getValue(),
'details' => iterator_to_array($status->getFirstModel())
]);
}
public function captureDoneAction(Request $request)
{
$token = $this->get('payum')->getHttpRequestVerifier()->verify($request);
$identity = $token->getDetails();
$model = $this->get('payum')->getStorage($identity->getClass())->find($identity);
$gateway = $this->get('payum')->getGateway($token->getGatewayName());
// you can invalidate the token. The url could not be requested any more.
// $this->get('payum')->getHttpRequestVerifier()->invalidate($token);
// Once you have token you can get the model from the storage directly.
//$identity = $token->getDetails();
//$details = $payum->getStorage($identity->getClass())->find($identity);
// or Payum can fetch the model for you while executing a request (Preferred).
$gateway->execute($status = new GetHumanStatus($token));
$details = $status->getFirstModel();
// you have order and payment status
// so you can do whatever you want for example you can just print status and payment details.
return new JsonResponse(array(
'status' => $status->getValue(),
'details' => iterator_to_array($details),
));
}
}
and that is my Payex Controller:
namespace App\Http\Controllers;
use App\Http\Requests;
use Illuminate\Http\Request;
use Payum\Payex\Api\OrderApi;
use Payum\LaravelPackage\Controller\PayumController;
use App\Http\Controllers\OrdersController as OrdersCart;
class PayexController extends PayumController
{
public $cart;
public function __construct(OrdersCart $ordersCart)
{
$this->cart = $ordersCart;
}
public function preparePayex( Request $request)
{
$storage = $this->getPayum()->getStorage('Payum\Core\Model\ArrayObject');
$details = $storage->create();
$details['price'] = $this->cart->updateCartTotalPrice($this->cart->currentCart);
$details['priceArgList'] = '';
$details['vat'] = 0;
$details['currency'] = 'SEK';
$details['orderId'] = $this->cart->currentCart;
$details['productNumber'] = $this->cart->currentCart;
$details['purchaseOperation'] = OrderApi::PURCHASEOPERATION_AUTHORIZATION;
$details['view'] = OrderApi::VIEW_CREDITCARD;
$details['description'] = '';
$details['clientIPAddress'] = $request->getClientIp();
$details['clientIdentifier'] = '';
$details['additionalValues'] = '';
$details['agreementRef'] = '';
$details['clientLanguage'] = 'en-US';
$storage->update($details);
$captureToken = $this->getPayum()->getTokenFactory()->createCaptureToken('payex', $details, 'payment_done');
$details['returnurl'] = $captureToken->getTargetUrl();
$details['cancelurl'] = $captureToken->getTargetUrl();
$storage->update($details);
return redirect($captureToken->getTargetUrl());
}
}
and i use laravel 5.2
This error is caused me a lot of boredom, so please some one help.