Forum Replies Created

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter biffa

    (@biffa)

    I’m not having a problem getting the $data array, the problem is getting the transaction ID from that array.

    Thread Starter biffa

    (@biffa)

    Basically what I’m trying to do is check if the payment went through and returned as true. That way I can update the database with the details of the user so I know they have paid. I was hoping to do this by adding the transaction ID to the user meta. If this is not the best way to do this, please let me know a better way.

    Thanks.

    Thread Starter biffa

    (@biffa)

    ID should be returned but isn’t. This is the code I have.

    In functions/fields.php :

    add_action('asp_stripe_payment_completed', 'asp_after_txn_callback');
    function asp_after_txn_callback ($data)
    { 
    var_dump($data['charge']['id']); 
    }

    In my template file stripe_success.php
    do_action( ‘asp_stripe_payment_completed’, $data, $data[‘charge’] );

    This is the errors that are returned:

    Notice: Undefined variable: data in /home/hp3-linc1-nfs2-z/400/506400/user/htdocs/wp-content/themes/champs/stripe_success.php on line 22
    
    Notice: Undefined variable: data in /home/hp3-linc1-nfs2-z/400/506400/user/htdocs/wp-content/themes/champs/stripe_success.php on line 22
    
    Notice: Trying to access array offset on value of type null in /home/hp3-linc1-nfs2-z/400/506400/user/htdocs/wp-content/themes/champs/stripe_success.php on line 22
    
    Notice: Trying to access array offset on value of type null in /home/hp3-linc1-nfs2-z/400/506400/user/htdocs/wp-content/themes/champs/functions/fields.php on line 1431
    
    Notice: Trying to access array offset on value of type null in /home/hp3-linc1-nfs2-z/400/506400/user/htdocs/wp-content/themes/champs/functions/fields.php on line 1431
    NULL

    If I remove [‘id’] it works and returns the full array from Stripe. But I need the transaction from that array.

    Thread Starter biffa

    (@biffa)

    ok that makes sense. However, var_dump($data[‘charge’]) works but var_dump($data[‘txn_id’]) returns NULL

    Thread Starter biffa

    (@biffa)

    Hi, thanks for the quick response.

    I’ve added this to the funtions.php file:

    add_action('asp_stripe_payment_completed', 'asp_after_txn_callback', 10 ,2);
    function asp_after_txn_callback ($post_data, $charge)
    {
        //Do stuff
        //$charge is the Stripe charge object.
        //print_r($post_data);//Lets see what info is in this array.
    }

    And added the code you suggested above to my template file. However I’m getting several errors:
    Notice: Undefined variable: data
    Notice: Trying to access array offset on value of type null

Viewing 5 replies - 1 through 5 (of 5 total)