Online Book Reader

Home Category

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

By Root 139 0

//position of value

$valuepos = strpos($nvpstr,'&') ? strpos($nvpstr,'&'): strlen($nvpstr);

/*getting the Key and Value values and storing in a Associative Array*/

$keyval=substr($nvpstr,$intial,$keypos);

$valval=substr($nvpstr,$keypos+1,$valuepos-$keypos-1);

//decoding the respose

$nvpArray[urldecode($keyval)] =urldecode( $valval);

$nvpstr=substr($nvpstr,$valuepos+1,strlen($nvpstr));

}

return $nvpArray;

}

?>

Example 4-2. preapprovalflow.php

//-------------------------------------------------

// When you integrate this code,

// look for TODO as an indication

// that you may need to provide a value or take

// action before executing this code.

//-------------------------------------------------

require_once ("paypalplatform.php");

// ==================================

// PayPal Platform Preapproval Module

// ==================================

// Request specific required fields

$cancelUrl = "http://wwww.yoursite.com/PreapprovalCancelHandler.xxx";

// TODO - The landing page on your site where the customer

// is sent when they cancel the Preapproval action on PayPal

$returnUrl = "http://wwww.yoursite.com/PreapprovalReturnHandler.xxx";

// TODO - The landing page on your site where the customer

// returns to after the Preapproval is agreed to on PayPal

$currencyCode = "USD";

$startingDate = "2009-06-17T13:00:00"; // TODO - The datetime when this

// preapproval agreement starts,

// cannot be in the past

$endingDate = "2009-09-17T13:00:00"; // TODO - The datetime when this

// preapproval agreement ends

$maxTotalAmountOfAllPayments = "2000"; // TODO - The maximum total amount

// of all payments, cannot exceed

// $2,000 USD or the equivalent

// in other currencies

// Request specific optional fields

// Provide a value for each field that you want to include in the request;

// if left as an empty string, the field will not be passed in the request.

$senderEmail = ""; // TODO - The PayPal account email address of the sender

$maxNumberOfPayments = ""; // TODO - The maximum number of payments for

// this preapproval

$paymentPeriod = ""; // TODO - If this preapproval is for periodic payments,

// this defines the payment period as one of the following:

// NO_PERIOD_SPECIFIED

// DAILY - each day

// WEEKLY - each week

// BIWEEKLY - every other week

// SEMIMONTHLY - twice a month

// MONTHLY - each month

// ANNUALLY - each year

$dateOfMonth = ""; // TODO - The day of the month on which a monthly payment is

// to be made, number between 1 and 31

$dayOfWeek = ""; // TODO - The day of the week that a weekly payment is to be

// made, see DayOfWeek in the WSDL for valid enumerations

$maxAmountPerPayment = ""; // TODO - The maximum amount per payment, it

//cannot exceed the value in maxTotalAmountOfAllPayments

$maxNumberOfPaymentsPerPeriod = ""; // TODO - The maximum number of all

// payments per period

$pinType = ""; // TODO - Whether or not a personal identification number (PIN)

// is required each time a Payment is made via the Pay API call

// NOT_REQUIRED - a PIN is not required (default)

// REQUIRED - a PIN is required; the sender must specify a PIN

// when setting up the preapproval on PayPal, and the PIN must

// be in the request of each subsequent Pay API call corresponding

// to this preapproval

// A PIN is typically required if a Pay call against the preapproval

// can be made for a purchase or payment in which the sender takes an

// explicit action to send the money.

//-------------------------------------------------

// Make the Preapproval API call

//

// The CallPreapproval function is defined in the paypalplatform.php file,

// which is included at the top of this file.

//-------------------------------------------------

$resArray = CallPreapproval ($returnURL, $cancelURL, $currencyCode, $startingDate,

$endingDate, $maxTotalAmountOfAllPayments, $senderEmail,

$maxNumberOfPayments, $paymentPeriod, $dateOfMonth, $dayOfWeek,

$maxAmountPerPayment, $maxNumberOfPaymentsPerPeriod, $pinType

);

$ack = strtoupper($resArray["responseEnvelope.ack"]);

Return Main Page Previous Page Next Page

®Online Book Reader