Flag to indicate separate membership payment
When the "Separate Membership Payment" option is enabled on a contribution page doPayment()
is called twice with different amounts and descriptions. However, there is no way to identify that they are part of the same form submission once doPayment is called.
This is a problem for token based processors which generate a "token" via javascript and then submit that token instead of the credit card details. In the case of Stripe (probably similar for others) that token is assigned to a customer and the customer can be charged multiple times, but the token CANNOT be re-used.
In order to process the second payment for the same submission we need to know that it is a second payment so we can handle the token differently.
My proposal is to add an additional flag to the $params
array that is passed to doPayment: is_secondary_financial_transaction=1
PR that implements this: https://github.com/civicrm/civicrm-core/pull/12358
This allows the following code to be implemented in the payment processor: https://github.com/mattwire/com.drastikbydesign.stripe/commit/b648603c0dc1a2aef569537f95ceb46612df3204#diff-8dcbf2bfe3fcb3899e049399543df444R559
Note that the code being removed in that commit did not work as both params were always set.