rcp_insert_payment

This action is deprecated as of version 2.9. Use rcp_create_payment to run actions whenever a payment status is inserted. Use rcp_update_payment_status_complete to run actions whenever a payment is marked as "complete".

Note: This is part of the developer docs and is considered custom code.
Unfortunately, we cannot provide support for custom code at this time as we do not have the additional resources that would be necessary to provide support for custom code.

If you need assistance with this, please reach out to our list of consultants for further assistance:
https://codeable.io/developers/restrict-content-pro/

Runs when a payment record is inserted into the database. Note: be sure to check that the payment status is 'complete' if executing code when a new completed payment is made.

Parameters:

  • $payment_id (int) - ID of the payment that was just inserted.
  • $args (array) - Arguments used when inserting the payment. Contains the following:
    • 'subscription' - Name of the subscription level the payment was for.
    • 'date' - Date of the payment record.
    • 'amount' - Amount the payment was for.
    • 'user_id' - ID of the user account who made the payment.
    • 'payment_type' - Type of payment, i.e. "manual".
    • 'subscription_key' - Subscription key.
    • 'transaction_id' - Payment transaction ID (from the gateway).
    • 'status' - Payment status: 'complete', 'pending', or 'refunded'.
  • $amount (float) - Amount the payment was for.

Example:

/**
 * Send an email to the customer when a new manual payment is created.
 * 
 * @return void
 */
function ag_rcp_insert_payment( $payment_id, $args, $amount ) {

    // If the payment type isn't "manual" - bail.
    if ( 'manual' != $args['payment_type'] ) {
        return;
    }

    $user_info = get_userdata( $args['user_id'] );

    // Bail if user info can't be retrieved.
    if( ! $user_info ) {
        return;
    }

    // Setup the subject and message.
    $subject = __( 'Your payment is pending', 'rcp' );
    $message = __( 'Hello %name%, your payment for %subscription_name% is still pending. You can view your invoice here: https://yoursite.com/register/your-membership/', 'rcp' );

    // Setup the email class.
    $emails = new RCP_Emails;
    $emails->member_id = $args['user_id'];
    $emails->payment_id = $payment_id;

    // Send the email.
    $emails->send( $user_info->user_email, $subject, $message );

}

add_action( 'rcp_insert_payment', 'ag_rcp_insert_payment', 10, 3 );
Powered by Zendesk