• Jetzt anmelden. Es dauert nur 2 Minuten und ist kostenlos!

Paypal Kontostand abfragen per Browser

martinpz

Neues Mitglied
Hallo,

Hi ich habe bereits erfolgreich die API eingerichtet und bekomme auch beim Aufruf eine gültige Antwort.

Untitled Document (ist ein Testzugang)

nun möchte ich es so haben, dass mir der Kontostand in vernünftiger Ansicht (html oder php) angezeigt wird.

Wie es aussehen soll:

Ihr Kontostand beträgt: 500,00 EUR

Wie mache ich das am besten?


ich weiss dass mit urlencode gehen soll, aber nur wie?


Die Doku von PP bringt mich nicht wirklich weiter
 
urldecode wohl in dem Fall.

PHP:
<?php

$response = array(
    'L_AMT0'    => '500%2e00',
    'TIMESTAMP' => '2011%2d03%2d28T18%3a59%3a06Z'
    // usw.
);

$response = array_map('urldecode', $response);

var_dump($response);
 
Hi,

vielen Dank.

Nun schauts so aus:

Code:
array(2) {   ["L_AMT0"]=>   string(6) "500.00"   ["L_CURRENCYCODE0"]=>   string(3) "EUR" }
kann das noch umgebaut werden, das es so ausschaut:
Code:
Sie haben 500,00€ auf Ihrem Konto
Die php-Datei:

PHP:
<?php

$environment = 'sandbox';    // or 'beta-sandbox' or 'live'

/**
 * Send HTTP POST Request
 *
 * @param    string    The API method name
 * @param    string    The POST Message fields in &name=value pair format
 * @return    array    Parsed HTTP Response body
 */
function PPHttpPost($methodName_, $nvpStr_) {
    global $environment;

    $API_UserName = urlencode('info_1301318824_biz_api1.xxxxx.de');
    $API_Password = urlencode('PLGSKTxxxxxSSD8Z8');
    $API_Signature = urlencode('AQU0e5vxxxxxxxxZPkDoe5nrhgNxPgGxQa9u13tsBV');
    $API_Endpoint = "https://api-3t.paypal.com/nvp";
    if("sandbox" === $environment || "beta-sandbox" === $environment) {
        $API_Endpoint = "https://api-3t.$environment.paypal.com/nvp";
    }
    $version = urlencode('51.0');

    // setting the curl parameters.
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $API_Endpoint);
    curl_setopt($ch, CURLOPT_VERBOSE, 1);

    // turning off the server and peer verification(TrustManager Concept).
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);

    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POST, 1);

    // NVPRequest for submitting to server
    $nvpreq = "METHOD=$methodName_&VERSION=$version&PWD=$API_Password&USER=$API_UserName&SIGNATURE=$API_Signature$nvpStr_";

    // setting the nvpreq as POST FIELD to curl
    curl_setopt($ch, CURLOPT_POSTFIELDS, $nvpreq);

    // getting response from server
    $httpResponse = curl_exec($ch);

    if(!$httpResponse) {
        exit("$methodName_ failed: ".curl_error($ch).'('.curl_errno($ch).')');
    }

    // Extract the RefundTransaction response details
    $httpResponseAr = explode("&", $httpResponse);

    $httpParsedResponseAr = array();
    foreach ($httpResponseAr as $i => $value) {
        $tmpAr = explode("=", $value);
        if(sizeof($tmpAr) > 1) {
            $httpParsedResponseAr[$tmpAr[0]] = $tmpAr[1];
        }
    }

    if((0 == sizeof($httpParsedResponseAr)) || !array_key_exists('ACK', $httpParsedResponseAr)) {
        exit("Invalid HTTP Response for POST request($nvpreq) to $API_Endpoint.");
    }

    return $httpParsedResponseAr;
}

$nvpStr="";

$httpParsedResponseAr = PPHttpPost('GetBalance', $nvpStr);

if("SUCCESS" == strtoupper($httpParsedResponseAr["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($httpParsedResponseAr["ACK"])) {
    //exit('GetBalance Completed Successfully: '.print_r($httpParsedResponseAr, true));
    $response = array(
            'L_AMT0'    => '500%2e00',
            //'TIMESTAMP' => '2011%2d03%2d28T18%3a59%3a06Z',
            'L_CURRENCYCODE0' => 'EUR',
            // usw.
        );

        $response = array_map('urldecode', $response);

        var_dump($response);
} else  {
    exit('GetBalance failed: ' . print_r($httpParsedResponseAr, true));
}
        

?>
 
Mir ist unklar, wo das Problem liegt. Das ist doch eine simple String-Zusammenfügung, oder?

Wahrscheinlich habe ich es falsch verstanden.
 
Vielleicht solltest du, statt einfach zu fressen was dir hingeworfen wird, einfach mal ins Manual gucken, was a) var_dump() macht b) ein Array ist c) wie man Teile eine Arrays ausgibt und d) als String zusammenfügt.
 

Neueste Beiträge

Zurück
Oben