emirazaiez/paypal
Composer 安装命令:
composer require emirazaiez/paypal
包简介
Simple script which use paypal api svn on php
README 文档
README
This php class will simply consume the paypal NVP Api for make a simple payment.
Installation
Add this line into require in your composer.json:
composer require emirazaiez/paypal
then add this line to your php file (Or not if you use a framework)
require 'vendor/autoload.php'
You can get all informations about the paypal API and the paypal Configuration in this page : Paypal Developer
A few examples: (You can also check sample.php)
This is just an exemple, it's better if for each "function" you do a route
Simple make a call request to the API for get a paypal payment URL : (route can be something like : /paypal/checkout)
<?php session_start(); //For use the 'transferData' require 'vendor/autoload.php' use Paypal\CheckoutManager; $paypalConfig = array( 'mode' => 'sandbox', // You can provide 'prod' for use the real paypal service 'user' => '', // You can get it from paypal service 'password' => '', // You can get it from paypal service 'signature' => '', // You can get it from paypal service 'lang' => 'EN' ); $productConfig = array( 'price' => 5, 'currency' => 'USD', 'description' => 'My app subscription for 1 month', //Which will be show on the paypal payment page 'logo' => 'http://creativebits.org/files/500px-Apple_Computer_Logo.svg_.png', //Logo of your company 'returnURL' => 'http://myweb.com/paypal/return', //The return url will be passed to paypal, this url will be call by paypal when the transfere will be done 'cancelURL' => 'http://myweb.com/paypal/cancel', //The return url will be passed to paypal, this url will be call when the user cancel the payment 'transferData' => array('productID' => '1', 'quantity' => '1month') //Those data arn't used by paypal, you can put whatever you want. Those data will be avaible on success of the "return url" called by paypal (You can only use this if you start the session) ); $paypal = new CheckoutManager($paypalConfig['mode'], $paypalConfig['user'], $paypalConfig['password'], $paypalConfig['signature'], $paypalConfig['lang']); $paypal->requestExpressCheckout($productConfig['price'], $productConfig['currency'], $productConfig['description'], $productConfig['logo'], $productConfig['returnURL'], $productConfig['cancelURL']) ->setTransferData($productConfig['transferData']) ->execute( function($paypalCheckoutURL,$success) { //Put your own logic here //You can redirect the user directly to paypal checkout shop : header("Location: " . $paypalCheckoutURL); }, function($errors) { //Put your own logic here });
Simple return of paypal API : (route can be something like : /paypal/return)
<?php $paypal = new CheckoutManager($paypalConfig['mode'], $paypalConfig['user'], $paypalConfig['password'], $paypalConfig['signature'], $paypalConfig['lang']); $paypal->requestExpressCheckoutPayment($_GET['token'], $_GET['PayerID']) ->execute( function($transferedData, $paypalUser, $success) { //Put your own logic here (Will be some db call for save everything) }, function($errors) { //Put your own logic here });
Cancel payment : (route can be something like : /paypal/cancel)
<?php $paypal = new CheckoutManager($paypalConfig['mode'], $paypalConfig['user'], $paypalConfig['password'], $paypalConfig['signature'], $paypalConfig['lang']); $paypal->requestExpressCheckoutDetails($_GET['token']) ->execute( function($transferedData, $paypalUser) { //Put your own logic here }, function($errors) { //Put your own logic here });
Authors
emirazaiez/paypal 适用场景与选型建议
emirazaiez/paypal 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 11 次下载、GitHub Stars 达 3, 最近一次更新时间为 2015 年 11 月 02 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 emirazaiez/paypal 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 emirazaiez/paypal 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 11
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 12
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2015-11-02