} else {
        inslog("ERROR: Couldn't change level for order (" . $morder->code . ").");
    }
    pmpro_twocheckoutExit(pmpro_url("confirmation", "?level=" . $morder->membership_level->id));
}
// Recurring Payment Success (recurring installment success and recurring is true)
if ($message_type == 'RECURRING_INSTALLMENT_SUCCESS') {
    //is this a first payment?
    $last_subscr_order = new MemberOrder();
    if ($last_subscr_order->getLastMemberOrderBySubscriptionTransactionID($txn_id) == false) {
        //first payment, get order
        $morder = new MemberOrder($order_id);
        $morder->getMembershipLevel();
        $morder->getUser();
        //update membership
        if (pmpro_insChangeMembershipLevel($txn_id, $morder)) {
            inslog("Checkout processed (" . $morder->code . ") success!");
        } else {
            inslog("ERROR: Couldn't change level for order (" . $morder->code . ").");
        }
    } else {
        pmpro_insSaveOrder($txn_id, $last_subscr_order);
    }
    pmpro_twocheckoutExit();
}
// Recurring Payment Failed (recurring installment failed and recurring is true)
if ($message_type == 'RECURRING_INSTALLMENT_FAILED' && $recurring) {
    //is this a first payment?
    $last_subscr_order = new MemberOrder();
    $last_subscr_order->getLastMemberOrderBySubscriptionTransactionID($txn_id);
    pmpro_insFailedPayment($last_subscr_order);
Ejemplo n.º 2
0
$order_status = pmpro_getParam('order_status', 'POST');
//$name = explode('=', $_POST['merchant_data']);
if ($order_status === FondyForm::ORDER_APPROVED) {
    $morder = new MemberOrder($order_id);
    $morder->getMembershipLevel();
    $morder->getUser();
    if (isset($_POST['rectoken'])) {
        $id = $morder->id;
        $rec = $wpdb->query("UPDATE `{$wpdb->pmpro_membership_orders}` SET fondy_token = '" . $_POST['rectoken'] . "' WHERE id = " . $id . "");
        //print_r ($rec);die;
    }
    //print_r ($morder->id); die;
    fnlog("ORDER_CREATED: ORDER: " . var_export($morder, true) . "\n---\n");
    if (!empty($morder) && !empty($morder->status) && $morder->status === 'success') {
        fnlog("Checkout was already processed (" . $morder->code . "). Ignoring this request.");
    } elseif (pmpro_insChangeMembershipLevel($order_id, $morder)) {
        fnlog("Checkout processed (" . $morder->code . ") success!");
    } else {
        fnlog("ERROR: Couldn't change level for order (" . $morder->code . ").");
    }
    //echo 1;
    pmpro_fondyExit(pmpro_url("confirmation", "?level=" . $morder->membership_level->id));
} else {
    fnlog("ERROR: (" . $order_status . ").");
}
function fnlog($s)
{
    global $logstr;
    $logstr .= "\t" . $s . "\n";
}
function pmpro_fondyExit($redirect = false)