Online Book Reader

Home Category

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

By Root 150 0
.= "&receiverList.receiver(" . $key . ").amount=" . urlencode($value);

}

}

}

}

elseif ("" != $trackingId)

{

$nvpstr = "trackingId=" . urlencode($trackingId);

if (0 != count($receiverEmailArray))

{

reset($receiverEmailArray);

while (list($key, $value) = each($receiverEmailArray))

{

if ("" != $value)

{

$nvpstr .= "&receiverList.receiver(" . $key . ").email=" . urlencode($value);

}

}

}

if (0 != count($receiverAmountArray))

{

reset($receiverAmountArray);

while (list($key, $value) = each($receiverAmountArray))

{

if ("" != $value)

{

$nvpstr .= "&receiverList.receiver(" . $key . ").amount=" . urlencode($value);

}

}

}

}

elseif ("" != $transactionId)

{

$nvpstr = "transactionId=" . urlencode($transactionId);

// the caller should only have 1 entry in the email and amount arrays

if (0 != count($receiverEmailArray))

{

reset($receiverEmailArray);

while (list($key, $value) = each($receiverEmailArray))

{

if ("" != $value)

{

$nvpstr .= "&receiverList.receiver(" . $key . ").email=" . urlencode($value);

}

}

}

if (0 != count($receiverAmountArray))

{

reset($receiverAmountArray);

while (list($key, $value) = each($receiverAmountArray))

{

if ("" != $value)

{

$nvpstr .= "&receiverList.receiver(" . $key . ").amount=" . urlencode($value);

}

}

}

}

/* Make the Refund call to PayPal */

$resArray = hash_call("Refund", $nvpstr);

/* Return the response array */

return $resArray;

}

/*

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

' Purpose: Prepares the parameters for the PaymentDetails API Call.

' The PaymentDetails call can be made with either

' a payKey, a trackingId, or a transactionId of a previously successful Pay call.

' Inputs:

'

' Conditionally Required:

' One of the following: payKey or transactionId or trackingId

' Returns:

' The NVP Collection object of the PaymentDetails call response.

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

*/

function CallPaymentDetails( $payKey, $transactionId, $trackingId )

{

/* Gather the information to make the PaymentDetails call.

The variable nvpstr holds the name-value pairs.

*/

$nvpstr = "";

// conditionally required fields

if ("" != $payKey)

{

$nvpstr = "payKey=" . urlencode($payKey);

}

elseif ("" != $transactionId)

{

$nvpstr = "transactionId=" . urlencode($transactionId);

}

elseif ("" != $trackingId)

{

$nvpstr = "trackingId=" . urlencode($trackingId);

}

/* Make the PaymentDetails call to PayPal */

$resArray = hash_call("PaymentDetails", $nvpstr);

/* Return the response array */

return $resArray;

}

/*

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

' Purpose: Prepares the parameters for the Pay API Call.

' Inputs:

'

' Required:

'

' Optional:

'

' Returns:

' The NVP Collection object of the Pay call response.

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

*/

function CallPay( $actionType, $cancelUrl, $returnUrl, $currencyCode,

$receiverEmailArray, $receiverAmountArray, $receiverPrimaryArray,

$receiverInvoiceIdArray, $feesPayer, $ipnNotificationUrl, $memo,

$pin, $preapprovalKey, $reverseAllParallelPaymentsOnError,

$senderEmail, $trackingId )

{

/* Gather the information to make the Pay call.

The variable nvpstr holds the name-value pairs.

*/

// required fields

$nvpstr = "actionType=" . urlencode($actionType) . "¤cyCode=";

$nvpstr .= urlencode($currencyCode) . "&returnUrl=";

$nvpstr .= urlencode($returnUrl) . "&cancelUrl=" . urlencode($cancelUrl);

if (0 != count($receiverAmountArray))

{

reset($receiverAmountArray);

while (list($key, $value) = each($receiverAmountArray))

{

if ("" != $value)

{

$nvpstr .= "&receiverList.receiver(" . $key . ").amount=" . urlencode($value);

}

}

}

if (0 != count($receiverEmailArray))

{

reset($receiverEmailArray);

while (list($key, $value) = each($receiverEmailArray))

{

if ("" != $value)

{

$nvpstr .= "&receiverList.receiver(" . $key . ").email=" . urlencode($value);

Return Main Page Previous Page Next Page

®Online Book Reader