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

[WIP] Sylius payum integration #275

Merged

Conversation

makasim
Copy link
Contributor

@makasim makasim commented Aug 19, 2013

The PR attempt to integration payum into sylius e-commerce. Currently it contains two examples. First is offsite payment (paypal express checkout was used) and second credit card payment (stripe via omnipay bridge was used).

Integration

I briefly describe integration steps required. Check Files Changes for more details.

  1. Add payum's lib to composer.json and install them
  2. Update PaymentMethods. Remove all exist and add Stripe and Payal EC.
  3. Add PurchaseStep to checkout scenario.
  4. Configure payum

Order <-> Payment details relation problem

We should definitely discuss the order <-> payment details relation problem.

Clarification:

Payum does not provide unified payment model in any way. All of them payment specific, do not share any interfaces or parent classes. For paypal rest situation even better: we reuse their official model that comes with paypal/rest-api-sdk. The bridge for jms plugings works with its PaymentInstruction model. Omnipay does not provide any model yet.

How I solve it in customers projects:

We have Order to PaymentDetails realtion (Order is owning side). Let's say one-to-one. PaymentDetails model implements class table inheritance pattern. There should be a way to dynamiclly add new classes to the map. I think it is possible with metadata doctrine event. I used this strategy in several projects: works fine but I doubt it is the best solution for the e-comerrace platform.

Solution:

I added details property to Paymnet model (and its iterface). The details contains simple array. This way we do not need any extra models and can reuse current code. Payum native and omnipay's gateways have to work fine with this solution where jms plugins not.

Moving payum related code to a bundle

What about moving all payum related stuff to payment bundle? or even better create one SyliusPayumBundle. It will contains all integration details.

Solution:

Moved.

Credit card processing questions?

Where to ask for credit card (if it is required)? It could be asked on payment method selection method (after user choose one) or inside CaptureOrderWithXXXAction.

Note: Since it is proof of concept everybody are welcome to discuss\criticize\ask about this PR. I am looking forward to get your feedback.

Solution:

It is asked on the separate page only if payment require it.

