Jump to content

Cant get the code right for Paypal Digital Payment PHP!


wrigaz

Recommended Posts

Hi all,

 

Basically I am an absolute novice at php and am only just getting my head around all the terminology Basically a programmer built me a site where I want a simple payment to go through my Paypal for a digital deliver good. The code built into my site copied and pasted is the following:

 

<?php

 

/*

* Code from paypal....

* but modified a bit

*/

 

 

/** SetExpressCheckout NVP example; last modified 08MAY23.

*

*  Initiate an Express Checkout transaction.

*/

 

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

 

/**

* Send HTTP POST Request

*

* @param string The API method name

* @param string The POST Message fields as an arrayt

* @return array Parsed HTTP Response body

*/

function paypalAPI($methodName_, $nvpAss_) {

global $environment;

        global $paypal_username;

        global $paypal_password;

        global $paypal_signature;

 

        $version = '65.1';

 

$API_Endpoint = "https://api-3t.paypal.com/nvp";

if("sandbox" === $environment || "beta-sandbox" === $environment) {

$API_Endpoint = "https://api-3t.$environment.paypal.com/nvp";

}

 

 

// Set the curl parameters.

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $API_Endpoint);

curl_setopt($ch, CURLOPT_VERBOSE, 1);

 

// Turn 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);

 

// Set the API operation, version, and API signature in the request.

$nvpAss_['METHOD']    = urlencode($methodName_);

        $nvpAss_['VERSION']  = urlencode($version);

        $nvpAss_['PWD']      = urlencode($paypal_password);

        $nvpAss_['USER']      = urlencode($paypal_username);

        $nvpAss_['SIGNATURE'] = urlencode($paypal_signature);

 

 

        $nvpArr = Array();

        foreach($nvpAss_ as $name=>$value){

            $nvpArr[] = urlencode($name) . '=' . urlencode($value);

        }

 

        $nvpreq = join('&', $nvpArr);

       

// Set the request as a POST FIELD for curl.

curl_setopt($ch, CURLOPT_POSTFIELDS, $nvpreq);

 

// Get response from the server.

$httpResponse = curl_exec($ch);

 

if(!$httpResponse) {

exit("$methodName_ failed: ".curl_error($ch).'('.curl_errno($ch).')');

}

 

// Extract the response details.

$httpResponseAr = explode("&", $httpResponse);

 

$httpParsedResponseAr = array();

foreach ($httpResponseAr as $i => $value) {

$tmpAr = explode("=", $value);

if(sizeof($tmpAr) > 1) {

$httpParsedResponseAr[$tmpAr[0]] = urldecode($tmpAr[1]);

}

}

 

if((0 == sizeof($httpParsedResponseAr)) || !array_key_exists('ACK', $httpParsedResponseAr)) {

exit("Invalid HTTP Response for POST request($nvpreq) to $API_Endpoint.");

}

 

return $httpParsedResponseAr;

}

 

?>

 

 

 

:'( On the configuration php file it is the following:

 

//paypal

/*

* Please go to https://www.paypal-business.com.au/ for general infrmation about

* how to make money via paypal.

*/

 

$paypal_enable          = true;

 

/*

*  The email of the paypal account.

*/

$paypal_username        = DELETED FOR THIS POST BUT IS ALL CORRECT;

/*

* Signiture of your buisness paypal account.

*/

$paypal_signature      = 'AMxxxxxxxxDELETED FOR THIS POST BUT IS ALL CORRECTxxxxxxxxxxxxxxxxxxxx';

 

$paypal_password      = 'STXXXXXDELETED FOR THIS POST  BUT IS ALL CORRECTXXXXXXXXXX';

/*

* The currency you want the be payed in.

* see https://cms.paypal.com/us/cgi-bin/?&cmd=_render-content&content_ID=developer/e_howto_api_nvp_currency_codes

*/

$paypal_currency        = 'AUD';

 

// Price

$paypal_amount          = '1.00';

 

// Header Image on PayPal  750x90px max.

$paypal_headerImage    = 'http://i51.tinypic.com/24uzuc6.jpg';

 

// nec. for paypal loop back e.g. sauer.com

$serverName            = 'ratemetoday.com';

 

 

 

:wtf: So with all that code into my site it still shows the following error:

 

SetExpressCheckout failed: Array ( [TIMESTAMP] => 2011-07-12T06:43:23Z [CORRELATIONID] => 5cb86566291fa [ACK] => Failure [VERSION] => 65.1 [bUILD] => 1968762 [L_ERRORCODE0] => 10004 [L_SHORTMESSAGE0] => Transaction refused because of an invalid argument. See additional error messages for details. [L_LONGMESSAGE0] => You are not signed up to accept payment for digitally delivered goods. [L_SEVERITYCODE0] => Error )

 

 

 

 

:-\ ANYBODY got any idea whats going on with this???? Is something missing?? Please help with as little jargon as possible! :confused:

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.