Closed remcotolsma closed 2 years ago
The Gravity Forms PayPal Add-On triggers the add_subscription_payment
action when it receives an subscr_payment
transaction type IPN request.
I don't know if PayPal sends a subscr_payment
transaction type IPN request for the first payment that triggered the creation of the PayPal subscription.
In the Gravity Forms Stripe Add-On i think they check on the first payment:
// If it's the first invoice and payment_status is active, it means the subscription has just started
// when checkout session completed. So don't set action to prevent duplicate notes.
$number = explode( '-', rgars( $event, 'data/object/number' ) );
if ( $this->is_stripe_checkout_enabled() && rgar( $entry, 'payment_status' ) === 'Active' && $number[1] === '0001' ) {
$action['abort_callback'] = true;
} else {
$payment_intent = rgars( $event, 'data/object/payment_intent' );
$action['transaction_id'] = empty( $payment_intent ) ? rgars( $event, 'data/object/charge' ) : $payment_intent;
$action['entry_id'] = $entry_id;
$action['type'] = 'add_subscription_payment';
$action['amount'] = $this->get_amount_import( rgars( $event, 'data/object/amount_due' ), $entry['currency'] );
$action['note'] = '';
My main concern always is about sending a different welcome notification for the first payment, but the create_subscription
event can already be used for this notification.
I don't think it is strange to call the add_subscription_payment
event for the first payment. However, it might be a surprising change for some users, as the first payment will not result in a notifications anymore if only the complete_payment
event has been set.
Currently we only execute the
add_subscription_payment
payment action for subscription follow-up payments (not the first payment).https://github.com/wp-premium/gravityforms/search?q=add_subscription_payment
Is this behaviour correct or is a first subscription payment also a subscription payment and should we also execute the
add_subscription_payment
action?https://github.com/wp-premium/gravityforms/blob/a9c8f2de051e016e096069210ecd5fb8f5a19801/includes/addon/class-gf-payment-addon.php#L2052-L2123