pronamic / wp-pronamic-pay

The Pronamic Pay plugin allows you to easily accept payments with payment methods like credit card, iDEAL, Bancontact and Sofort through a variety of payment providers on your WordPress website.
https://pronamicpay.com
35 stars 14 forks source link

Review use case `$payment->automatic` or `$payment->event` or `$payment->origin` #241

Closed remcotolsma closed 1 year ago

remcotolsma commented 3 years ago

Also talked about payment.automatic just like the Stripe payout object property payout.automatic documented like:

Returns true if the payout was created by an automated payout schedule, and false if it was requested manually.

https://stripe.com/docs/api/payouts/object#payout_object-automatic

Or we could use something like GitHub actions event name GITHUB_EVENT_NAME:

if: github.event_name == 'schedule' && github.event.schedule != '0 0 * * *'
Property name Type Description
github.event object The full event webhook payload. For more information, see "Events that trigger workflows." You can access individual properties of the event using this context.

We could also extend the payment object with an event property that contains information about what event triggered the payment. I also mentioned the use of origin:

payment {
    "origin": {
        "post_id": 123,
        "type": "web" // or `cron`
    }
}

For just Mollie we maybe even don't need the first payment, if there is no mandate ID we use sequenceType first and otherwise recurring.

For Gravity Forms there is currently an action that is triggered only for successful follow-up payments.

Originally posted by @remcotolsma in https://github.com/pronamic/wp-pronamic-pay/issues/228#issuecomment-936106294

remcotolsma commented 2 years ago

In https://github.com/pronamic/wp-pay-core/compare/39084c8...d8b108b a Subscription->is_manual_renewal_payment( Payment $payment ) method was introduced, is this related to this issue? It's used in https://github.com/wp-pay-gateways/mollie/compare/bcbceab...4a16ba1. Is the payment manually initiated and/or processed manually?

rvdsteege commented 2 years ago

In pronamic/wp-pay-core@39084c8...d8b108b a Subscription->is_manual_renewal_payment( Payment $payment ) method was introduced, is this related to this issue?

In the Mollie integration, I needed a way to not set the sequence type to recurring (like first payments) if the payment is a manual renewal; initiated via the subscription renewal URL. Instead of checking for the manual_subscription_renewal meta in the gateway, I thought it might be cleaner/convenient to have a Subscription::is_manual_renewal_payment( $payment ) method, like Subscription::is_first_payment( $payment ).

If we find an other way to mark a payment as initiated by the user, we could also use that instead. However, manually starting the next period payment for a subscription could also be considered as (admin) user initiated, but should not be considered an interactive payment. So, for example payment.origin.type = 'web' won't be enough to distinguish between these cases.

remcotolsma commented 2 years ago

For now i have changed this to:

$payment->set_meta( 'mollie_sequence_type', 'first' );
$payment->set_meta( 'mollie_sequence_type', 'recurring' );

As soon as we start supporting subscriptions for more gateways, I think we'll get a better idea of how we can design this.