定制 emirazaiez/paypal 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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

Emir Azaiez

emirazaiez/paypal 适用场景与选型建议

emirazaiez/paypal 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 11 次下载、GitHub Stars 达 3, 最近一次更新时间为 2015 年 11 月 02 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 emirazaiez/paypal 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 emirazaiez/paypal 我们能提供哪些服务?
定制开发 / 二次开发

基于 emirazaiez/paypal 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 11
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 12
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2015-11-02