Conversation
Regarding the testability for contributors, I agree that it could be simplified/easier to get started. Also see the discussion here. |
First impressions:
I highly appreciate this contribution and will be looking into this. It will be a key part of the
That being said, rest assured you have my attention 😉 . |
@sandervanhooft No worries about the timeframe, just take it easy ;). Is the develop branch going to be the base for the V2 release branch? In that case I will just let the morphable related code be (since it won’t break any tests). Good thing to note for the upgrade guide though. I had seen the conversation you mentioned about the “making testing easier” comment. The thing I’m envisioning is a “run this with your mollie api key, copy paste to your phpunit configuration and you’re done” kind of thing. After that you’d be able to run all the tests without figuring out what mandates or subscriptions, first payments etcetera are. Sometimes you wish to make a simple change, but you still have to run the test suite, so I thought we could make that a lot easier for simple pull requests. Great that Spark Mollie is being released, I’m thinking of giving that a spin for a side project to play with it! Just a thought off the top of my head; Optionally making a mandate can probably be implemented by passing [“method” => “first”] to the invoice options. |
Let's treat this as a breaking change, so implement it on |
If this goes into v2, I guess that means having this feature available will require waiting for any other v2 milestones to be finished as well? Or might finishing this warrant releasing v2? |
Any update on this feature? Would love to see this in V2 😄 |
Hi @mbardelmeijer, I’m not really sure about the roadmap for V2. Seeing the latest commits it looks like Sander has been improving some testing utilities lately. @sandervanhooft |
I am silently (so mostly off-radar) working on v2, hope to release by the end of the year / beginning of next year. I'm tackling some fundamental changes first. |
@sandervanhooft I would love to test v2 when you have an alpha ready! |
@jelleroorda We're a long way into developing the v2 alpha, almost ready for release. We have heavily based the new one-off payment features on this PR, but since there was a lot changed already we had to copy it in. Rest assured the features will be properly attributed to you on release. Big thanks and we'll get back to you soon! |
This pull request closes #42.
There are a few things that still need to be done, and on which I would appreciate your input (@sandervanhooft).
Order items "on the tab" collision (?) with Subscription order items.
Currently, because of the nature of the subscription billing implementation, the 'open tab' may collide with subscription billing.
Example 1: calling
$user->invoice()
may end up invoicing subscription items if they are due for processing (could be the intended functionality?).Example 2:
php artisan cashier:run
will invoice the items that we put on the tab, once they are due for processing.If we intend to split apart subscription billing and one off payments, we can add an extra table
tab_items
that simply points to theid
of an order item that is supposed to be on the tab. After that we can add two scopesonTheTab
andforSubscriptions
(naming up for discussion of course), and add theforSubscriptions
scope toCashier::run
, as well as theonTheTab
scope to theinvoice
method.My assumption was/is that you would prefer not to split this apart, since it could be nice if a developer can put an extra item on the customers next bill (complementary to the fee for the subscription).
In this case we would need to document this properly, and in my opinion also write some extra tests that do some checking on the aforementioned scenario (subscription + one off payment complimentary usage).
Double checking the payment flow for one off payments
Though this is pretty obvious, you may want to double check if the one off payment flow that is implemented is correct. A quick summary:
Scenario 1:
Scenario 2:
OrderPaymentPaid
event)OrderPaymentFailed
event)This flow is quite the same as the "first payment" flow, except the fact that we are creating a "one off payment", which means we don't create a mandate in the process.
Something you will notice is that the "one off payment flow" is not using/hooking onto the
Actions
that are currently a feature for subscriptions. This was done on purpose, since I couldn't think of a scenario where you would want to do "anything fancy" with a one off payment. This also means that instead of storingactions
in the Mollie Payment metadata, we are simply storing theorder items
. If someone can think of a valid reason to introduce the extra layer of complexity (the actions), we could revisit this implementation.Double check the written tests
I'm not completely up to speed with your usual event dispatching for example, in the end I haven't used this package since
1.0
because there were no "one off payment" possibilities, which was my main use case in the application I was building. Kindly check if the tests are up to par, and if they need to be improved/extended.Notes
The
Laravel\Cashier\SubscriptionBuilder\RedirectToCheckoutResponse
class has been reused (for developer friendliness), even though the namespace is now kind of weird; maybe we should flag this as something that can be improved in V2? (since it's a breaking change to move it to a different namespace)Instead of using
get_class($user)
I used$user->getMorphClass()
, which supports Laravels MorphMap (I noticed later you usedget_class()
). You could see this as a breaking change. If a developer has defined a morph map for theirUser
model, it will now use the defined string by the developer instead of the fully qualified name of theUser
model (though chances are probably very low the generic developer is using this [this is an assumption though :)]). I noticed this later, as well as the assumption we're currently making that the user will always have anid
column ($owner->id
calls). We should replace this with$owner->getKey()
instead in the future, so we support different primary key names. Let me know what your thought are on the above.To do's
phpunit.xml
for usage inManagesInvoiceTest.php
, since one off payments have a different Mollie Payment metadata (they use theorder items
, not theactions
after all.phpunit.xml
. This will (in my opinion) greatly improve onboarding of developers for pull requests (perhaps other pull request?).->getMorphClass()
calls toget_class
.Let me know your thought on this so far.