pagomio / pagomio-sdk-php
PHP版的Pagomio SDK
1.1
2017-05-23 21:30 UTC
Requires
- php: >=5.3.0
- rmccue/requests: >=1.0
This package is not auto-updated.
Last update: 2024-09-28 16:31:11 UTC
README
安装
使用Composer安装
如果你正在使用 Composer,将以下内容添加到你的 composer.json 的 require
{ "require" : { "pagomio/pagomio-sdk-php" : "dev-master" } }
并使用Composer的自动加载器加载它
require 'vendor/autoload.php';
从GitHub安装
要安装源代码
$ git clone git@github.com:Pagomio/pagomio-sdk-php.git $ git clone git@github.com:rmccue/Requests.git
在你的代码中包含 pagomio-sdk-php
并自动加载 requests
require_once '/path/to/pagomio-sdk-php/pagomio.php'; require_once '/path/to/Requests/library/Requests.php'; Requests::register_autoloader();
使用方法
设置你的client_id,secret_id以及如果是在沙盒模式下设置为 true
$pagomio = new Pagomio\Pagomio('client_id','secret_id',true);
生成令牌
你必须使用所有的支付信息生成一个令牌。
//Customer information - Not required $userData = new Pagomio\UserData(); $userData->names = 'Name User'; $userData->lastNames = 'Last name User'; $userData->identificationType = 'CC'; # Allow: CC, TI, PT, NIT $userData->identification = '123456789'; $userData->email = 'email@domain.com'; $userData->phone = '1234567'; // Payment information - Is required $paymentData = new Pagomio\PaymentData(); $paymentData->currency = 'COP'; $paymentData->reference = '1234'; $paymentData->totalAmount = '1160'; $paymentData->taxAmount = '160'; $paymentData->devolutionBaseAmount = '1000'; $paymentData->description = 'Description of your product'; // Url return to after payment - Is required $enterpriseData = new Pagomio\EnterpriseData(); $enterpriseData->url_redirect = 'http://www.foo.com/response.php'; $enterpriseData->url_notify = 'http://www.foo.com/notify.php'; // Create the object $aut = new Pagomio\AuthorizePayment(); $aut->enterpriseData = $enterpriseData; $aut->paymentData = $paymentData; $aut->userData = $userData; // Generate the token $response = $pagomio->getToken($aut); // Redirect to Pagomio.com if($response->success) { header("Location: " . $response->url); }
响应
支付后,Pagomio.com
会重定向到你之前步骤中报告的页面。
// response.php $pagomio = new Pagomio\Pagomio('client_id','secret_id',true); $request = $pagomio->getRequestPayment(); switch ($request->status) { case Pagomio\Pagomio::TRANSACTION_SUCCESS: // ... break; case Pagomio\Pagomio::TRANSACTION_ERROR: // ... break; case Pagomio\Pagomio::TRANSACTION_PENDING: // ... break; }
许可
MIT许可证下许可。
版权(c)2015 Pagomío。