Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue showing the description on paypal checkout #52

Closed
maximgeerinck opened this issue Oct 6, 2013 · 15 comments
Closed

Issue showing the description on paypal checkout #52

maximgeerinck opened this issue Oct 6, 2013 · 15 comments

Comments

@maximgeerinck
Copy link

I am trying to get a purchase to show its description, name and price but nothing is showing up, this is what i get on checkout

http://prntscr.com/1vp82e

The code i am using:

 public function onStorePay(StoreEvent $event)
    {
        ###############################
        # FORWARD TO PAYMENT PROCESSOR
        ###############################
        $paymentName = 'paypal_express_checkout_plus_doctrine';

        $item = $event->getItem();

        $data = array(
            "currency"  =>  "GBP",
            "amount"    =>  $item->getAmount(),
            "item_name" =>  $item->getName(),
            "item_number" => 1,

        );

        $storage = $this->container->get('payum')->getStorageForClass(
            'Maxim\CMSBundle\Entity\PaypalExpressPaymentDetails',
            $paymentName
        );

        /** @var $paymentDetails PaymentDetails */
        $paymentDetails = $storage->createModel();
        $paymentDetails->setPaymentrequestCurrencycode(0, $data['currency']);
        $paymentDetails->setPaymentrequestAmt(0,  $data['amount'] * 1);

        $paymentDetails->setNoshipping(Api::NOSHIPPING_NOT_DISPLAY_ADDRESS);
        $paymentDetails->setReqconfirmshipping(Api::REQCONFIRMSHIPPING_NOT_REQUIRED);
        $paymentDetails->setLPaymentrequestItemcategory(0, 0, Api::PAYMENTREQUEST_ITERMCATEGORY_DIGITAL);
        $paymentDetails->setLPaymentrequestAmt(0, 0, $data['amount']);
        $paymentDetails->setLPaymentrequestQty(0, 0, 1);
        $paymentDetails->setLPaymentrequestName(0, 0, $data['item_name']);
        $paymentDetails->setLPaymentrequestDesc(0, 0, $item->getDescription());

        $storage->updateModel($paymentDetails);

        $notifyToken = $this->token_factory->createNotifyToken($paymentName, $paymentDetails);

        $captureToken = $this->token_factory->createCaptureToken(
            $paymentName,
            $paymentDetails,
            'paypal_done'
        );

        $paymentDetails->setReturnurl($captureToken->getTargetUrl());
        $paymentDetails->setCancelurl($captureToken->getTargetUrl());
        $paymentDetails->setPaymentrequestNotifyurl(0, $notifyToken->getTargetUrl());
        $this->logger->err($notifyToken->getTargetUrl());
        $paymentDetails->setInvnum($paymentDetails->getId());
        $storage->updateModel($paymentDetails);

        $event->setCaptureToken($captureToken->getTargetUrl());
        return;
    }