TODO (maybe not in this PR (: )

  • Fallback payments
  • Simplify storages configurations
  • Offline payments
  • Allow set custom status for dummy payments.
  • Design for credit card page.

@@ -37,15 +38,19 @@ public function displayAction(ProcessContextInterface $context)
*/
public function forwardAction(ProcessContextInterface $context)
{
/** @var Order $order */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can do this on the docblock of createOrder and not here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with you that createOrder is a better place for that.

This was referenced Sep 4, 2013
@@ -52,6 +52,7 @@ public function build(ProcessBuilderInterface $builder)
->add('shipping', 'sylius_checkout_shipping')
->add('payment', 'sylius_checkout_payment')
->add('finalize', 'sylius_checkout_finalize')
->add('do_payment', 'sylius_checkout_do_payment')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i want to like the name however there must be some better name maybe

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cordoval you are welcome to propose one.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

something with capture or complete purchase?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

weird to have something after finalize... maybe the others names should also be renamed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jjanvier yes I am completely agree with you. I am thinking of such renaming

  • finalize to approve
  • payment to choose_payment
  • do_payment to payment or purchase.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@makasim perfect for me, cc/ @pjedrzejewski

@chugas
Copy link

chugas commented Sep 17, 2013

I am testing the integration of payum with paypal but I am having some troubles. I am going to tell you the changes I had to make and the issue that have me stucked.

First of all, I have changed the following lines of the DoPaymentStep.php file:

1- Line 23, function displayAction
$captureToken = $this->getPayumTokenManager()->createTokenForCaptureRoute
by
$captureToken = $this->getTokenFactory()->createCaptureToken

2- Line 38, function forwardAction
$token = $this->getPayumTokenManager()->getTokenFromRequest($context->getRequest());
by
$token = $this->getTokenFactory()->getTokenFromRequest($context->getRequest());

3- Change the function
protected function getPayumTokenManager()
{
return $this->get('payum.token_manager');
}
by
protected function getTokenFactory()
{
return $this->get('payum.security.token_factory');
}

When the process finishes and when I create the order I get this error for the relative url "/payment/capture/{token}":
Request Payum\Request\SecuredCaptureRequest is not supported.

I am attaching an image.

syliuspayum

Thank you very much

@makasim
Copy link
Contributor Author

makasim commented Sep 17, 2013

@chugas I did some BC breaks in 0.6 version, you know it is not stable so I can break it (:

I am going to fix it right now.

@makasim
Copy link
Contributor Author

makasim commented Sep 17, 2013

@chugas Should work fine except one place: Currently relation between payment details and order is not establish. So the payment always endup with unknown status. I suppose you change it to doctrine relation or something similar. In this case I expect everything should work fine.

Thanks for your feedback

@makasim
Copy link
Contributor Author

makasim commented Sep 17, 2013

Also I am thinking of moving some code from CoreBundle to PaymentBundle. IMO it would be a better place.

@jjanvier
Copy link
Contributor

@makasim which part of the CoreBundle would you like to move ?

@makasim
Copy link
Contributor Author

makasim commented Sep 17, 2013

@makasim which part of the CoreBundle would you like to move ?

the one I added and which related to payum integration. Sylius\CoreBundle\Payum\Action\OrderStatusAction for example.

@jeremyFreeAgent
Copy link

Any news about that?

@makasim
Copy link
Contributor Author

makasim commented Sep 27, 2013

@jeremyFreeAgent I have lots of ideas and plans how to move it forward but I decided to wait for some feedback from sylius team side. Unfortunately any news so far.

@pjedrzejewski
Copy link
Member

@stloyd Yeah, or maybe we just move it outside main app. (like it was before) At some point maybe someone/other org would like to adopt it, because we're not going to use it in Sylius apparently. One repo less to maintain is always good.

@pjedrzejewski
Copy link
Member

PR requires a rebase, @maksim need a hand? :)

@makasim
Copy link
Contributor Author

makasim commented Oct 15, 2013

@pjedrzejewski hands are always welcome, I can do something only tomorrow, no time left for today.

@makasim
Copy link
Contributor Author

makasim commented Oct 15, 2013

rebased&squashed

@makasim
Copy link
Contributor Author

makasim commented Oct 17, 2013

@pjedrzejewski

I'm not sure I like saving stuff to app/Resources/payments - I'm pretty sure Payum provides db storage. Possible?

fixed - formapro-forks@aa8e12c

@makasim
Copy link
Contributor Author

makasim commented Oct 17, 2013

@pjedrzejewski what is left? I am gonna write some specs today\tomorrow what else should I do?

@makasim
Copy link
Contributor Author

makasim commented Oct 17, 2013

rebased&squashed

@pjedrzejewski
Copy link
Member

My new scenarios for inventory update during checkout are failing, but I'll fix this with another PR. Thank you for your amazing work Maskim, I think it's great start and big step forward. There are some little issues, but we'll iterate on the payments just like with everything else. More in the blog post today, I'm writing it right now. Also I'll register the payum bundle on packagist and update my subtree split script.

Thanks to everyone involved in this PR! Awesome work. 👍

pjedrzejewski pushed a commit that referenced this pull request Oct 18, 2013
@pjedrzejewski pjedrzejewski merged commit 73726b9 into Sylius:master Oct 18, 2013
@makasim
Copy link
Contributor Author

makasim commented Oct 18, 2013

@pjedrzejewski oh my... good news before weekends

@jjanvier
Copy link
Contributor

congratulations @makasim :)

@norberttech
Copy link
Contributor

Time for a 🍺 ! Congratz @makasim

@jeremyFreeAgent
Copy link

👍

@arnolanglade
Copy link
Contributor

👍 @makasim !

@amenophis
Copy link
Contributor

@makasim 👍 too ! Great work !!


Jérémy LEHERPEUR
jeremy@leherpeur.net

2013/10/18 Arnaud Langlade notifications@github.com

[image: 👍]@makasim https://github.com/makasim !


Reply to this email directly or view it on GitHubhttps://github.com//pull/275#issuecomment-26592030
.

@pentarim
Copy link

thanks & congratz

@antonioperic
Copy link
Contributor

Good job guys

@pjedrzejewski
Copy link
Member

SyliusPayumBundle is available as standalone package on packagist.org - https://packagist.org/packages/sylius/payum-bundle.

@winzou
Copy link
Contributor

winzou commented Oct 18, 2013

Awesome, great job guys!

@Richtermeister
Copy link
Contributor

Awesome! Congratz & great job!

@lughino
Copy link

lughino commented Oct 27, 2013

Hello,
excellent job of integration!
But I have a problem:
I state that I installed a complete project Sylvius.
When I make a payment with PayPal, the payment remains in "pending".
Then it is normal paypal, once payment has been made, redirects you to the homepage?

I can customize this behavior?

@makasim
Copy link
Contributor Author

makasim commented Oct 27, 2013

When I make a payment with PayPal, the payment remains in "pending".

could you check pending_reason in the payment details (details column in the sylius_payments table). It most probably set to multi-currency. If so you have different currencies set for sale account and buyer. Paypal does not convert currencies automatically and waiting for sales to make a decision.

Let me know if you have other then this reason.

Then it is normal paypal, once payment has been made, redirects you to the homepage?

yes it is expected behavior. You have to see a flash message on the home page. Right now you can customize it only extending PurchaseStep.

I have plans to add an event there to make such tasks easier to do.

@lughino
Copy link

lughino commented Oct 27, 2013

Thanks, that was exactly what the problem!

2013/10/27 Maksim Kotlyar notifications@github.com

When I make a payment with PayPal, the payment remains in "pending".

could you check pending_reason in the payment details (details column in
the sylius_payments table). It most probably set to multi-currency. If so
you have different currencies set for sale account and buyer. Let me know
if you have other then this reason.

Then it is normal paypal, once payment has been made, redirects you to the
homepage?

yes it is expected behavior. You have to see a flash message on the home
page. Right now you can customize it only extending PurchaseStephttps://github.com/Sylius/Sylius/blob/master/src/Sylius/Bundle/PayumBundle/Checkout/Step/PurchaseStep.php
.

I have plans to add an event there to make such tasks easier to do.


Reply to this email directly or view it on GitHubhttps://github.com//pull/275#issuecomment-27175600
.

pamil pushed a commit to pamil/Sylius that referenced this pull request Mar 21, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Minor issues and PRs improving the current solutions (optimizations, typo fixes, etc.).
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet