-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Payment Integration #48
Comments
Hey @dyjo! Thanks for the good words, it's really motivating! :) I'd love to handle several different flows for the payment out of the box, but to keep it flexible at the same time. We can perhaps rename this issue to Omnipay integration and discuss everything here, what do you think? Thanks for jumping in! |
Narrowing it down to Omnipay Integration helps. My original question was about a checklist of items that would create a working deployment, so I've tried to create one here. I've also tried to keep the descriptions as simple as possible, to prevent incorrect assumptions about the intended architecture. Just tell me if any corrections should be made, but I think maintaining this list will be useful as a roadmap for end-users or new contributors.
I'll be posting my suggestions for these items in separate comments, and hope others do as well. |
Would be great if you can help Sylius move forward on these tasks! |
Why do you want to integrate a CreditCard entity to the CoreBundle? There is already one in PaymentBundle, it is even linked to the User class defined in config. |
@winzou Thanks for pointing that out; I've been having trouble understanding how the DI occurs. I see that |
Everything is in PaymentBundle/Entity, and the doctrine mapping in PaymentBundle/Resources/config/doctrine. There is also the relation between CreditCard and Payment. You can tick the first 2 items ;) |
@winzou I've looked at both of those, but was still confused: how do i access the credit card entity? is it available in the service container as |
Does anyone have already use JMSPayment bundles? @pjedrzejewski wouldn't be a better thing to rely on JMS' bundles as this is a quite complex feature? It seems that JMS' bundles are on an advanced stage, it would save Sylius a lot of effort. Have you ever thought about that? |
@winzou I found Sylius when I was looking for a more full-featured alternative to JMSPayment. The big value added for me is integration with Omnipay, so there's an abstracted method for submitting and capturing payments, and you don't have to define a new provider every time you want to use a new Gateway. |
Do you think this is possible to integrate omnipay in a JMsPaymentCore plugin? It's a real question. |
@winzou I'm sure it's possible, though I don't know why you would. It seems like the JMSPaymentCore GatewayPlugin duplicates a lot of what Omnipay does. At any rate, it don't know that it really relates to the topic of the issue, which is how does one bridge the gaps that exist in SyliusPayments and SyliusOmnipay |
@winzou also a real question: #48 (comment). Figuring that out would be of great help for me, and hopefully flick the switch that helps me start contributing. |
Ok, so my proposals for checking off the boxes on the task list. Please keep in mind this is all messy, just ideas not working code. But I want to get feedback before writing a bunch of stuff that doesn't make sense to maintainers. Integrate a
Add a
Map an Association between
Map an Association between
Add the
Integrate submission and capturing of payments to the
For example: $omnipayCard = $form->get('creditCard')->mapToOmnipay();
$omnipayGateway = $this->get('sylius.omnipay.gateway' . $this->getCurrentCart()->getPaymentMethod()->getGateway());
$transaction = $omnipayGateway->purchase($omnipayCard); Persist Captured Payments to Database
Hopefully this is easy enough to follow, and hopefully others can help me understand the code that's already there to make this stuff happen. If any of these sounds reasonable, let me know and I'll get to work on a pull request. |
Why do you want I totally agree with all your following points. There is just one thing I want to raise: the use of credit card. In quite many cases I think end-users will choose to go through the bank interface: it means that the ecommerce website doesn't have to ask for and store the credit card information, avoiding some obligations. For us, it means that the payment process differs from one payment method to another, and we don't show the credit card form everytime. |
I totally agree with winzou on the use of credit card. Storing credit card data is very very discouraged. If Sylius wants to store these kind of information, it should follow the PCI-DSS standard. Here is some documentation :
I don't know if these requirements have been taken into consideration at the moment. But if not, we have to understand that :
|
The actual use case for CreditCard entity is to store the name, 4 last digits and the token for gateways which support token billing. So the store does not store any sensitive data and customer can enter the info only once, and later just select his credit card from the list. There is no plan to save any cc information on our side, but of course it's up to developer what he'll do! |
Re: #48 (comment) I've left the second item unchecked because I still don't see a concrete mapping between a payment and a credit card (not just association in schema, but forms and embedded forms) in the checkout flow. @winzou re: #48 (comment). But, in the event a credit card is available as a payment source, persistence should definitely be available. Storing a token is very useful for recurring payments, storing the last 4 and a reference to the owner doesn't require PCI compliance, but does allow a user to select the method for a future payment. Further, someone using the bundle independently may want to store more info, and could develop PCI compliance. |
Hello! I'd like to join in, plan to use Sylius for some jobs soon. I've been working on a pull request for credit card form type. I've run into a problem with where to get a list of supported brands/types. Different gateways support different brands depending on locale (https://stripe.com/us/help/faq#types-of-payments). So the question is how to get that list. Some ideas
In the meantime I'm just using the constants from Omnipay Credit Card class (https://github.com/adrianmacneil/omnipay/blob/master/src/Omnipay/Common/CreditCard.php) |
I think this is up to end-users, they can choose to enable or not certain types of credit cards in their country. |
Hey guys, thanks for all the input. 👍 Just to clarify confusion about Payment -> CreditCard association - it's there https://github.com/Sylius/SyliusPaymentsBundle/blob/master/Model/Payment.php#L63. But there are no dedicated get/setters, you can set and get it via get|setSource methods. This may be confusing as it's hidden behind Doctrine RTEL magic. See this cookbook entry. This is how all Sylius relations work, so if you want to change one entity class (via configuration) there is no need to remap or redefine all entities. Relation are updated automatically. This also works for CreditCard.user association, if you configure FOSUserBundle User entity class (or any other user entity you want) it will be associated with CC. I think this is sensible default. Yes, Order should be associated with Payment. And I agree that Payments do not always have to come from Order, so let's keep the foreign key on Order side. The plan was to create payment via The @dyjo Thanks for your research, I fully agree that we should be able to set method/source per transaction, not only for payment. My idea would be to remove Transaction model completely, and use offset payments like Spree does it. @dyjo What do you think about handling this like Spree? We'd get rid of Transaction model, which otherwise would become very similar to Payment itself. |
@pjedrzejewski Thanks for clearing all that up! The way Spree handles this looks perfect; certainly clears up the confusion about what is a transaction and what is a payment. I'm not too familiar with Doctrine Extensions; I have worked with multi-level trees but not 1-level trees. Is there any special configuration required to limit a tree to a single level? Additionally, curious about integrating two things you mentioned:
Is there any plan to incorporate these into the payments bundle? They would be very helpful for standardizing transactions. I know that Omnipay has "off-site" gateways, so that should make using PayPal easy enough, but I haven't seen anything about Bank Transfer, ACH, etc. |
Actually, I think we do not really need to use DoctrineExtensions (we use it for taxonomies) for this. I think that Payment.parent -> Payment association will be enough. With reverse side on Payment.offsets -> many Payments. We can simply perform a check to disallow setting Payment as parent if it is already a "offset" (or child) payment. This way we'll limit it to just one level tree. Actually I was using Adyen payments system directly (via SyliusPaymentsBundle models), not Omnipay. And I think that Omnipay currently does not support token billing (or maybe it's in dev). Nevertheless, we can simply contribute to Omnipay with features we need! Forgive me guys but I need a bit of clarification who is who haha! @dyjo @Eponymi @dylanjohnson? :D |
Fair confusion! I'm Carl, I'm the boss :) . I just hired Dylan a couple weeks ago as a contractor, and he's now working with us full-time. So he's been using this account to make comments sometimes, but I've asked him to use his personal account (thought it was @dyjo, don't know why he has @dylanjohnson) for comments/issues now. He does all the code writing through this account. So pinging this account is probably best way to go. So in short: any comments/issues coming from this account will be me, any code writing is Dylan. And @dyjo @dylanjohnson pick one personal account name! |
Woops. I deleted the other one. But now I'm also Ghost (#48 (comment)). Sorry about that! |
@dyjo My plan is to work hard to finish the 2 important things I mentioned (product + cart&order) by the end of this week. Then I can code the Payments stuff with you if you wish, but of course you can start whenever you want and I'll be happy to help/discuss/review a PR! That'd be awesome help. 👍 Thanks for pushing this important feature forward! |
@pjedrzejewski I'll have a PR up on PaymentsBundle in the morning tomorrow following the Spree model, and I'll make sure to put in all specs. Hopefully that will be good enough to merge, and if so, I'll get the stuff together for CoreBundle tomorrow afternoon. |
@dyjo That's great but don't set so hard deadlines for yourself. :) Take your time to implement it! |
Fair enough, thanks for the help! |
@pjedrzejewski Any ideas on sources that don't require a form? Off-site sources like PayPal for example. I have a couple ideas but wanted to get your thoughts.
Number one would be quite a bit easier to implement with current code base. Number two seems like a much better UI/UX, but would require a lot more work and would mean that any off-site payment method would have to add a button view, or at the very least, an URL pointing to the gateway. |
I think we should do number 1 in a first iteration, and then improve UI over time. |
Ok, I've had a lot of trouble figuring out how to implement this abstraction. I'm going to defer to others on this integration and just use some hard-coding in the PaymentStep for the time being. Hopefully someone will be able to put something together for this, I'll be looking for it! EDIT: If anyone is interested in seeing the route I was going, you can check here: https://github.com/Eponymi/SyliusPaymentsBundle/tree/payment_refactor_branch |
Closed in favor of: #112 |
Solution to Issue #48 - "Incorrect quantity when adding the same product on dev-master". The changes made to the cart's item collection happen on the inverse side of the relationship, according to doctrine "Changes made only to the inverse side of an association are ignored. Make sure to update both sides of a bidirectional association (or at least the owning side, from Doctrine’s point of view)". Solution is to explicitly persist the items in the refreshCart function. More info at http://docs.doctrine-project.org/en/latest/reference/unitofwork-associations.html
Fixed transitive association persistence issue (Issue #48)
Solution to Issue #48 - "Incorrect quantity when adding the same product on dev-master". The changes made to the cart's item collection happen on the inverse side of the relationship, according to doctrine "Changes made only to the inverse side of an association are ignored. Make sure to update both sides of a bidirectional association (or at least the owning side, from Doctrine’s point of view)". Solution is to explicitly persist the items in the refreshCart function. More info at http://docs.doctrine-project.org/en/latest/reference/unitofwork-associations.html
Fixed transitive association persistence issue (Issue #48)
Update index_resources.rst
Few UI tweaks
load metadata event listener
Hello,
First: Thank you for the awesome library!
Sylius would be perfect in a product I have scheduled for imminent release, but I was confused about some things regarding the payment process. I'm hoping to figure out what's missing so I can bridge the gap for my project, and submit some pull requests if the code might help others.
sylius/omnipay-bundle
is included insylius/sylius
orsylius/payments-bundle
.PaymentStep
in the Checkout process and thePaymentMethodType
in the PaymentBundle. But I can't seem to find how the actual entry of credit card information is facilitated? Is this a work in progress related to the integration of the Omnipay library?Again, thanks for the awesome library; I look forward to seeing what you come up with next, and hope to have an opportunity to contribute in the future!
The text was updated successfully, but these errors were encountered: