[PHP] PayPal einbinden

Dieses Thema im Forum "Webentwicklung" wurde erstellt von master2005, 29. Mai 2013 .

Schlagworte:
  1. 29. Mai 2013
    PayPal einbinden

    Guten Abend @ all,

    ich verzweile schon den ganzen halben tag darn, PayPal einzubinden. Ich bin registriert habe meine API angefordert und hänge die ganze Zeit im ingegrationcenter ab. Ich verstehe es leider nicht.

    Ich dachte,ich erhalte einen Link bzw. erstelle ihn mit meiner API und Angaben (Gesamtsumme) und gut ist.

    Kann mir irgendeiner hier helfen ?

    Home | PayPal Developer

    puhh meine Augen
     
  2. 30. Mai 2013
    AW: PayPal einbinden

    Hey,

    gibt doch fertige Dateien von PayPal die man nur noch entsprechend anpassen muss. Also quasi nur noch deinen API-Schlüssel rein:
    Classic API References - PayPal Developer
    bzw.
    REST API Reference - PayPal Developer
    bzw.
    Home | PayPal Developer

    Gruß
    gl
     
  3. 30. Mai 2013
    AW: PayPal einbinden

    Danke für Deine Hilfe.

    Habe mir die Bsp. Dateien runtergeladen.

    habe aber ein problem wenn ich auf die PP Siete geleitet werde stehe da keine Preise bzw. Gesamtpreis und keine Artikelbezeichnungnen. Habe es aber so gemacht, wie es in der Anleitung steht.

    Code:
    <?php
    
    /********************************************
    ReviewOrder.php
    
    This file is called after the user clicks on a button during
    the checkout process to use PayPal's Express Checkout. The
    user logs in to their PayPal account.
    
    This file is called twice.
    
    On the first pass, the code executes the if statement:
    
    if (! isset ($token))
    
    The code collects transaction parameters from the form
    displayed by SetExpressCheckout.html then constructs and
    sends a SetExpressCheckout request string to the PayPal
    server. The paymentType variable becomes the PAYMENTACTION
    parameter of the request string. The RETURNURL parameter
    is set to this file; this is how ReviewOrder.php is called
    twice.
    
    On the second pass, the code executes the else statement.
    
    On the first pass, the buyer completed the authorization in
    their PayPal account; now the code gets the payer details
    by sending a GetExpressCheckoutDetails request to the PayPal
    server. Then the code calls GetExpressCheckoutDetails.php.
    
    Note: Be sure to check the value of PAYPAL_URL. The buyer is
    sent to this URL to authorize payment with their PayPal
    account. For testing purposes, this should be set to the
    PayPal sandbox.
    
    Called by SetExpressCheckout.html.
    
    Calls GetExpressCheckoutDetails.php, CallerService.php,
    and APIError.php.
    
    ********************************************/
    
    require_once 'CallerService.php';
    require_once 'constants.php';
    
    session_start();
    
    /* An express checkout transaction starts with a token, that
     identifies to PayPal your transaction
     In this example, when the script sees a token, the script
     knows that the buyer has already authorized payment through
     paypal. If no token was found, the action is to send the buyer
     to PayPal to first authorize payment
     */
    
    $token = $_REQUEST['token'];
    if(! isset($token)) {
    
     /* The servername and serverport tells PayPal where the buyer
     should be directed back to after authorizing payment.
     In this case, its the local webserver that is running this script
     Using the servername and serverport, the return URL is the first
     portion of the URL that buyers will return to after authorizing payment
     */
     $serverName = $_SERVER['SERVER_NAME'];
     $serverPort = $_SERVER['SERVER_PORT'];
     $url=dirname('http://'.$serverName.':'.$serverPort.$_SERVER['REQUEST_URI']);
    
     $paymentAmount = $_REQUEST['paymentAmount'];
     $currencyCodeType = $_REQUEST['currencyCodeType'];
     $paymentType = $_REQUEST['paymentType'];
     $name = "testprodukt";
    
    
    
     /* The returnURL is the location where buyers return when a
     payment has been succesfully authorized.
     The cancelURL is the location buyers are sent to when they hit the
     cancel button during authorization of payment during the PayPal flow
     */
    
     $returnURL =urlencode($url.'/ReviewOrder.php?currencyCodeType='.$currencyCodeType.'&paymentType='.$paymentType.'&paymentAmount='.$paymentAmount); //Bei erfolgreichen Abschluss
     $cancelURL =urlencode("$url/test.php?paymentType=$paymentType" ); //Wenn man auf abbrechen klickt
    
     /* Construct the parameter string that describes the PayPal payment
     the varialbes were set in the web form, and the resulting string
     is stored in $nvpstr
     */
    
     $nvpstr="&Amt=".$paymentAmount."&PAYMENTACTION=".$paymentType."&ReturnUrl=".$returnURL."&CANCELURL=".$cancelURL ."&CURRENCYCODE=".$currencyCodeType."&L_NAMEn=".$name;
    
     /* Make the call to PayPal to set the Express Checkout token
     If the API call succeded, then redirect the buyer to PayPal
     to begin to authorize payment. If an error occured, show the
     resulting errors
     */
     $resArray=hash_call("SetExpressCheckout",$nvpstr);
     $_SESSION['reshash']=$resArray;
    
     $ack = strtoupper($resArray["ACK"]);
    
     if($ack=="SUCCESS"){
     // Redirect to paypal.com here
     $token = urldecode($resArray["TOKEN"]);
     $payPalURL = PAYPAL_URL.$token;
     header("Location: ".$payPalURL);
     } else {
     //Redirecting to APIError.php to display errors.
     $location = "APIError.php";
     header("Location: $location");
     }
    } else {
     /* At this point, the buyer has completed in authorizing payment
     at PayPal. The script will now call PayPal with the details
     of the authorization, incuding any shipping information of the
     buyer. Remember, the authorization is not a completed transaction
     at this state - the buyer still needs an additional step to finalize
     the transaction
     */
    
     $token =urlencode( $_REQUEST['token']);
    
     /* Build a second API request to PayPal, using the token as the
     ID to get the details on the payment authorization
     */
     $nvpstr="&TOKEN=".$token;
    
     /* Make the API call and store the results in an array. If the
     call was a success, show the authorization details, and provide
     an action to complete the payment. If failed, show the error
     */
     $resArray=hash_call("GetExpressCheckoutDetails",$nvpstr);
     $_SESSION['reshash']=$resArray;
     $ack = strtoupper($resArray["ACK"]);
    
     if($ack=="SUCCESS"){
     require_once "GetExpressCheckoutDetails.php";
     } else {
     //Redirecting to APIError.php to display errors.
     $location = "APIError.php";
     header("Location: $location");
     }
    }
    ?>
    
    
     
  4. 30. Mai 2013
    Zuletzt bearbeitet: 30. Mai 2013
    AW: PayPal einbinden

    PHP:
    $paymentAmount         =        $_REQUEST [ 'paymentAmount' ];
    $currencyCodeType      =        $_REQUEST [ 'currencyCodeType' ];
    $paymentType           =        $_REQUEST [ 'paymentType' ];
    $name  "testprodukt" ;
    Sind bei dir die evtl. $_REQUESTS leer? Nutze da POST bzw. GET, je nach dem - ist sicherer.

    Auf Paypal selbst wird kein Preis angezeigt bei dem Expresscheckout.
    Der Nutzer wird auf Paypal weitergeleitet und meldet sich an und wählt sein Konto/Zahlugnsmethode aus. Wenn er auf weiter klickt wird er auf deine Seite (in "$returnURL") zurückgeschickt. Dort sieht er die Bestellung mit Preis und Details und muss die Zahlung ein letztes mal bestätigen. Erst dann hat er den Artikel gekauft.

    Kann auch sein, dass ich grad was durcheinanderbringe

    Gruß
    gl

    Edit:
    Jo, es ist nicht möglich den Warenkorb mitzuübergeben (s. S.33ff. Existing Developer Products - PayPal Developer)

    Du musst dir eben eine schöne Bestellbestätigungsseite basteln. Auf diese Seite wird der Nutzer nach dem einloggen bei paypal zurückgeleitet, sieht eben nochmal den warenbkorb und kauft endgültig ein. (s. S.37)
    Und zuletzt eben die Auftragsbestätigungsseite (S. 42).
     
    1 Person gefällt das.
  5. 31. Mai 2013
    AW: PayPal einbinden

    Danke für Deine Hilfe.

    Würde es aber lieber so machen wie es gängi ist. Man wird auf PP weitergeleitet, und bestätige da die Zahlung. (Ist doch gängig oder?)
     
  6. 31. Mai 2013
    AW: PayPal einbinden

    Immer mehr Shops nehmen den ExpressCheckout. Finde ihn persönlich auch schöner

    Was Du willst müsste "PayPal Starter" sein: Home | PayPal Developer

    Gruß
    gl
     
  7. 31. Mai 2013
    AW: PayPal einbinden

    Danke Dir,

    also wäre es sinnvoller Express zu verwenden ?

    Habe ihc das richtig verstanden?-> Bei PP Express werde ich auf PP geleitet da autorisiere ich mich, werde zurück in meinen Warenkorb geleitetn und da vollende ich meine Bestellung inkl. zahlung ?

    Habe mir die ganze PDF zu der API durchgelesen. Die würde ich auch verwnden, aber aus meiner sicht steht da kaum was drinne. Bin ich blind oder wie sehe ich das ?
    Da steht gar nicht genau drinne wie man PP einbindet.
     
  8. 1. Juni 2013
    AW: PayPal einbinden

    Das musst Du für Dich entscheiden. Ich halte es für recht sicher und schwierig zu manipulieren. Daher habe ich diese Methode bei uns eingebunden. Außerdem geht es recht schnell =)
    Ganz genau
    Ja, die Doku ist nicht sooo der Burner
    Musst einfach viel probieren oder die fertigen Dateien hernehmen und abändern (so hab ichs gemacht).

    Gruß
    gl
     
  9. 3. Juni 2013
    AW: PayPal einbinden

    ich mein bei express läuft es so ab:
    - bezahlen von deinem shop (button klick)
    - weiterleitung zu PP
    - in PP bezahlen
    - zurück zu deinem shop
    - überprüfen ob bezahlt wurde und rückgabe von PP auf richtigkeit überprüfen!
    - deine bestellung fertig machen
     
  10. 3. Juni 2013
    AW: PayPal einbinden

    Falsch.

    Man wird auf PP geleitet und loggt sich dort ein. Wählt seine Zahlungsmethode (Lastschrift, Kreditkarte, whatever) und wird zurück auf den Shop geschickt. Dort sieht man die Bestellübersicht und kauft erst dort ein und bestätigt die Zahlung über den Shop an Paypal. Die Bezahlung erfolgt nicht auf der Paypal-Seite!
     
    1 Person gefällt das.
  11. Video Script

    Videos zum Themenbereich

    * gefundene Videos auf YouTube, anhand der Überschrift.