PayPal is the most commonly used payment processor across the world; one of the key contributors to PayPal's success is its easy-to-use API and exhaustive documentation that supports this payment gateway. For any new merchant,PayPal offers a wide range of options for setting up their payment processor, the most important being the types of integrations that are offered. PayPal offers various products under Payment Processing; some of them include:
◆ Express Checkout
◆ PayPal Payments Standards (Website Payments Standards)
◆ PayPal Payments Pro (Website Payments Pro)
We will be working with Express Checkout in this chapter, since it is the most basic implementation method of PayPal.
PayPal and Zend Framework 2.0
At the time of writing this book, there were no native packages that were offered by Zend Framework which supported PayPal integration. There are always third-party options that support this integration. In this example, we have made use of one such third party package called SpeckPaypal.
Perform the following steps for setting up PayPal:
1. Open https://packagist.org/, search for speckpaypal.
2. Get the repository details.
3. Modify the application's Composer configuration file to include the speckpaypal
repository:
"require": {
"php": ">=5.3.3", "zendframework/zendframework": "2.0.*", "webino/webino-image-thumb": "1.0.0", "zendframework/zendgdata": "2.*","speckcommerce/speck-paypal": "dev-master"
}
4. Update the project dependencies using the Composer update:
.
Loading composer repositories with package information Updating dependencies
- Removing zendframework/zendframework (2.0.7)
- Installing zendframework/zendframework (2.0.8) Downloading: 100%
- Installing speckcommerce/speck-paypal (dev-master d951518) Cloning d951518fd2c98148da5609e23a41697e6cfca06e
Writing lock file Generating autoload files
5. Now we will need API credentials for accessing PayPal Express Checkout.
This can be accessed by logging into https://developer.paypal.com
with your PayPal credentials.
6. Open Sandbox Accounts from Applications.
8. Make a note of the API credentials.
9. Now create a new configuration in the config file (CommunicationApp/module/ Users/config/module.config.php) in the module's configuration file and name the array index speck-paypal-api:
'speck-paypal-api' => array( 'username' => '', 'password' => '', 'signature' => '',
'endpoint' => 'https://api-3t.sandbox.paypal.com/nvp'
)
10. Different PayPal services have different end points. For Express Checkout in Sandbox this is https://api-3t.sandbox.paypal.com/nvp; if you are switching live/ production environment, this needs to be changedto https://api-3t.paypal. com/nvp.
What just happened?
Now we have configured PayPal and SpeckPaypal in our application, our next step is to test receiving payments using PayPal Express Checkout.
Không có nhận xét nào:
Đăng nhận xét