Use Order API to create recur directly for Formbuilder payments - #35995
Use Order API to create recur directly for Formbuilder payments#35995mattwire wants to merge 1 commit into
Conversation
|
🤖 Thank you for contributing to CiviCRM! ❤️ We will need to test and review this PR. 👷 Introduction for new contributors...
PR commands & links...
|
da1f184 to
c060ea1
Compare
3613211 to
9646108
Compare
Formbuilder's Afform contribution submission (CreateContribution::saveNewContribution) used to create the Contribution via Order API and then create the ContributionRecur separately afterwards, manually copying contact_id/amount/currency/is_test across from the just-created Contribution. Order API now supports recurring contributions directly, so pass the recur values straight into Order::create() and let it create both records. Order::calculateSharedValues() reconciles currency/is_test between the Contribution and ContributionRecur when only one side provides a value, so callers don't have to specify both. It runs before the ContributionRecur is created (calculateContributionRecurValues() creates it immediately when there isn't an existing one), otherwise a value provided only on the Contribution side would be too late to reach it.
9646108 to
aa0d657
Compare
|
@mattwire I've been trying to get my head around this and #35996 I like the general idea here a lot and the code looks good to me. But I'm stumbling on the following discrepancy between Contribution and ContributionRecur: Contribution:
ContributionRecur
Are you at all worried about this discrepancy? Do you have any thoughts on how to handle it? Does Order API for recurring contributions allow setting the payment processor (and associated details)? |
ContributionRecur is the subscription schedule and payment method. In the case of a direct debit you can think of it as the "mandate". It is not an invoice but you can expect invoices to be opened because of it.
It's only fudged because afform payments doesn't add the payment processor ID, quickform does. Because Order API didn't support recurring until early this year you had to do separate calls to create the recur.
This PR will actually need a bit of rework once #35996 is merged - as long as the params are passed into order api they will be saved. |
|
Marking draft pending merge of #35996 |
Overview
When Formbuilder payments was first written Order API did not support recurring contributions. Now it does. So let's use it!
Before
Separate function, after Order API called
After
Created using Order API
Technical Details
Comments