Sylius: Creating payment methods

Created on 30 Sep 2016  路  14Comments  路  Source: Sylius/Sylius

Hi guys, i'm getting problems to create additional payment methods.

I need to add Paypal express checkout and Redsys gateways.

I did this config

payum:
    gateways:
        paypal_express_checkout:
            factory: "paypal_express_checkout"
            payum.http_client: "@sylius.payum.http_client"
            username: "***"
            password: "***"
            signature: "***"
            sandbox: "true"


sylius_payment:
    gateways:
        cc: Redsys
        paypal_express_checkout: Paypal Express Checkout

Now i can add both gateways on admin section but i didn't see those on select payment method in cart steps.

I'm doing something wrong?

Help Wanted

Most helpful comment

Have a look to freshly updated documentation here :)
https://github.com/Sylius/Sylius/pull/6250/files

or here, it's merged now http://docs.sylius.org/en/latest/cookbook/paypal.html

All 14 comments

You need to enable them in channel. See https://github.com/Sylius/Sylius/pull/6250 for more info about adding payment methods.

Have a look to freshly updated documentation here :)
https://github.com/Sylius/Sylius/pull/6250/files

or here, it's merged now http://docs.sylius.org/en/latest/cookbook/paypal.html

Oh thanks, now i can select the methods on cart actions but now i think found a bug.

Sylius doesn't redirect me to Paypal platform, it jumps from summary to thank-you controller. It's normal?

When you finalize your order, you only move the sylius_order_checkout state machine to completed.

It triggers a lot of state_machine callbacks such as moving sylius_order_payment from CART to AWAITING_PAYMENT (see state_machine.yml in the Core).

Thus Your Checkout is completed, but not your order. Your customer have to pay (in one or multiple payments) and you have to ship the products (in one or multiple shipments).

Once all your payments & shipments are finalized, there is a callback that move your order to fulfilled (discussion here).

@bretto36 answered to a similar question on moving directly to Payment after checkout is done here

I don't understand very well the checkout process.

According to my logic before showing the user a message of thanks, he should pay the order.

I followed the thread that you've linked of @bretto36 and when I'll end buying Sylius enters a loop of redirects that goes through 3 URLs infinitely.

Walking flow is: Thank-you -> Pay -> Capture -> Thank-you -> Pay ... until the browser throws me error too many redirects.

Can you post the code you've added to the thank you action? You need to make sure you are checking if payment has already been taken, if it has then don't redirect anymore

Yes of course @bretto36

  public function thankYouAction(Request $request)
    {
        $configuration = $this->requestConfigurationFactory->create($this->metadata, $request);

        $orderId = $this->getSession()->get('sylius_order_id');
        Assert::notNull($orderId);
        $order = $this->repository->findOneForPayment($orderId);
        Assert::notNull($order);

        $payment = $order->getLastPayment();


        if (null !== $payment  && $order->getTotal() > 0 && $order->getPaymentState() != OrderPaymentStates::STATE_PAID && $payment->getMethod()->getGateway() != 'offline') {
            return $this->redirectToRoute('sylius_shop_order_pay', ['orderId' => $orderId]);
        }

        return $this->render($configuration->getParameters()->get('template'), ['order' => $order]);
    }

This is likely due to having an outdated version of Sylius?

@bnd170 the thank you page was reworked in https://github.com/Sylius/Sylius/pull/6104. The previous logic was not exactly good. Please get familiar with the new workflow 馃槈

@michalmarcinkowski Thanks for respose, i did composer update but i didn't see any Sylius update. I got this dependencies on composer.json:

"replace": {
"sylius/addressing": "1.0.x-dev",
"sylius/addressing-bundle": "1.0.x-dev",
"sylius/admin-bundle": "1.0.x-dev",
"sylius/api-bundle": "1.0.x-dev",
"sylius/archetype": "1.0.x-dev",
"sylius/archetype-bundle": "1.0.x-dev",
"sylius/attribute": "1.0.x-dev",
"sylius/attribute-bundle": "1.0.x-dev",
"sylius/cart": "1.0.x-dev",
"sylius/cart-bundle": "1.0.x-dev",
"sylius/contact": "1.0.x-dev",
"sylius/contact-bundle": "1.0.x-dev",
"sylius/content-bundle": "1.0.x-dev",
"sylius/core": "1.0.x-dev",
"sylius/core-bundle": "1.0.x-dev",
"sylius/currency": "1.0.x-dev",
"sylius/currency-bundle": "1.0.x-dev",
"sylius/customer": "1.0.x-dev",
"sylius/customer-bundle": "1.0.x-dev",
"sylius/fixtures-bundle": "1.0.x-dev",
"sylius/flow-bundle": "1.0.x-dev",
"sylius/installer-bundle": "1.0.x-dev",
"sylius/inventory": "1.0.x-dev",
"sylius/inventory-bundle": "1.0.x-dev",
"sylius/locale": "1.0.x-dev",
"sylius/locale-bundle": "1.0.x-dev",
"sylius/money-bundle": "1.0.x-dev",
"sylius/order": "1.0.x-dev",
"sylius/order-bundle": "1.0.x-dev",
"sylius/payment": "1.0.x-dev",
"sylius/payment-bundle": "1.0.x-dev",
"sylius/payum-bundle": "1.0.x-dev",
"sylius/pricing": "1.0.x-dev",
"sylius/pricing-bundle": "1.0.x-dev",
"sylius/product": "1.0.x-dev",
"sylius/product-bundle": "1.0.x-dev",
"sylius/promotion": "1.0.x-dev",
"sylius/promotion-bundle": "1.0.x-dev",
"sylius/rbac": "1.0.x-dev",
"sylius/rbac-bundle": "1.0.x-dev",
"sylius/registry": "1.0.x-dev",
"sylius/report": "1.0.x-dev",
"sylius/report-bundle": "1.0.x-dev",
"sylius/resource": "1.0.x-dev",
"sylius/resource-bundle": "1.0.x-dev",
"sylius/search-bundle": "1.0.x-dev",
"sylius/settings-bundle": "1.0.x-dev",
"sylius/shipping": "1.0.x-dev",
"sylius/shipping-bundle": "1.0.x-dev",
"sylius/storage": "1.0.x-dev",
"sylius/taxation": "1.0.x-dev",
"sylius/taxation-bundle": "1.0.x-dev",
"sylius/taxonomy": "1.0.x-dev",
"sylius/taxonomy-bundle": "1.0.x-dev",
"sylius/theme-bundle": "1.0.x-dev",
"sylius/ui-bundle": "1.0.x-dev",
"sylius/user": "1.0.x-dev",
"sylius/user-bundle": "1.0.x-dev",
"sylius/variation": "1.0.x-dev",
"sylius/variation-bundle": "1.0.x-dev",
"sylius/web-bundle": "1.0.x-dev"
},

There are correct? I need to execute sylius:install to get the new workflow?

Seems you are one the sylius-standard edition, not sylius one. The first one is more stable, but does not have latests updates.

No, im sure about I have Sylius/Sylius because Sylius-standard doesn't install de newest looks

Thats weird cause at least the sylius/archetype & sylius/archetype-bundles where removed from the 1.0.x-dev

Well, i'll wait for someone that can help me. Thanks a lot @ylastapis

Looks like it's resolved. Please reopen if still relevant.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

xleliberty picture xleliberty  路  3Comments

stefandoorn picture stefandoorn  路  3Comments

crbelaus picture crbelaus  路  3Comments

tchapi picture tchapi  路  3Comments

hmonglee picture hmonglee  路  3Comments