NVP API Web Samples Using PHP
This document describes web samples that use PHP to send Name-Value Pair (NVP) API requests to a PayPal server.
This document contains the following sections:
- Required Software
- Installing the Samples
- Running the Samples
- Enabling the Proxy for Samples
- Descriptions of Samples
- API Documentation
The following software is required:
|PHP with CURL extension enabled||4.4.2 or greater||http://www.php.net/downloads.php|
|Apache HTTP Server||1.3.17 or greater||http://httpd.apache.org/|
You must install and configure PHP with the Apache HTTP Server.
Copy the sample folder,
php_nvp_samples, to the docroot of the Apache HTTP Server. By default docroot is in datadir
You can run the samples by entering the following address in a web browser:
constants.php is the configuration file for Proxy setup.
Update the following variables in constants.php for Proxy configuration.
- USE_PROXY - Set this variable to TRUE to route all the API requests through Proxy(by default it is FALSE).
- PROXY_HOST - Set this variable to Proxy Server name or IP address
- PROXY_PORT - Set this variable to Proxy Server port
The web samples consist of the following:
- Charging a Credit Card Using Direct Payment
- Accepting PayPal in Express Checkout
- Capturing the amount of the authorization
- Void the authorization
- Reauthorizing for a different amount
- Getting Transaction Details
- Searching for a Transaction
- Refunding the amount
- Mass Payment
- Common Files
The main page of the samples, index.html, contains links to each sample.
This sample shows how to use Direct Payment to charge a credit card. Access this sample from the following choices displayed on index.html:
|DoDirectPayment - Sale||
Charge a credit card.
|DoDirectPayment - Authorization||
Authorize a credit card for later sale.
The primary files for this sample are:
This is the main web page for the DoDirectPayment sample. This page allows the user to enter name, address, amount, and credit card information. It also accept input variable
When the user clicks the Submit button, DoDirectPaymentReceipt.php is called.
Called by index.html.
Submits a credit card transaction to PayPal using a
The code collects transaction parameters from the form displayed by DoDirectPayment.php then constructs and sends the
After the PayPal server returns the response, the code displays the API request and response in the browser. If the response from PayPal was a success, it displays the response parameters. If the response was an error, it displays the errors in APIError.php.
Called by DoDirectPayment.php.
This sample shows how to use Express Checkout to accept payments using PayPal. Access this sample from the following choices displayed on index.html:
|ExpressCheckout - Sale||
Do basic checkout with PayPal.
|ExpressCheckout - Authorization||
Authorize for a single capture.
|ExpressCheckout - Order||
Authorize for multiple captures.
More at : http://www.artadviser.com/php_nvp_samples/README.html#MassPayReceipt