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

RedsysBundle: Error creating UrlOK to complete the process #10

Closed
mashware opened this issue Dec 10, 2014 · 7 comments
Closed

RedsysBundle: Error creating UrlOK to complete the process #10

mashware opened this issue Dec 10, 2014 · 7 comments

Comments

@mashware
Copy link
Contributor

 # Configuration for payment success redirection
    #
    # Route defines which route will redirect if payment successes
    # If order_append is true, Bundle will append card identifier into route
    #    taking order_append_field value as parameter name and
    #    PaymentOrderWrapper->getOrderId() value
    payment_success:
        route: card_thanks
        order_append: true
        order_append_field: order_id

When you click on 'Next' to finish the payment at the TPV is:
https://sis-t.redsys.es:25443/sis/card_thanks

Sorry for my GoogleIngles

@mmoreram
Copy link
Contributor

@mashware Hi! Are you working with this bundle? Are you testing it?

This issue is because, somewhere, instead of generating the route with the name of card_thanks, the route /card_thanks is set.

@mmoreram
Copy link
Contributor

@mashware BTW, Thanks for the feedback :)

@mashware
Copy link
Contributor Author

@mmoreram I'm seeing how it works to use it on a website.
The documentation is somewhat sparse (for me) and I do not know if I'm doing well:

Events

use PaymentSuite\PaymentCoreBundle\Services\Interfaces\PaymentBridgeInterface;

class PaymentBridge implements PaymentBridgeInterface {

    /**
     * @var Object
     *
     * Order object
     */
    private $order;

    /**
     * @var integer
     *
     */
    private $amount;

    /**
     * @var string
     *
     */
    private $orderNumber;

    public function getPaymentName()
    {
        return 'redsys';
    }


    /**
     * Set order to PaymentBridge
     *
     * @var Object $order Order element
     */
    public function setOrder($order)
    {
        $this->order = $order;
    }

    /**
     * Return order
     *
     * @return Object order
     */
    public function getOrder()
    {
        return $this->order;
    }

    /**
     * Return order identifier value
     *
     * @return integer
     */
    public function getOrderId()
    {
        return $this->order->getId();
    }

    /**
     * Given an id, find Order
     *
     * @param int $orderId
     * @return Object order
     */
    public function findOrder($orderId)
    {
        /*
        * Your code to get Order
        */

        return $this->order;
    }

    /**
     * Get the currency in which the order is paid
     *
     * @return string
     */
    public function getCurrency()
    {
        /*
        * Set your static or dynamic currency
        */

        return 'EUR'; //EUR
    }

    /**
     * Get total order amount in cents
     *
     * @return integer
     */
    public function getAmount()
    {
        /*
        * Return payment amount (in cents)
        */

        return $this->amount;
    }

    public function setAmount($amount)
    {
        $this->amount = $amount;

        return $this;
    }

    /**
     * Return if order has already been paid
     *
     * @return boolean
     */
    public function isOrderPaid()
    {
        return array();
    }

    /**
     * Get extra data
     *
     * @return array
     */
    public function getExtraData()
    {
        return array('terminal' => '001');
    }

    /**
     * @return string
     */
    public function getOrderNumber()
    {
        return $this->orderNumber;
    }

    /**
     * @param $orderNumber
     * @return $this
     */
    public function setOrderNumber($orderNumber)
    {
        $this->orderNumber = $orderNumber;
        return $this;
    }
} 

EventListener

 public function onPaymentOrderLoad(PaymentOrderLoadEvent $paymentOrderLoadEvent)
    {
        $pedido = new Pedido();
        $pedido->setTotal(200);

        $this->entityManager->persist($pedido);
        $this->entityManager->flush();

        $paymentBridge = $paymentOrderLoadEvent->getPaymentBridge();

        $paymentBridge->setOrder($pedido);
        $paymentBridge->setAmount($pedido->getTotal());
        $paymentBridge->setOrderNumber('000'.$pedido->getId());
    }
/**
     * On payment order created event
     *
     * @param PaymentOrderCreatedEvent $paymentOrderCreatedEvent Payment Order Created event
     */
    public function onPaymentOrderCreated(PaymentOrderCreatedEvent $paymentOrderCreatedEvent)
    {

    }

    /**
     * On payment done event
     *
     * @param PaymentOrderDoneEvent $paymentOrderDoneEvent Payment Order Done event
     */
    public function onPaymentOrderDone(PaymentOrderDoneEvent $paymentOrderDoneEvent)
    {

    }

    /**
     * On payment success event
     *
     * @param PaymentOrderSuccessEvent $paymentOrderSuccessEvent Payment Order Success event
     */
    public function onPaymentOrderSuccess(PaymentOrderSuccessEvent $paymentOrderSuccessEvent)
    {

    }

    /**
     * On payment fail event
     *
     * @param PaymentOrderFailEvent $paymentOrderFailEvent Payment Order Fail event
     */
    public function onPaymentOrderFail(PaymentOrderFailEvent $paymentOrderFailEvent)
    {

    }

Services

payment.bridge:
        class: Escuela\PaymentBridgeBundle\Services\PaymentBridge

    payment.event.listener:
        class:     Escuela\PaymentBridgeBundle\EventListener\Payment
        arguments: [@doctrine.orm.entity_manager]
        tags:
            - { name: kernel.event_listener, event: payment.order.done, method: onPaymentOrderDone }
            - { name: kernel.event_listener, event: payment.order.created, method: onPaymentOrderCreated }
            - { name: kernel.event_listener, event: payment.order.load, method: onPaymentOrderLoad }
            - { name: kernel.event_listener, event: payment.order.success, method: onPaymentOrderSuccess }
            - { name: kernel.event_listener, event: payment.order.fail, method: onPaymentOrderFail }

@mashware
Copy link
Contributor Author

From what I've seen of Bundle (I do not know if it has anything to do, I will not say if it helps) is that in the "PaymentSuite\RedsysBundle\Services\Wrapper\RedsysFormTypeWrapper", line 173 and 174 file is assigned directly config value instead of generating routes:

->add('Ds_Merchant_UrlOK', 'hidden', array(
                'data' => $this->Ds_Merchant_UrlOK,
            ))
->add('Ds_Merchant_UrlKO', 'hidden', array(
                'data' => $this->Ds_Merchant_UrlKO,
            ))

Config

 payment_success:
        route: card_thanks
        order_append: true
        order_append_field: order_id
  payment_fail:
        route: card_view
        order_append: false
        order_append_field: card_id

in the debug I see:

$this->Ds_Merchant_UrlOK = card_thanks
$this->Ds_Merchant_UrlKO = card_view

I guess this is where they generate the routes opened and not directly assign the value of config.

@mashware
Copy link
Contributor Author

Hello, any news on this? or do I put the full url in the config directly?

@mickaelandrieu
Copy link
Contributor

Hello,

it's a bug, in PaymentSuite\RedsysBundle\Services\Wrapper\RedsysFormTypeWrapper
you need UrlGenerator as service dependency.

Take a look at we have done on PaypalWebCheckoutBundle => https://github.com/PaymentSuite/PaypalWebCheckoutBundle/blob/master/Services/Wrapper/PaypalFormTypeWrapper.php

Then you can generate the correct url /c @mmoreram

@mashware
Copy link
Contributor Author

Hello again,
to put into setting the value controller_result_route also generates the route.

Pd: @mickaelandrieu: Sorry but still find myself not able to make such modifications.

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