Esempio n. 1
0
<?php 
require_once osc_themes_path() . 'nepcoders/includes/paypal-api.php';
if (isset($_POST['submit'])) {
    $username = Params::getParam("username");
    $password = Params::getParam("password");
    $signature = Params::getParam("signature");
    $url = Params::getParam("server");
    $status = Params::getParam("status");
    if ($status == "on") {
        $enable = TRUE;
    } else {
        $enable = FALSE;
    }
    $credentials = array('USER' => $username, 'PWD' => $password, 'SIGNATURE' => $signature);
    $method = array('METHOD' => 'GetBalance', 'VERSION' => '74.0');
    $data = PaypalAPI::execute_post($url, array(), $credentials, $method);
    if ($data['ACK'] == 'Failure') {
        echo returnErrorMsgWithHeader($data['L_SHORTMESSAGE0'], $data['L_LONGMESSAGE0']);
    } else {
        if ($data['ACK'] == 'Success') {
            echo returnSuccessMsgWithHeader("Your Available Balance", $data['L_CURRENCYCODE0'] . " " . $data['L_AMT0']);
            $_credentials = Paypal::newInstance()->selectPaypalData();
            if ($_credentials == null) {
                Paypal::newInstance()->insertPaypalData($username, $password, $signature, $url);
            } else {
                Paypal::newInstance()->updatePaypalData($username, $password, $signature, $url, $enable, $_credentials['pk_pp_username']);
            }
        }
    }
}
$_credentials = Paypal::newInstance()->selectPaypalData();