Online Book Reader

Home Category

PayPal APIs_ Up and Running_ A Developer's Guide - Michael Balderas [20]

By Root 159 0
city.

$shipToState = $resArray["SHIPTOSTATE"]; // ' State or province.

$shipToCntryCode = $resArray["SHIPTOCOUNTRYCODE"]; // ' Country code.

$shipToZip = $resArray["SHIPTOZIP"]; // ' U.S. Zip code or other country-specific

// postal code.

$addressStatus = $resArray["ADDRESSSTATUS"]; // ' Status of street address on file

// with PayPal.

$invoiceNumber = $resArray["INVNUM"]; // ' Your own invoice or tracking number, as set

// by you in the element of the same name.

//in SetExpressCheckout request.

$phoneNumber = $resArray["PHONENUM"]; // ' Payer's contact telephone number. Note:

// PayPal returns a contact telephone number only

// if your Merchant account profile settings require

// that the buyer enter one.

}

else

{

//Display a user-friendly Error on the page using any of the following error

//information returned by PayPal.

$ErrorCode = urldecode($resArray["L_ERRORCODE0"]);

$ErrorShortMsg = urldecode($resArray["L_SHORTMESSAGE0"]);

$ErrorLongMsg = urldecode($resArray["L_LONGMESSAGE0"]);

$ErrorSeverityCode = urldecode($resArray["L_SEVERITYCODE0"]);

echo "GetExpressCheckoutDetails API call failed. ";

echo "Detailed Error Message: " . $ErrorLongMsg;

echo "Short Error Message: " . $ErrorShortMsg;

echo "Error Code: " . $ErrorCode;

echo "Error Severity Code: " . $ErrorSeverityCode;

}

}

?>

Example 2-5. orderconfirmation.php

/*==================================================================

PayPal Express Checkout Call

===================================================================

*/

require_once ("paypalfunctions.php");

if ( $PaymentOption == "PayPal" )

{ /*

'------------------------------------

' The paymentAmount is the total value of

' the shopping cart, which was set

' earlier in a session variable

' by the shopping cart page.

'------------------------------------

*/

$finalPaymentAmount = $_SESSION["Payment_Amount"];

/*

'------------------------------------

' Calls the DoExpressCheckoutPayment API call

'

' The ConfirmPayment function is defined in the file PayPalFunctions.jsp,

' included at the top of this file.

'-------------------------------------------------

*/

$resArray = ConfirmPayment ( $finalPaymentAmount );

$ack = strtoupper($resArray["ACK"]);

if( $ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING" )

{

/*

'************************************************************************************

'

' THE PARTNER SHOULD SAVE THE KEY TRANSACTION-RELATED INFORMATION SUCH AS

' transactionId & orderTime

' IN THEIR OWN DATABASE AND THE REST OF THE INFORMATION

' CAN BE USED TO UNDERSTAND THE STATUS OF THE PAYMENT

'

'************************************************************************************

*/

$transactionId = $resArray["TRANSACTIONID"]; // ' Unique transaction ID of the payment.

// Note: If the PaymentAction of the request was Authorization or Order,

// this value is your AuthorizationID for use with the Authorization &

// Capture APIs.

$transactionType = $resArray["TRANSACTIONTYPE"]; //' The type of transaction Possible

// values: l cart l express-checkout

$paymentType = $resArray["PAYMENTTYPE"]; //' Indicates whether the payment is instant

// or delayed. Possible values: none,

// echeck, instant

$orderTime = $resArray["ORDERTIME"]; //' Time/date stamp of payment.

$amt = $resArray["AMT"]; //' The final amount charged, including any shipping and

// taxes from your Merchant Profile.

$currencyCode = $resArray["CURRENCYCODE"]; //' A three-character currency code for

// one of the currencies listed in

// PayPal-Supported Transactional

// Currencies. Default: USD.

$feeAmt = $resArray["FEEAMT"]; //' PayPal fee amount charged for the transaction

$settleAmt = $resArray["SETTLEAMT"]; //' Amount deposited in your PayPal account

// after a currency conversion.

$taxAmt = $resArray["TAXAMT"]; //' Tax charged on the transaction.

$exchangeRate = $resArray["EXCHANGERATE"]; //' Exchange rate if a currency conversion

// occurred. Relevant only if you are

// billing in their non-primary currency.

// If the customer chooses

Return Main Page Previous Page Next Page

®Online Book Reader