• Resolved grosso2020

    (@grosso2020)


    Hi Ironikus!

    I want to get user payment data from a WordPress plugin via a custom Webhook action

    Plugin code:

    add_action( 'subscribe_success_pay', 'opt_payment', 10 );
    function opt_payment( $payData ) {
        if ( $payData->pay_type != 'subscribe-pay' )
            return false;
    
        $baggage = $payData->baggage_data;
        $tariff = opt_get_tariff( $baggage->tariff_id );
        $tariff_price = opt_get_tariff_price( $baggage->tariff_id, $payData->user_id );
    
        if ( $tariff_price != $payData->pay_summ )
            return false;
    
        do_action( 'opt_pre_payment_access', $payData, $tariff );
    
        $payment_id = opt_add_payment( array(
            'user_id'       => $payData->user_id,
            'account_name'  => opt_get_account_field( $tariff->account_id, 'account_name' ),
            'tariff_price'  => $tariff_price,
            'access_time'   => $tariff->access_time
        ) );
    
        $access_id = opt_update_user_access( $payData->user_id, $tariff->account_id, $tariff->access_time );
    
        do_action( 'opt_payment_access', $payment_id, $access_id, $baggage->tariff_id );
    }

    I make a filter and a function according to your documentation and insert it into functions.php

    add_filter( 'wpwhpro/run/actions/custom_action/return_args', 'wpwh_fire_my_custom_logic', 10, 3 );
    function wpwh_fire_my_custom_logic( $return_args, $identifier, $response_body ){
        if( $identifier !== 'subscribe' ){
          $return_args  = array(
              'user_id'       => $payData->user_id,
              'account_name'  => wau_get_account_field( $tariff->account_id, 'account_name' ),
              'tariff_price'  => $tariff_price,
              'access_time'   => $tariff->access_time
              );
        }
        return $return_args;
    
    }

    But after the user pays, the webhook does not work. How to get data from a plugin into your function?

Viewing 1 replies (of 1 total)
  • Hi Grosso2020, thank you for reaching out.

    Please note that our plugin works mainly in two ways:

    1. Sending data, or “Triggers“: those are events that take place on your site, and that will send a Webhook request to a target URL with all the relevant information from that event (i.e., a post was created, and you send the post data through a Webhook request).
    2. Receiving data, or “Actions“: this is the opposite way; they receive a Webhook request to the URL you create when setting up your action, and you can then execute that action with the parameters you get from the URL (i.e., create a post, and you receive the post data through the URL parameters).

    Can you please tell us which payment plugin you’re using? And which trigger or action are you trying to use? Can you please show us a screenshot of your trigger or action set up? We’ll learn more, and we’ll be able to provide further guidance then.

Viewing 1 replies (of 1 total)
  • The topic ‘how to get data from a plugin using a custom action?’ is closed to new replies.