承接 pagomio/pagomio-sdk-php 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

pagomio/pagomio-sdk-php

最新稳定版本:1.1

Composer 安装命令:

composer require pagomio/pagomio-sdk-php

包简介

Pagomio SDK for PHP

README 文档

README

Installation

Install with Composer

If you're using Composer, add this to your composer.json require:

{
  "require" : {
    "pagomio/pagomio-sdk-php" : "dev-master"
  }
}

And load it using Composer's autoloader

require 'vendor/autoload.php';

Install from GitHub

To install the source code:

$ git clone git@github.com:Pagomio/pagomio-sdk-php.git
$ git clone git@github.com:rmccue/Requests.git

Include pagomio-sdk-php in your code and autoload requests:

require_once '/path/to/pagomio-sdk-php/pagomio.php';
require_once '/path/to/Requests/library/Requests.php';
Requests::register_autoloader();

Usage

Set your client_id, secret_id and true if is sandbox:

$pagomio = new Pagomio\Pagomio('client_id','secret_id',true);

Generate Token

You must generate a token with all your payment information.

//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);
}

Response

After the payment Pagomio.com redirected to the page that you reported in the previous step.

// 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;
}

License

Licensed under the MIT license.

Copyright (r) 2015 Pagomío.

统计信息

  • 总下载量: 1.83k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 5
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-04-24