function pmpro_insFailedPayment($last_order)
{
    //hook to do other stuff when payments fail
    do_action("pmpro_subscription_payment_failed", $last_order);
    //create a blank order for the email
    $morder = new MemberOrder();
    $morder->user_id = $last_order->user_id;
    // Email the user and ask them to update their credit card information
    $pmproemail = new PMProEmail();
    $pmproemail->sendBillingFailureEmail($user, $morder);
    // Email admin so they are aware of the failure
    $pmproemail = new PMProEmail();
    $pmproemail->sendBillingFailureAdminEmail(get_bloginfo("admin_email"), $morder);
    inslog("Payment failed. Emails sent to " . $user->user_email . " and " . get_bloginfo("admin_email") . ".");
    return true;
}
         $morder->billing->city = $old_order->billing->city;
         $morder->billing->state = $old_order->billing->state;
         $morder->billing->zip = $old_order->billing->zip;
         $morder->billing->country = $old_order->billing->country;
         $morder->billing->phone = $old_order->billing->phone;
         //get CC info that is on file
         $morder->cardtype = get_user_meta($user_id, "pmpro_CardType", true);
         $morder->accountnumber = hideCardNumber(get_user_meta($user_id, "pmpro_AccountNumber", true), false);
         $morder->expirationmonth = get_user_meta($user_id, "pmpro_ExpirationMonth", true);
         $morder->expirationyear = get_user_meta($user_id, "pmpro_ExpirationYear", true);
         // Email the user and ask them to update their credit card information
         $pmproemail = new PMProEmail();
         $pmproemail->sendBillingFailureEmail($user, $morder);
         // Email admin so they are aware of the failure
         $pmproemail = new PMProEmail();
         $pmproemail->sendBillingFailureAdminEmail(get_bloginfo("admin_email"), $morder);
         $logstr .= "Subscription payment failed on order ID #" . $old_order->id . ". Sent email to the member and site admin.";
         pmpro_stripeWebhookExit();
     } else {
         $logstr .= "Could not find the related subscription for event with ID #" . $event->id . ".";
         if (!empty($event->data->object->customer)) {
             $logstr .= " Customer ID #" . $event->data->object->customer . ".";
         }
         pmpro_stripeWebhookExit();
     }
 } elseif ($event->type == "customer.subscription.deleted") {
     //for one of our users? if they still have a membership, notify the admin
     $user = getUserFromCustomerEvent($event, "success", true);
     if (!empty($user->ID)) {
         do_action("pmpro_stripe_subscription_deleted", $user->ID);
         $pmproemail = new PMProEmail();
Exemplo n.º 3
0
function pmpro_ipnFailedPayment($last_order)
{
    //hook to do other stuff when payments fail
    do_action("pmpro_subscription_payment_failed", $last_order);
    //create a blank order for the email
    $morder = new MemberOrder();
    $morder->user_id = $last_order->user_id;
    //add billing information if appropriate
    if ($last_order->gateway == "paypal") {
        $morder->billing->name = $_POST['address_name'];
        $morder->billing->street = $_POST['address_street'];
        $morder->billing->city = $_POST['address_city '];
        $morder->billing->state = $_POST['address_state'];
        $morder->billing->zip = $_POST['address_zip'];
        $morder->billing->country = $_POST['address_country_code'];
        $morder->billing->phone = get_user_meta($morder->user_id, "pmpro_bphone", true);
        //get CC info that is on file
        $morder->cardtype = get_user_meta($morder->user_id, "pmpro_CardType", true);
        $morder->accountnumber = hideCardNumber(get_user_meta($morder->user_id, "pmpro_AccountNumber", true), false);
        $morder->expirationmonth = get_user_meta($morder->user_id, "pmpro_ExpirationMonth", true);
        $morder->expirationyear = get_user_meta($morder->user_id, "pmpro_ExpirationYear", true);
    }
    // Email the user and ask them to update their credit card information
    $pmproemail = new PMProEmail();
    $pmproemail->sendBillingFailureEmail($user, $morder);
    // Email admin so they are aware of the failure
    $pmproemail = new PMProEmail();
    $pmproemail->sendBillingFailureAdminEmail(get_bloginfo("admin_email"), $morder);
    ipnlog("Payment failed. Emails sent to " . $user->user_email . " and " . get_bloginfo("admin_email") . ".");
    return true;
}