NVP API Web Samples Using PHP
VERSION 5.1
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
Required Software
The following software is required:
Software | Version | Download Location |
---|---|---|
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.
Installing the Samples
Copy the sample folder, php_nvp_samples
, to the docroot of the Apache HTTP Server. By default docroot is in datadir/htdocs
.
Running the Samples
First, make sure that you have installed the required software and the samples.
You can run the samples by entering the following address in a web browser:
http://name_of_Apache_HTTP_Server:port/php_nvp_samples/index.html
Enabling the Proxy for Samples
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
Descriptions of Samples
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.
Charging a Credit Card Using Direct Payment
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.
In the |
DoDirectPayment - Authorization |
Authorize a credit card for later sale.
In the |
The primary files for this sample are:
File | Description |
---|---|
DoDirectPayment.php<a id="DoDirectPayment" name="DoDirectPayment"></a> |
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 paymentType which becomes the value of the PAYMENTACTION parameter.
When the user clicks the Submit button, DoDirectPaymentReceipt.php is called. Called by index.html. Calls DoDirectPaymentReceipt.php. |
DoDirectPaymentReceipt.php<a id="DoDirectPaymentReceipt" name="DoDirectPaymentReceipt"></a> |
Submits a credit card transaction to PayPal using a DoDirectPayment request.
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. Calls CallerService.php and APIError.php. |
Accepting PayPal in Express Checkout
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.
In the |
ExpressCheckout - Authorization |
Authorize for a single capture.
In the |
ExpressCheckout - Order |
Authorize for multiple captures.
In the |
More at : http://www.artadviser.com/php_nvp_samples/README.html#MassPayReceipt