ritproduction/nelnet
最新稳定版本:1.1.4
Composer 安装命令:
composer require ritproduction/nelnet
包简介
A user-friendly interface for the Nelnet System.
README 文档
README
Note: Any of the "Nelnet Statuses" that come back above 50 are not actually coming from NELNET.
Installing
The easiest way to install this library is via composer, however it requires that you have git set up to use SSH keys.
Add the following to your composer.json file inside your project:
"require": {
"ritproduction/nelnet": "dev-master"
},
"repositories": [
{
"type": "vcs",
"url": "git@bitbucket.org:ritproduction/nelnet-library.git"
}
]
and the composer auto-loader will take care of the rest.
If you don't already use composer (which you should) you'll just want to clone the repository into your desired folder, and then
require_once('path/to/nelnet/src/autoload.php');
Usage
The following code is all you need to get started:
<?php
use RIT\Prod\Nelnet as Nelnet;
require_once("path/to/Nelnet/autoload.php");
$nelnet = new Nelnet\Nelnet();
$nelnet->orderType = "[Your Order Type]";
$nelnet->sharedSecret = "[Your Shared Secret]";
$nelnet->redirectUrl = "[Your Confirmation Page]";
$nelnet->setNelnetEnvironment("[Staging | Production]");
$params = array(
"id" => [This instance's ID],
"amount" => (XXX * 100), // dollars (X) times 100 to convert to pennies
);
$request = $nelnet->buildRequest();
$request->send($params);
and for your confirmation page:
<?php
use RIT\Prod\Nelnet as Nelnet;
require_once("path/to/Nelnet/autoload.php");
$nelnet = new Nelnet\Nelnet();
$nelnet->sharedSecret = "[Your Shared Secret]";
$response = $nelnet->buildResponse($_GET);
You could even split up the Autoload and Nelnet initialization into a common, shared file and configure it there and then all you need to do is build the request and response on the appropriate pages:
header.php
<?php
use RIT\Prod\Nelnet as Nelnet;
require_once("path/to/Nelnet/autoload.php");
$nelnet = new Nelnet\Nelnet();
$nelnet->orderType = "[Your Order Type]";
$nelnet->sharedSecret = "[Your Shared Secret]";
$nelnet->redirectUrl = "[Your Confirmation Page]";
$nelnet->setNelnetEnvironment("[Staging | Production]");
form-handler.php
<?php
include ('/path/to/header.php');
$params = array(
"id" => [This instance's ID],
"amount" => (XXX * 100),
"email" => [User's email],
);
$request = $nelnet->buildRequest();
$request->send($params);
confirmation.php
<?php
include('path/to/header.php');
...
$response = $nelnet->buildResponse($_GET);
...
//print human readble status
$statuses = $response->config->statuses;
$current_status = $statuses[$response->transactionStatus];
print $current_status->getDetails();
Custom User Choices
(userChoice1, userChoice2, userChoice3, userChoice4, userChoice5)
These are built into Nelnet and can be used to pass extra info to Nelnet and have it sent back through the URL after payment. One of the main reasons to use this is to send the webform's node ID so you can use a single confirmation page.
form-handler.php
<?php
$params = array(
'id' => $submission_id,
'amount' => $amount,
'email' => $email,
'extras' => [$webform_node_id, $etc]
);
$request = $nelnet->buildRequest();
$request->send($params);
confirmation.php
<?php
$response = $nelnet->buildResponse($_GET);
$userChoices = $response->extras;
$userChoice1 = $userChoices[0];
$userChoice2 = $userChoices[1];
// etc, be sure to check isset
统计信息
- 总下载量: 12
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2015-04-09