I think we could simply call $subscription->set_customer( $payment->get_customer() ) in the WooCommerce gateway to resolve this. But additionally, the incorrect period of the first payment (which causes the payment not being recognized as the first payment) is also a point of attention:
This seems to be caused by the next payment date being set on the subscription, before a new period is added. In development, I have resolved this by temporarily setting the next payment date to the current date (as is usually the case when starting subscriptions), but this is not really a nice solution.
The customer is not set because the payment is not recognized as the first payment in https://github.com/pronamic/wp-pay-core/blob/b20133ecec3b72d2ca9fab58b6b693f93edf3063/src/Subscriptions/SubscriptionsModule.php#L118-L133. Therefore,
SubscriptionHelper::complement_subscription_by_payment( $subscription, $payment )
is not called and the customer is not 'complemented' in the subscription.I think we could simply call
$subscription->set_customer( $payment->get_customer() )
in the WooCommerce gateway to resolve this. But additionally, the incorrect period of the first payment (which causes the payment not being recognized as the first payment) is also a point of attention:This seems to be caused by the next payment date being set on the subscription, before a new period is added. In development, I have resolved this by temporarily setting the next payment date to the current date (as is usually the case when starting subscriptions), but this is not really a nice solution.
https://github.com/pronamic/wp-pronamic-pay-woocommerce/blob/f21bf0b8b83e0c5682a9b3825356d8b423714e59/src/Gateway.php#L385-L400