I configure PayumBundle in symfony2 but not work :)
im not redirected to paypal site.
i get error - 'error', 'Payment failed' where i can find some informations ?
Update 1
i foud error : in var_dump($status)
'L_SHORTMESSAGE0' => string 'Security error' (length=14) 'L_LONGMESSAGE0' => string 'Security header is not valid' (length=28)
when i turn off in config sandbox im redirected to paypal but i dont have filled amount , payment name - how to configure it ?
i configure it from this example http://payum.forma-dev.com/documentation/0.8/PayumBundle/simple_purchase_examples/paypal_express_checkout
config:
payum:
security:
token_storage:
ed\partnerBundle\Entity\PayumSecurityToken:
doctrine:
driver: orm
contexts:
frei_payment:
paypal_express_checkout_nvp:
api:
options:
username: 'myusername'
password: 'mypass'
signature: 'mysing'
sandbox: true
storages:
ed\partnerBundle\Entity\PaymentDetails:
doctrine:
driver: orm
routing :
payment_start:
pattern: /payment
defaults: { _controller: edpartnerBundle:Payment:preparePaypalExpressCheckoutPayment }
edpartner_payment_done:
pattern: /payment/done
defaults: { _controller: edpartnerBundle:Payment:done }
actions in Payment Controller:
public function doneAction(){
$request = $this->getRequest();
$token = $this->get('payum.security.http_request_verifier')->verify($request);
$payment = $this->get('payum')->getPayment($token->getPaymentName());
$status = new BinaryMaskStatusRequest($token);
$payment->execute($status);
if ($status->isSuccess()) {
$this->getUser()->addCredits(100);
$this->getRequest()->getSession()->getFlashBag()->set(
'notice',
'Payment success. Credits were added'
);
} else if ($status->isPending()) {
$this->getRequest()->getSession()->getFlashBag()->set(
'notice',
'Payment is still pending. Credits were not added'
);
} else {
$this->getRequest()->getSession()->getFlashBag()->set('error', 'Payment failed');
}
return $this->redirect('homepage');
}
/**
*/
public function preparePaypalExpressCheckoutPaymentAction(){
$paymentName = 'my_payment';
$storage = $this->get('payum')->getStorageForClass(
'ed\partnerBundle\Entity\PaymentDetails',
$paymentName
);
/** @var \ed\partnerBundle\Entity\PaymentDetails $paymentDetails */
$paymentDetails = $storage->createModel();
$paymentDetails['PAYMENTREQUEST_0_CURRENCYCODE'] = 'USD';
$paymentDetails['PAYMENTREQUEST_0_AMT'] = 1.23;
$storage->updateModel($paymentDetails);
$captureToken = $this->get('payum.security.token_factory')->createCaptureToken(
$paymentName,
$paymentDetails,
'edpartner_payment_done' // the route to redirect after capture;
);
$paymentDetails['INVNUM'] = $paymentDetails->getId();
$paymentDetails['RETURNURL'] = $captureToken->getTargetUrl();
$paymentDetails['CANCELURL'] = $captureToken->getTargetUrl();
$storage->updateModel($paymentDetails);
return $this->redirect($captureToken->getTargetUrl());
}
i go to /payment url in browser and im redirected to homepage i see new records in database - but i dont make any payment - why im not redirected to paypal for payment ?
Ok in found error - this is sandbox error - normal api key - dont allow sandbox mode - a pity that it is not described in bundle install manual - and a the bundle dont throw any exception - simple redirect without info...