```php
@makasim
Copy link
Member

makasim commented Oct 7, 2013

I suppose you use payment details mapped supper class (Like it is shown in the sandbox). So these fields does not have doctrine mapping by default.

<?php

        $paymentDetails->setLPaymentrequestItemcategory(0, 0, Api::PAYMENTREQUEST_ITERMCATEGORY_DIGITAL);
        $paymentDetails->setLPaymentrequestAmt(0, 0, $data['amount']);
        $paymentDetails->setLPaymentrequestQty(0, 0, 1);
        $paymentDetails->setLPaymentrequestName(0, 0, $data['item_name']);
        $paymentDetails->setLPaymentrequestDesc(0, 0, $item->getDescription());

And you have to add it to your model manually (just an example):

<?php
/**
 * @ORM\Entity
 */
class PaypalPaymentDetails extends PaymentDetails
{
    /**
     * @ORM\Column(type="json_array")
     */
    protected $l_paymentrequest_nnn_qtymmm = array();
}

@maximgeerinck
Copy link
Author

Thank you for your quick response, indeed that worked however now it's throwing me : "The model status must be new."

@makasim
Copy link
Member

makasim commented Oct 9, 2013

could you debug PaymentDetailsStatusAction action: where it marks request as new

@awdng
Copy link

awdng commented Oct 10, 2013

I have the same problems, i find the docs to be not very clear in some cases so its quite hard to get a grasp on how things are supposed to be done.

I have added an Item in my controller and now it direcs me directly to the captureDone action without showing paypal at all. It works fine if i remove the product info from the controller.

Controller

public function cgetAction(Request $request)
    {
        $paymentName = 'paypal_express_checkout_plus_doctrine';

        $storage = $this->get('payum')->getStorageForClass(
            'dubdng\PaymentBundle\Entity\PaypalExpressPaymentDetails',
            $paymentName
        );

        $paymentDetails = $storage->createModel();
        $paymentDetails->setPaymentrequestCurrencycode(0, 'EUR');

        $paymentDetails->setLPaymentrequestItemcategory(0, 0, Api::PAYMENTREQUEST_ITERMCATEGORY_DIGITAL);
        $paymentDetails->setLPaymentrequestAmt(0, 0, 99);
        $paymentDetails->setLPaymentrequestQty(0, 0, 1);
        $paymentDetails->setLPaymentrequestName(0, 0, 'text');
        $paymentDetails->setLPaymentrequestDesc(0, 0, 'desc');
        $paymentDetails->setPaymentrequestAmt(0, 99);

        $storage->updateModel($paymentDetails);

        $captureToken = $this->get('payum.security.token_factory')->createCaptureToken(
            $paymentName,
            $paymentDetails,
            'payment_paypal_done' // the route to redirect after capture;
        );

        $paymentDetails->setInvnum($paymentDetails->getId());
        $paymentDetails->setReturnurl($captureToken->getTargetUrl());
        $paymentDetails->setCancelurl($captureToken->getTargetUrl());

        $storage->updateModel($paymentDetails);

        return $this->redirect($captureToken->getTargetUrl());
    }

Entity

<?php
namespace dubdng\PaymentBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Payum\Paypal\ExpressCheckout\Nvp\Bridge\Doctrine\Entity\PaymentDetails;

/**
 * @ORM\Entity
 */
class PaypalExpressPaymentDetails extends PaymentDetails
{
    /**
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="IDENTITY")
     */
    protected $id;

    /**
     * @ORM\Column(type="json_array")
     */
    protected $l_paymentrequest_nnn_qtymmm = array();

    /**
     * @ORM\Column(type="json_array")
     */
    protected $l_paymentrequest_nnn_namemmm = array();

    /**
     * @ORM\Column(type="json_array")
     */
    protected $l_paymentrequest_nnn_descmmm = array();

    /**
     * @ORM\Column(type="json_array")
     */
    protected $l_paymentrequest_nnn_amtmmm = array();

    /**
     * @ORM\Column(type="json_array")
     */
    protected $l_paymentrequest_nnn_itemcategorymmm = array();
}

@makasim
Copy link
Member

makasim commented Oct 10, 2013

@awdng could you post what the payment details contains when you come to doneAction?

<?php
var_dump(iterator_to_array($paymentDetails));

@makasim
Copy link
Member

makasim commented Oct 10, 2013

you could help me improve docs

@maximgeerinck
Copy link
Author

I debugged my error, it's throwing this:

After paying:

[2013-10-11 20:37:51] app.DEBUG: [Payum] 1# Payum\Action\StatusDetailsAggregatedModelAction::execute(BinaryMaskStatusRequest{model: PayumSecurityToken}) [] []
[2013-10-11 20:37:51] app.DEBUG: [Payum] 2# Payum\Paypal\ExpressCheckout\Nvp\Action\PaymentDetailsStatusAction::execute(BinaryMaskStatusRequest{model: PaypalExpressPaymentDetails}) [] []
[2013-10-11 20:37:51] app.ERROR: [ERROR]: The model status must be new. with code: 0 [] []
[2013-10-11 20:37:51] security.DEBUG: Write SecurityContext in the session [] []

the checkout itsself (when getting redirected to paypal)

[2013-10-11 20:30:16] app.DEBUG: [Payum] 1# Payum\Action\StatusDetailsAggregatedModelAction::execute(BinaryMaskStatusRequest{model: PayumSecurityToken}) [] []
[2013-10-11 20:30:16] app.DEBUG: [Payum] 2# Payum\Paypal\ExpressCheckout\Nvp\Action\PaymentDetailsStatusAction::execute(BinaryMaskStatusRequest{model: PaypalExpressPaymentDetails}) [] []
[2013-10-11 20:30:16] app.DEBUG: [Payum] 1# Payum\Action\CaptureDetailsAggregatedModelAction::execute(SecuredCaptureRequest{model: PayumSecurityToken}) [] []
[2013-10-11 20:30:16] app.DEBUG: [Payum] 2# Payum\Paypal\ExpressCheckout\Nvp\Action\CaptureAction::execute(SecuredCaptureRequest{model: PaypalExpressPaymentDetails}) [] []
[2013-10-11 20:30:16] app.DEBUG: [Payum] 3# Payum\Paypal\ExpressCheckout\Nvp\Action\Api\SetExpressCheckoutAction::execute(SetExpressCheckoutRequest{model: ArrayObject}) [] []
[2013-10-11 20:30:17] app.DEBUG: [Payum] 3# Payum\Paypal\ExpressCheckout\Nvp\Action\Api\AuthorizeTokenAction::execute(AuthorizeTokenRequest{model: ArrayObject}) [] []
[2013-10-11 20:30:17] app.DEBUG: [Payum] 3# AuthorizeTokenAction::execute(AuthorizeTokenRequest{model: ArrayObject}) throws interactive RedirectUrlInteractiveRequest{url: https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-87481783VH369064X} [] []
[2013-10-11 20:30:17] app.DEBUG: [Payum] 2# CaptureAction::execute(SecuredCaptureRequest{model: PaypalExpressPaymentDetails}) throws interactive RedirectUrlInteractiveRequest{url: https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-87481783VH369064X} [] []
[2013-10-11 20:30:17] app.DEBUG: [Payum] 1# CaptureDetailsAggregatedModelAction::execute(SecuredCaptureRequest{model: PaypalExpressPaymentDetails}) throws interactive RedirectUrlInteractiveRequest{url: https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-87481783VH369064X} [] []

@maximgeerinck
Copy link
Author

Everything appears to be working when i set it to @dev release, however i don't receive any ipn calls anymore now

@makasim
Copy link
Member

makasim commented Oct 14, 2013

however i don't receive any ipn calls anymore now

this may be helpful if you are sure you setup it correctly: http://stackoverflow.com/questions/18556794/calling-ipn-paypal-payumbundle/18558813

@maximgeerinck
Copy link
Author

For people who are looking for my solution, make sure ipn is also enabled on the paypal side, you can also check if there are incomming ipn calls on the paypal ipn history. Thank you for the great support

@maximgeerinck
Copy link
Author

Still getting

[2013-10-18 22:09:35] app.DEBUG: [Payum] 1# Payum\Action\StatusDetailsAggregatedModelAction::execute(BinaryMaskStatusRequest{model: PayumSecurityToken}) [] []
[2013-10-18 22:09:35] app.DEBUG: [Payum] 2# Payum\Paypal\ExpressCheckout\Nvp\Action\PaymentDetailsStatusAction::execute(BinaryMaskStatusRequest{model: PaypalExpressPaymentDetails}) [] []
[2013-10-18 22:09:35] app.ERROR: [ERROR]: The model status must be new. with code: 0 [] []

It only seems to happen on some occassions

@maximgeerinck maximgeerinck reopened this Oct 18, 2013
@makasim
Copy link
Member

makasim commented Oct 19, 2013

@c4d3r I am completely sure you missed something. The sandbox is working. I also added paypal express checkout usage to Sylius E-Commerce Platform. That's work fine.

Are you sure you do not call capture for same model twice?

@maximgeerinck
Copy link
Author

Add the column: array for the 0.7 version

@manixx
Copy link

manixx commented Feb 20, 2014

I had the exact same problem. After the payment on PayPal I got the exception "The model status must be new.". After some debugging (or simply dumping the model) I found the error. Checkout the last lines of the model:

[storage:ArrayObject:private] => Array
        (
            [PAYMENTREQUEST_0_CURRENCYCODE] => EUR
            [PAYMENTREQUEST_0_AMT] => 24.7
            [L_PAYMENTREQUEST_0_NAME0] => Creme Gelée Royale für den Tag
            [L_PAYMENTREQUEST_0_NUMBER0] => 210
            [L_PAYMENTREQUEST_0_DESC0] => Diese schnell einziehende Tagescreme wird nicht nur zur täglichen Hautpflege eingesetzt, sondern ist vor allem auf Grund des hohen Anteils an Gelee Royale eine hervorragende Anti - Faltencreme. Sie ist revitalisierend und somit ein sicherer Schutz gegen unsere täglichen Umwelteinflüsse aus der Luft. CREME GELEE ROYALE stellt eine ideale Ergänzung zu unserer NACHTKERZENCREME dar
            [L_PAYMENTREQUEST_0_AMT0] => 8.30
            [L_PAYMENTREQUEST_0_QTY0] => 1
            [L_PAYMENTREQUEST_0_NAME1] => Akazienhonig
            [L_PAYMENTREQUEST_0_NUMBER1] => 184
            [L_PAYMENTREQUEST_0_DESC1] => 
            [L_PAYMENTREQUEST_0_AMT1] => 11.40
            [L_PAYMENTREQUEST_0_QTY1] => 1
            [L_PAYMENTREQUEST_0_NAME2] => Versandkosten
            [L_PAYMENTREQUEST_0_AMT2] => 5
            [INVNUM] => 103
            [RETURNURL] => http://localhost/~manixx/sinapura/web/app_dev.php/payment/capture/uMKz2HosJEXuWcKTm1VzltaVMwjJcsQP1s-7HlMvh-g
            [CANCELURL] => http://localhost/~manixx/sinapura/web/app_dev.php/payment/capture/uMKz2HosJEXuWcKTm1VzltaVMwjJcsQP1s-7HlMvh-g
            [PAYMENTREQUEST_0_PAYMENTACTION] => Sale
            [TOKEN] => EC-8FH00476JM2645404
            [TIMESTAMP] => 2014-02-20T07:56:12Z
            [CORRELATIONID] => 79790b1150481
            [ACK] => SuccessWithWarning
            [VERSION] => 65.1
            [BUILD] => 9720069
            [L_ERRORCODE0] => 11812
            [L_SHORTMESSAGE0] => Invalid Data
            [L_LONGMESSAGE0] => The value of Description parameter has been truncated.
            [L_SEVERITYCODE0] => Warning
        )

Therefore the description is too long. After i truncated it in the controller everthing works as excepted. Maybe this helps someone.

@makasim
Copy link
Member

makasim commented Feb 20, 2014

thanks for sharing this with us.

FYI: I am going to remove a check about payment status in capture controller.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants