Exemple #1
0
    $contents = "{$timestamp}|{$request['reference_id']}|{$request['status']}";
    $hashKey = "{$apiKey}|{$timestamp}|{$apiSecret}";
    $hash = hash_hmac("sha256", $contents, $hashKey);
    if ($hash !== $remoteHash) {
        MM_DiagnosticLog::log(MM_DiagnosticLog::$MM_ERROR, "Scheduler Endpoint: Authentication Failed ({$hash} <> {$remoteHash})");
        returnStatus('error', 'Authentication Failed');
        exit;
    }
} else {
    MM_DiagnosticLog::log(MM_DiagnosticLog::$MM_ERROR, "System does not support sha256 hmac... proceeding to process schedules without auth");
}
$eventId = $request['reference_id'];
$eventType = $wpdb->get_var("SELECT event_type from " . MM_TABLE_SCHEDULED_EVENTS . " where id='{$eventId}'");
switch ($eventType) {
    case MM_ScheduledEvent::$PAYMENT_SERVICE_EVENT:
        $paymentEvent = new MM_ScheduledPaymentEvent($eventId);
        $billingStatus = $request['status'];
        $paymentEvent->setBillingStatus($billingStatus);
        if ($paymentEvent->getStatus() == MM_ScheduledEvent::$EVENT_PROCESSED) {
            returnStatus("ok", "Event {$eventId} already processed");
        }
        $paymentService = MM_PaymentServiceFactory::getPaymentServiceById($paymentEvent->getPaymentServiceId());
        if (is_null($paymentService)) {
            returnStatus("error", "Improper event configuration: Payment service with id {$paymentService->getPaymentServiceId()} not found");
        }
        $response = $paymentService->processScheduledPaymentEvent($paymentEvent);
        if (MM_PaymentServiceResponse::isError($response) || MM_PaymentServiceResponse::isFailed($response)) {
            returnStatus("error", $response->message);
        }
        returnStatus("ok", "");
        break;
<?php

$orderItem = new MM_OrderItem($p->orderItemId);
if ($orderItem->isValid()) {
    $scheduledPaymentEvent = MM_ScheduledPaymentEvent::findNextScheduledEventByOrderItemId($orderItem->getId(), false);
    if ($scheduledPaymentEvent->isValid()) {
        $crntRebillDate = MM_Utils::dateToLocal($scheduledPaymentEvent->getScheduledDate(), "m/d/Y");
        ?>
<div id='mm-edit-subscription-div'>
<input type='hidden' id='order_item_id' value='<?php 
        echo $p->orderItemId;
        ?>
' />
<a href="#"></a>
<p>Next Rebill Date</p>
<p style="font-size:11px;">
	<input id="mm-next-rebill-date" type="text" style="width: 152px" value="<?php 
        echo $crntRebillDate;
        ?>
" /> 
	<a onClick="jQuery('#mm-next-rebill-date').focus();"><?php 
        echo MM_Utils::getCalendarIcon();
        ?>
</a>
</p>

</div>

<div class="mm-dialog-footer-container">
<div class="mm-dialog-button-container">
<a href="javascript:mmjs.saveSubscription();" class="mm-ui-button blue">Save</a>