Run command when payment is taken

Discussion in 'Customization & add-ons' started by alexblyz91, Mar 5, 2020.

Thread Status:
Not open for further replies.
  1. alexblyz91

    alexblyz91 New Member

    Joined:
    Aug 9, 2019
    Messages:
    24
    Hi,
    I am using
    Code:
    Am_Di::getInstance()->hook->add(Am_Event::USER_AFTER_INSERT, function (Am_Event $e) {
    
    in site.php to run scripts when a new user sign up, im just wondering if their is also a version for if user submits a payment/completes purchase for a membership?

    Thanks
  2. caesar

    caesar aMember Pro Developer Staff Member

    Joined:
    Oct 16, 2009
    Messages:
    2,295
    Hello,

    Here you are:

    PHP:
    Am_Di::getInstance()->hook->add(Am_Event::PAYMENT_AFTER_INSERT, function (Am_Event $e) {
        
    /** @var InvoicePayment $payment */
        
    $payment $e->getPayment();
        
    /** @var User $user */
        
    $user $payment->getUser();
    });
  3. alexblyz91

    alexblyz91 New Member

    Joined:
    Aug 9, 2019
    Messages:
    24
    Thanks again!
    caesar likes this.
Thread Status:
Not open for further replies.

Share This Page