Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You have to follow only three steps:</p> <p>1- You send a PayRequest message to PayPal</p> <blockquote> <p>{"returnUrl":"http://example.com/returnURL.htm", \ "requestEnvelope":{"errorLanguage":"en_US"},"currencyCode":"USD", \ "receiverList":{"receiver":[{"email":"david@example.com", \ "amount":"10.00",}]},"cancelUrl":"http://example.com/cancelURL.htm",\ "actionType":"PAY"}</p> </blockquote> <p>2- You receive a response with a pay key.</p> <blockquote> <p>{"responseEnvelope":\ {"timestamp":"2009-10-06T14:30:39.383-07:00","ack":"Success",\ "correlationId":"cfe8f8783f1d3","build":"DEV"},\ "payKey":"AP-17266198048308436","paymentExecStatus":"CREATED"}</p> </blockquote> <p>3- You must redirect the sender’s browser to PayPal to approve the payment.</p> <p>This would be an example code for step 1 (it works on my local server):</p> <pre><code>&lt;?php //turn php errors on ini_set("track_errors", true); //set PayPal Endpoint to sandbox $url = trim("https://svcs.sandbox.paypal.com/AdaptivePayments/Pay"); $api_appid = 'APP-80W284485P519543T'; // para sandbox //PayPal API Credentials $API_UserName = "sbapi_1287090601_biz_api1.paypal.com"; //TODO $API_Password = "1287090610"; //TODO $API_Signature = "ANFgtzcGWolmjcm5vfrf07xVQ6B9AsoDvVryVxEQqezY85hChCfdBMvY"; //TODO $receiver_email = "fake@email.com"; //TODO $amount = 25; //TODO //Default App ID for Sandbox $API_AppID = "APP-80W284485P519543T"; $API_RequestFormat = "NV"; $API_ResponseFormat = "NV"; //Create request payload with minimum required parameters $bodyparams = array ( "requestEnvelope.errorLanguage" =&gt; "en_US", "actionType" =&gt; "PAY", "cancelUrl" =&gt; "http://cancelUrl", "returnUrl" =&gt; "http://returnUrl", "currencyCode" =&gt; "EUR", "receiverList.receiver.email" =&gt; $receiver_email, "receiverList.receiver.amount" =&gt; $amount ); // convert payload array into url encoded query string $body_data = http_build_query($bodyparams, "", chr(38)); try { //create request and add headers $params = array("http" =&gt; array( "method" =&gt; "POST", "content" =&gt; $body_data, "header" =&gt; "X-PAYPAL-SECURITY-USERID: " . $API_UserName . "\r\n" . "X-PAYPAL-SECURITY-SIGNATURE: " . $API_Signature . "\r\n" . "X-PAYPAL-SECURITY-PASSWORD: " . $API_Password . "\r\n" . "X-PAYPAL-APPLICATION-ID: " . $API_AppID . "\r\n" . "X-PAYPAL-REQUEST-DATA-FORMAT: " . $API_RequestFormat . "\r\n" . "X-PAYPAL-RESPONSE-DATA-FORMAT: " . $API_ResponseFormat . "\r\n" )); //create stream context $ctx = stream_context_create($params); //open the stream and send request $fp = @fopen($url, "r", false, $ctx); //get response $response = stream_get_contents($fp); //check to see if stream is open if ($response === false) { throw new Exception("php error message = " . "$php_errormsg"); } //close the stream fclose($fp); //parse the ap key from the response $keyArray = explode("&amp;", $response); foreach ($keyArray as $rVal){ list($qKey, $qVal) = explode ("=", $rVal); $kArray[$qKey] = $qVal; } //print the response to screen for testing purposes If ( $kArray["responseEnvelope.ack"] == "Success") { foreach ($kArray as $key =&gt;$value){ echo $key . ": " .$value . "&lt;br/&gt;"; } } else { echo 'ERROR Code: ' . $kArray["error(0).errorId"] . " &lt;br/&gt;"; echo 'ERROR Message: ' . urldecode($kArray["error(0).message"]) . " &lt;br/&gt;"; } } catch(Exception $e) { echo "Message: ||" .$e-&gt;getMessage()."||"; } ?&gt; </code></pre> <p>You have many examples here: <a href="https://www.x.com/developers/paypal/documentation-tools/paypal-code-samples" rel="nofollow">https://www.x.com/developers/paypal/documentation-tools/paypal-code-samples</a></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload