PayPal APIs_ Up and Running_ A Developer's Guide - Michael Balderas [11]
L_SHIPPINGOPTIONNAME n The internal/system name of a shipping option (e.g., Air, Ground, Expedited). This field is required. Parameters must be ordered sequentially starting with 0 (e.g., L_SHIPPINGOPTIONNAME0, L_SHIPPINGOPTIONNAME1 ). Limitation: Up to 50 characters.
L_SHIPPINGOPTIONLABEL n The label for the shipping options displayed to the buyer (e.g., Air: Next Day, Expedited: 3-5 days, Ground: 5-7 days). This field is required. Labels can be localized based on the buyer’s locale. Parameters must be numbered sequentially starting with 0 (e.g., L_SHIPPINGOPTIONLABEL0, L_SHIPPINGOPTIONLABEL1 ). Limitation: Up to 50 characters.
L_SHIPPINGOPTIONAMOUNT n Amount of the shipping option. Parameters must be numbered sequentially starting with 0 (e.g., L_SHIPPINGOPTIONAMOUNT0, L_SHIPPINGOPTIONAMOUNT1 ). Limitations: Must not exceed $10,000 USD in any currency. No currency symbol allowed. The decimal separator must be a period (.), regardless of currency, and the optional thousands separator must be a comma(,). Equivalent to nine characters maximum for USD.
L_SHIPPINGOPTIONISDEFAULT The default option selected for the buyer; this is also reflected in the “default” total (required).
Simple Express Checkout Integration
The simplest Express Checkout integration requires execution of only two PayPal API operations: SetExpressCheckout and DoExpressCheckoutPayment. For example, optionally, you can call GetExpressCheckoutDetails to error check the information provided to SetExpressCheckout against the form values and provide the customer a Confirm Transaction screen before finalizing the payment.
Setting Up the Transaction
To set up an Express Checkout transaction, you must first invoke the SetExpressCheckout API to provide sufficient information to initiate the payment flow and redirect your customer to PayPal if the operation is successful.
When you initiate the Express Checkout transaction, you specify values in the SetExpressCheckout request, and then call the API. The values you specify control the PayPal page flow and options available to your customers.
Let’s look at setting up a simple Express Checkout transaction.
First we need to specify the total dollar amount of the transaction, if known; otherwise, specify the subtotal. Refer to Table 2-3’s PAYMENTREQUEST_n_AMT field description for requirements and restrictions.
AMT=amount
CURRENCYCODE=currencyID
Specify the return URL. This is the page on your site that you want PayPal to redirect the customer to after the customer logs into PayPal and approves the payment. Typically, the customer is redirected to a secure page on your site via SSL (https://).
RETURNURL=return_url
Specify the cancel URL. This is the page on your site you want PayPal to redirect the customer to if the buyer does not approve the payment. Typically, the customer is redirected to a secure page on your site via SSL (https://).
CANCELURL=cancel_url
Specify the payment action. Even though the action is a Sale, it is best to explicitly set the payment action. Refer to Table 2-3’s PAYMENT_n_PAYMENTACTION field description for allowed values.
Execute the SetExpressCheckoutAPI operation and test that the response was successful. To test for success, check to see whether the API returns a TOKEN and other variables.
Tip
You can piggyback parameters between pages on your site in the return URL call as well as the cancel URL call. For example, you can set your return URL to specify additional parameters using something like https://your.domain.ext/returnpage.php?param1=val1¶m2=val2, etc. This allows you to pass parameters from the transaction without making a GetExpressCheckoutDetails API call, or pass custom parameters not provided by the SetExpressCheckout API.
To execute the transaction, you must invoke the DoExpressCheckoutPayment operation. This is accomplished through the following steps:
Specify the TOKEN value returned by PayPal when it redirects the buyer