Php 简明教程

PHP - Paypal Integration

PayPal 是一个付款处理系统。我们可以使用 PHP 来将 PayPal 与网站集成。

PayPal is a payment processing system. We can integrate PayPal with websites by using with PHP.

PayPal Integration File System

PayPal 集成文件系统包含四个文件,如下所示 -

PayPal integration file system included four files as shown below −

  1. constants.php − This file includes the API user name, password and signature.

  2. CallerService.php − This file includes the PayPal Services, which are used to call PayPal services.

  3. confirmation.php − This file includes a form with minimum fields required to make payment process and it will return payment success or failure.

  4. PayPal_entry.php − This page has used to send the user the data to PayPal. It acts as an adapter between PayPal and user form.

用户需要从这里下载一个 PayPal SDK 文件并具体解压一个 zip 文件。zip 文件包含四个 PHP 文件。我们不需要更改“constants.php”以外的任何文件。

The user has to download a PayPal SDK file from here and exact a zip file. The zip file contains four PHP files. We don’t need to change any file except "constants.php".

constants.php

“constants.php”文件包含以下代码 -

The "constants.php" file contains code as shown below −

<?php
   define('API_USERNAME', 'YOUR USER NAME HERE');
   define('API_PASSWORD', 'YOUR PASSWORD HERE');
   define('API_SIGNATURE', 'YOUR API SIGNATURE HERE');
   define('API_ENDPOINT', 'https://api-3t.paypal.com/nvp');
   define('USE_PROXY',FALSE);
   define('PROXY_HOST', '127.0.0.1');
   define('PROXY_PORT', '808');
   define('PAYPAL_URL', 'https://www.PayPal.com/webscr&cmd=_express-checkout&token=');
   define('VERSION', '53.0');
?>

用户将在上方语法中声明放置在“constants.php”中的用户名、密码和签名。

The user will declare the username, password and signature in the above syntax which are placed in "constants.php".

这是一个实验示例,所以最后金额将被添加到沙盒账户。

This is an experimental example so the last amount will be added to sandbox’s account.