コード例 #1
0
 private function _create_CIM_payment_profile(AuthorizeNetPaymentProfile $payment_profile, $validation = 'liveMode')
 {
     if ($this->debug) {
         s('creating new payment profile');
     }
     $this->_responses['PaymentProfileResponse'] = $this->createCustomerPaymentProfile($this->CIMCustID, $payment_profile, $validation);
     $this->_responses['last'] = $this->_responses['PaymentProfileResponse'];
     if ($this->_responses['PaymentProfileResponse']->isOk()) {
         // success
         $this->PymtRefCrdCd = substr($this->info->card_num, -4);
         $this->CIMPymtProfID = $this->_responses['PaymentProfileResponse']->getPaymentProfileId();
         if ($this->debug) {
             s('New PymtProfID: ' . $this->CIMPymtProfID);
         }
     } else {
         if ($this->debug) {
             s('error in creating payment profile');
         }
         if ($this->_responses['last']->getMessageCode() == 'E00039' || $this->_responses['last']->getMessageCode() == 'E00042') {
             // duplicate exists or max profiles reached
             if ($this->debug) {
                 s('duplicate or overflow');
             }
             $profiles = $this->getCustomerProfile($this->CIMCustID)->xml->profile->paymentProfiles;
             foreach ($profiles as $profile) {
                 if ($profile->billTo->firstName == $payment_profile->billTo->firstName && $profile->billTo->lastName == $payment_profile->billTo->lastName && $profile->billTo->address == $payment_profile->billTo->address && $profile->billTo->zip == $payment_profile->billTo->zip && $profile->billTo->phoneNumber == ($payment_profile->billTo->phoneNumber ? $payment_profile->billTo->phoneNumber : '') && substr($profile->payment->creditCard->cardNumber, -4) == substr($payment_profile->payment->creditCard->cardNumber, -4)) {
                     $this->CIMPymtProfID = strip_tags($profile->customerPaymentProfileId->asXML());
                     if ($this->debug) {
                         s("found duplicate with ID {$this->CIMPymtProfID}");
                     }
                     $this->update_CIM_payment_profile($validation);
                     break;
                 }
             }
         } else {
             if ($this->debug) {
                 ri($this->_responses['PaymentProfileResponse']);
                 ri($payment_profile);
             }
             throw new Exception('Error while creating payment profile');
             //$this->print_error_message();
             //die;
         }
         if (!$this->CIMPymtProfID) {
             if ($this->_responses['last']->getMessageCode() == 'E00042') {
                 // overflow and no duplicate found
                 $this->_CIMMod++;
                 if ($this->debug) {
                     s('Payment profile overflow, going to mod ' . $this->_CIMMod);
                 }
                 if ($this->_CIMMod == 10) {
                     //die('CIM Customer Profile Overflow');
                     throw new Exception('Error while creating payment profile');
                 }
                 $this->update_CIM_customer_profile();
                 $this->update_CIM_payment_profile($validation);
             } else {
                 if ($this->debug) {
                     ri($this->_responses['PaymentProfileResponse']);
                     ri($payment_profile);
                 }
                 throw new Exception('Error while creating payment profile');
                 //$this->print_error_message();
                 //die;
             }
         }
     }
 }
