I am using Symfony and trying to send payment details to PayPal using PayumBundle, I got PayumBundle configured and I got it to work until getting redirected to paypal but no payment details were being sent so I searched on line and came across this question in SO and this is the exact blank information screen I am seeing.
Looking at the documentation that answer is pointing to I came up with the following piece of code but when I try to access to route that is calling the following prepare
Action. I run into an error
public function prepareAction(Request $request)
{
$paymentName = 'paypal';
$storage = $this->getPayum()->getStorage('ClickTeck\featuresBundle\Entity\Orders');
/** @var \ClickTeck\featuresBundle\Entity\Orders $paymentDetails */
$paymentDetails = $storage->create();
$paymentDetails['PAYMENTREQUEST_0_CURRENCYCODE'] = 'USD';
$paymentDetails['PAYMENTREQUEST_0_AMT'] = 1500;
$storage->update($paymentDetails);
$notifyToken = $this->getTokenFactory()->createNotifyToken($paymentName, $paymentDetails);
$captureToken = $this->getTokenFactory()->createCaptureToken(
$paymentName,
$paymentDetails,
'payment_done'
);
$paymentDetails['PAYMENTREQUEST_0_NOTIFYURL'] = $notifyToken->getTargetUrl();
$paymentDetails['INVNUM'] = $paymentDetails->getId();
$storage->update($paymentDetails);
return $this->redirect($captureToken->getTargetUrl());
}
Error: Cannot use object of type ClickTeck\featuresBundle\Entity\Orders as array
I then tried using the following but that leads to another error at paypal end
$paymentDetails->PAYMENTREQUEST_0_CURRENCYCODE = 'USD';
$paymentDetails->PAYMENTREQUEST_0_AMT = 1500;
This transaction cannot be processed. The amount to be charged is zero
This is how my Order
Entity looks like
<?php
namespace ClickTeck\featuresBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Payum\Core\Model\Order as BaseOrder;
/**
* Orders
*/
class Orders extends BaseOrder
{
/**
* @var integer
*/
protected $id;
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
}
Can someone please help me find out what is this happening? Its been 2 days I am trying to make the PayumBundle work.
I will really appreciate any help in this. How do I send payment details to PayPal?