function pmpro_insRecurringRestarted($morder) { global $pmpro_error; //hook to do other stuff when payments restart do_action("pmpro_subscription_recuring_restarted", $last_order); $worked = pmpro_changeMembershipLevel($morder->membership_level->id, $morder->user->ID); if ($worked === true) { //$pmpro_msg = __("Your membership has been cancelled.", 'pmpro'); //$pmpro_msgt = "pmpro_success"; //send an email to the member $pmproemail = new PMProEmail(); $pmproemail->sendCheckoutEmail($morder->user, $morder); //send email to admin $pmproemail = new PMProEmail(); $pmproemail->sendCheckoutAdminEmail($morder->user, $morder); inslog("Subscription restarted due to 'recurring restarted' INS notification."); return true; } else { return false; } }
function pmpro_insSaveOrder($txnref, $last_order) { global $wpdb; //check that txn_id has not been previously processed $old_txn = $wpdb->get_var("SELECT payment_transaction_id FROM {$wpdb->pmpro_membership_orders} WHERE payment_transaction_id = '" . $txnref . "' LIMIT 1"); if (empty($old_txn)) { //hook for successful subscription payments do_action("pmpro_subscription_payment_completed"); //save order $morder = new MemberOrder(); $morder->user_id = $last_order->user_id; $morder->membership_id = $last_order->membership_id; $morder->payment_transaction_id = $txnref; $morder->subscription_transaction_id = $last_order->subscription_transaction_id; $morder->InitialPayment = $last_order->InitialPayment; //$_POST['item_list_amount_1']; //not the initial payment, but the class is expecting that $morder->PaymentAmount = $last_order->PaymentAmount; //$_POST['item_list_amount_1']; $morder->gateway = $last_order->gateway; $morder->gateway_environment = $last_order->gateway_environment; //save $morder->saveOrder(); $pmproemail = new PMProEmail(); $pmproemail->sendInvoiceEmail($user_id, $morder); $user = get_userdata($morder->user_id); $user->membership_level = $morder->membership_level; //make sure they have the right level info //send email to member $pmproemail = new PMProEmail(); $pmproemail->sendCheckoutEmail($user_id, $morder); //send email to admin $pmproemail = new PMProEmail(); $pmproemail->sendCheckoutAdminEmail($user_id, $morder); $morder->getMemberOrderByID($morder->id); // //email the user their invoice $pmproemail = new PMProEmail(); $pmproemail->sendInvoiceEmail(get_userdata($last_order->user_id), $morder); if (strpos(PMPRO_INS_DEBUG, "@")) { $log_email = PMPRO_INS_DEBUG; } else { $log_email = get_option("admin_email"); } inslog("New order (" . $morder->code . ") created."); return true; } else { inslog("Duplicate Transaction ID: " . $txnref); return false; } }