2co 中文文档教程

发布于 11年前 浏览 32 项目主页 更新于 3年前

构建状态

2CO

2CO 是将提供 nodejs 的模块 2checkout API 适配器 支付网关。

Installation

安装是使用节点包管理器 (npm) 完成的。 如果您的系统上没有安装 npm,您可以从 npmjs.org 下载它。 安装 2co:

$ npm install -g 2co

Usage overview

Example

list_products 调用用于检索帐户中所有产品的列表。

var checkout = require('2co');

/* Filter list results on vendor product ID. Optional. */
var product = {
     vendor_product_id:'your product id'
};

checkout.setAuth('USERNAME','PASSWORD');
/* list_products method */
checkout.exec('list_products',product);

checkout.on('data',function(data){
   console.log(data);
});

checkout.on('error',function(error){
   console.log(error);
});

Instant Notification System

for Express:

var checkout = require('2co'),
express = require('express'),
app = express(),
host = 'localhost',
port = 3000;

// for express < 4 uncomment
// app.use(app.router);  

checkout
     .notificationRoute('/notifications') // default route '/payments/2co/notifications'
     .fetchNotification(function(data,res){
            res.send(data);
     })
     .notificationHelper(app);

app.listen(port,host);

Handling Approved URL

for Express:

/* Callbacks if an order is immediately approved */
checkout
      .scriptRoute('/2co/:pid?')  // default route '/payments/2co/callback/:pid?'
      .scriptCallback(function(pid,data,res){
             res.send(data);
      })
      .scriptHelper(app);

In the Wild

以下项目使用2co。

如果您在项目、应用程序或模块中使用 2co,请进入下面的列表 通过联系或提交对 README 进行更改的拉取请求。

Startups & Apps

Recommend extensions

Author

阿列克谢·戈尔德耶夫 (aleksej@gordejev.lv)。 开发由 Etvnet 赞助。

License

(麻省理工学院许可证)

版权所有 (c) 2012 Aleksej Gordejev aleksej@gordejev.lv

特此免费授予任何获得许可的人 此软件和相关文档文件的副本( “软件”),不受限制地处理软件,包括 但不限于使用、复制、修改、合并、发布、 分发、再许可和/或出售软件的副本,以及 允许向其提供软件的人这样做,但须遵守 下列条件:

上述版权声明和本许可声明应 包含在软件的所有副本或重要部分中。

本软件按“原样”提供,不提供任何形式的保证, 明示或暗示的,包括但不限于 适销性、特定用途的适用性和非侵权性。 在任何情况下,作者或版权持有人均不对任何 索赔、损害赔偿或其他责任,无论是在合同行为中, 侵权行为或其他由以下原因引起、由其引起或与之相关的行为 软件或软件的使用或其他交易。

Resources

比特得利徽章

build status

2CO

2CO is the module that will provide nodejs adapters for 2checkout API payment gateway.

Installation

Installation is done using the Node Package Manager (npm). If you don't have npm installed on your system you can download it from npmjs.org. To install 2co:

$ npm install -g 2co

Usage overview

Example

The list_products call is used to retrieve list of all products in account.

var checkout = require('2co');

/* Filter list results on vendor product ID. Optional. */
var product = {
     vendor_product_id:'your product id'
};

checkout.setAuth('USERNAME','PASSWORD');
/* list_products method */
checkout.exec('list_products',product);

checkout.on('data',function(data){
   console.log(data);
});

checkout.on('error',function(error){
   console.log(error);
});

Instant Notification System

for Express:

var checkout = require('2co'),
express = require('express'),
app = express(),
host = 'localhost',
port = 3000;

// for express < 4 uncomment
// app.use(app.router);  

checkout
     .notificationRoute('/notifications') // default route '/payments/2co/notifications'
     .fetchNotification(function(data,res){
            res.send(data);
     })
     .notificationHelper(app);

app.listen(port,host);

Handling Approved URL

for Express:

/* Callbacks if an order is immediately approved */
checkout
      .scriptRoute('/2co/:pid?')  // default route '/payments/2co/callback/:pid?'
      .scriptCallback(function(pid,data,res){
             res.send(data);
      })
      .scriptHelper(app);

In the Wild

The following projects use 2co.

If you are using 2co in a project, app, or module, get on the list below by getting in touch or submitting a pull request with changes to the README.

Startups & Apps

Recommend extensions

Author

Aleksej Gordejev (aleksej@gordejev.lv). Development was sponsored by Etvnet.

License

(The MIT License)

Copyright (c) 2012 Aleksej Gordejev aleksej@gordejev.lv

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Resources

Bitdeli Badge

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文