コード例 #2
0
ファイル: ri.php プロジェクト: qw3rtman/ri
            $intensities[$i] = $tier_average + round(($input[$i] - $average) / $per_upper_tier);
        } else {
            if ($input[$i] < $average) {
                // Less than "normal".
                $intensities[$i] = $tier_average - round(($average - $input[$i]) / $per_lower_tier);
            } else {
                // Same as "normal".
                $intensities[$i] = $tier_average;
            }
        }
    }
    return $intensities;
}
// Examples.
// Random values.
echo json_encode(ri([7.3, 4.2, 5.7, 12.3, 8.6, 7.2, 9.4, 4.3, 5.6, 8.199999999999999])) . "\n";
// Gradual increase.
echo json_encode(ri([1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 6, 6.5, 7, 7.5])) . "\n";
// Gradual decrease.
echo json_encode(ri([7.5, 7, 6.5, 6, 5.5, 5, 4.5, 4, 3.5, 3, 2.5, 2, 1.5, 1])) . "\n";
// Gradual increase followed by gradual decrease.
echo json_encode(ri([1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 6, 6.5, 7, 7.5, 7, 6.5, 6, 5.5, 5, 4.5, 4, 3.5, 3, 2.5, 2, 1.5, 1])) . "\n";
// Stagnant with dip.
echo json_encode(ri([12, 12, 12, 12, 12, 12, 12, 8, 12, 12, 12, 12, 12, 12, 12])) . "\n";
// Stagnant with rise.
echo json_encode(ri([8, 8, 8, 8, 8, 8, 8, 12, 8, 8, 8, 8, 8, 8, 8])) . "\n";
// Stagnant.
echo json_encode(ri([12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12])) . "\n";
// No data provided.
echo json_encode(ri()) . "\n";
コード例 #3
0
    public function can_be_used($CustomerID, $table, $debug = 0){
        $CustomerID = (int) $CustomerID;
        $table = dbi()->escape($table);

        if(!$CustomerID){ // new customers can use any promo code
            return true;
        }

        $date = Gadget::$date_do->format(DATE_FORMAT_MYSQL);

        if($table === 'Orders' || $table === 'Subscriptions' || $table === 'GiftCertificates') {
            $table = 'Orders';
            $table2 = 'Subscriptions';
            $table3 = 'GiftCertificates';
        } else {
            $table2 = 'Orders';
            $table3 = 'GiftCertificates';
        }

        if($this->One_Time_Only){
            if(dbi()->q_n("SELECT PromoCodeID FROM $table WHERE CustomerID = '$CustomerID' AND DeliveryDate <= '$date' AND PromoCodeID = '$this->PromoCodeID'
                            UNION
                            SELECT PromoCodeID FROM $table2 WHERE CustomerID = '$CustomerID' AND DeliveryDate < '$date' AND PromoCodeID = '$this->PromoCodeID'
                            UNION
                            SELECT PromoCodeID FROM $table3 WHERE CustomerID = '$CustomerID' AND PromoCodeID = '$this->PromoCodeID'")){ // already in use on another order
                return false;
            }
        }

        if($this->New_Customer_Only){
            if ($debug == 1){
                ri("SELECT PromoCodeID FROM $table WHERE CustomerID = '$CustomerID' AND DeliveryDate <= '$date'
                    UNION
                    SELECT PromoCodeID FROM $table2 WHERE CustomerID = '$CustomerID' AND DeliveryDate < '$date'
                    UNION
                    SELECT PromoCodeID FROM $table3 WHERE CustomerID = '$CustomerID'");
            }
            if(dbi()->q_n("SELECT PromoCodeID FROM $table WHERE CustomerID = '$CustomerID' AND DeliveryDate <= '$date'
                            UNION
                            SELECT PromoCodeID FROM $table2 WHERE CustomerID = '$CustomerID' AND DeliveryDate < '$date'
                            UNION
                            SELECT PromoCodeID FROM $table3 WHERE CustomerID = '$CustomerID'")){ // not this customer's first order
                return false;
            }
        }
        return true;
    }
コード例 #4
0
ファイル: x4IndexLib.php プロジェクト: KlabsTechnology/andro
function x4SQL($sql)
{
    $dbconn = $GLOBALS['AG']['dbconn'];
    pg_send_query($dbconn, $sql);
    $results = pg_get_result($dbconn);
    $t = pg_result_error($results);
    $error = false;
    if ($t) {
        // Made conditional 1/24/07 KFD
        // In x4, made universal
        //if(SessionGet('ADMIN',false)) {
        x4Error("(ADMIN): You are logged in as an administrator, you will see " . " more detail than a regular user.");
        x4Error("(ADMIN): " . $sql);
        // Save them separately so they can be dealt with on the
        // browser if need be
        ri('message', 'sql', $sql);
        //}
        $ts = explode(";", $t);
        foreach ($ts as $onerr) {
            if (trim($onerr) == '') {
                continue;
            }
            x4Error($onerr);
        }
        // Now save the original unsplit errors for return to browser
        $t = trim(str_replace('ERROR: ', '', $t));
        $t = str_replace("\n", '', $t);
        ri('message', 'sqlerr', $t);
    }
    return $results;
}