Esempio n. 1
0
function updatePaymentMethod()
{
    global $messages;
    $pmId = $_REQUEST['pmId'];
    $updRes = PaymentManager::changePaymentMethod($_SESSION['accountId'], $pmId);
    $messages = $updRes;
}
Esempio n. 2
0
function test_ChangeDefaultPaymentMethod()
{
    global $EXISTING_CUSTOMER_ACCOUNT_NAME;
    printResultStart(__FUNCTION__);
    $messages = array();
    $pmId;
    $checkPmId;
    try {
        $zapi = new zApi();
        $pres = $zapi->zQuery("SELECT DefaultPaymentMethodId FROM Account WHERE Name='" . $EXISTING_CUSTOMER_ACCOUNT_NAME . "'");
        if (count($pres->result->records) == 0) {
            throw new Exception("ACCOUNT_DOESNT_EXIST");
        }
        $pmId = $pres->result->records[0]->DefaultPaymentMethodId;
        $cpmres = $zapi->zQuery("SELECT Id from PaymentMethod where Name='Check'");
        //Test
        echo "Updating Default Payment Method on Account " . $EXISTING_CUSTOMER_ACCOUNT_NAME . " to 'Check': <br>";
        $changeRes = PaymentManager::changePaymentMethod($EXISTING_CUSTOMER_ACCOUNT_NAME, $pmId);
        print_r_html($changeRes);
        echo "Updating Default Payment Method on Account " . $EXISTING_CUSTOMER_ACCOUNT_NAME . " back to original payment method: <br>";
        $changeRes = PaymentManager::changePaymentMethod($EXISTING_CUSTOMER_ACCOUNT_NAME, $pmId);
        print_r_html($changeRes);
    } catch (Exception $e) {
        array_push($messages, $e->getMessage());
    }
    printResultEnd($messages);
}