Giter Site home page Giter Site logo

nodejs-sdk's Introduction

wepay logo

Official WePay NodeJS SDK wepay.

// load in your modules
var wepay = require('wepay').WEPAY;       // if wepay.js is installed globally/locally
// var wepay = require('./wepay').WEPAY;  // if wepay.js is in the same directory as your script

// local variables
var wepay_settings = {
	'client_id'     : '127580',
	'client_secret' : '6180c3de46',
	'access_token'  : 'a9ff4ce866893119097e0c29ee1f7886b3891e76b4599ab589c232b4f2f6ddcd', // used for oAuth2
	// 'api_version': 'API_VERSION'
}

var wp = new wepay(wepay_settings);
wp.use_staging(); // use staging environment (payments are not charged)
wp.call('/checkout/create',
	{
		'account_id': 1723052,
		'amount': 50,
        'currency': 'USD',
		'short_description': 'Selling 42 Pens',
		'type': 'goods'
	},
	function(response) {
		console.log('%s', response);
	}
);

Installation

Local installation:

$ npm install wepay

Global installation:

$ npm install -g wepay

Note:

When installing with global settings, you'll need to set your NODE_PATH environment variable.

Install dependencies:

$ npm install

Endpoints

You can specify in the SDK which endpoint (stage or prod) you wish to use. See, endpoints.

To use staging endpoint:

wp.use_staging();

To use production endpoint:

wp.use_production();

Risk Headers

You can supply WePay with risk-related information on every API call by passing the WePay-Risk-Token and Client-IP values to the call function:

wp.call('/checkout/create',
	{
		'account_id': 1723052,
		'amount': 50,
        'currency': 'USD',
		'short_description': 'Selling 42 Pens',
		'type': 'goods'
	},
	function(response) {
		console.log('%s', response);
	},
	'123e4567-e89b-12d3-a456-426655440000',
	'100.166.99.123'
);

Detailed information regarding the Risk Headers can be found at the WePay API Documentation.

Node version supported

This SDK is compatible with Node version up to 10.0.0. Please contact API Support if you have any problem.

More Information

License

(The MIT License)

Copyright (c) 2009-2012 TJ Holowaychuk <[email protected]>

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.

nodejs-sdk's People

Contributors

aroundthesea avatar camerona93 avatar kromped avatar lucasstinchcombe avatar mattuuh7 avatar naissa12 avatar sharonlingqiongtan avatar thef1rstpancake avatar vasusen avatar wepayer avatar y2chaits avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nodejs-sdk's Issues

Cannot find node module.

Not sure what's up, but I keep running into this running server.js:

Error: Cannot find module 'wepay'

Any ideas?

WEPAY constructor options not used

The options passed to the WEPAY constructor are not used anywhere (eg, client_id, & client_secret). They should be automatically merged with the parameters that are sent in the request.

Error 503 first byte timeout

I am getting this error when i call to /checkout/create method .

?xml version="1.0" encoding="utf-8"?>

<title>503 first byte timeout</title>

Error 503 first byte timeout

first byte timeout

Guru Mediation:

Details: cache-lax1431-LAX 1469176127 1060265685


Varnish cache server

Valid email addresses marked as invalid (false positive)

Hi,

Not sure if this is the right repo, but my wife encountered an issue with Freshbooks (who uses wepay for their invoice transactions), where a valid email address was used, but wepay returned with an invalid_request ("Invalid parameter 'email' expected a valid email addresss", which also has a typo sss btw).

This seems to be cause by email addresses that use an & or - (didn't have the time to narrow it down more).
Example: foo.bar+hi&[email protected] is a perfectly valid email address, but wepay seems to trip over it.

Email address formats like these are used fairly frequently in the Canadian Government, so this seems to be an issue that's worth investigating and fixing ;)

You can move it to the proper repo if this isn't the one (couldn't really find the "main" repo for Wepay which, I assume, is private).

CORS errrors when calling API

Hello.
I am using this npm module in meteor project, and this is my code implementation.

// local variables
var wepay_settings = {
'client_id' : 'XXXXXXX',
'client_secret' : 'XXXXXXX',
'access_token' : 'XXXXXXXXX', // used for oAuth2
// 'api_version': 'API_VERSION'
}

    var wp = new wepay.WEPAY(wepay_settings);
    wp.use_staging(); // use staging environment (payments are not charged)
    wp.call('/checkout/create',
        {
            'account_id': XXXX,
            'amount': 5,
            'currency': 'USD',
            'short_description': 'Test: Selling 42 Pens',
            'type': 'goods'
        },
        function(response) {
            console.log('%s', response);
        }
    );

I have got below errors when calling this API

I am pulling my hairs for few days to solve this problem, but I couldn't find any solution yet.
Is there the problem of this package module.
Please help me with this issue. Thank you so mcuh.

/checkout/create response is incomplete

Do to the checkout/call being async
console.log("%s",response) prints:
{"checkout_id":1142912238,"account_id":1484170267,"type":"service","short_description":"Test Checkout","currency":"USD","amount":50,"state":"new","soft_descriptor":"WPY*David Small Stage","auto_capture":true,"create_time":1468179813,"delivery_type":"subscription","gross":0,"reference_id":null,"callback_uri":null,"long_description":null,"fee":{"app_fee":0,"processing_fee":0,"fee_payer":"payer"},"chargeback":{"amount_charged_back":0,"dispute_uri":null},"refund":{"amount_refunded":0,"refund_reason":null},"hosted_checkout":{"checkout_uri":"https://stage.wepay.com/api/checkout/1142912238/e5e2b1aa","redirect_uri":null,"shipping_fee":0,"require_shipp

You can see at the end, "require_shipp" is cut off and the rest is missing.

Use Promises

Update API to use promises instead of callbacks.

Accent in value of one of the values of payer_rbits fails the payment

When you do wepay.call('/checkout/create', {......., payer_rbits:rbits] where rbits is an array with one object being an address rbit, if the address's city includes an accent, it fails.

Sample rbit:

              receive_time: credit_card.created_at.getTime(),
              source: 'user',
              type: 'address',
              properties: {
                address: {
                  address1: credit_card.address.street,
                  city: credit_card.address.city,
                  region: credit_card.address.province,
                  postal_code: credit_card.address.postal_code,
                  country: credit_card.address.country
                }
              }

In our case, city was Montréal, failing the call. Making the same call with Montreal was accepted.

Stacktrace:

Error: Input could not be parsed
at ....
at IncomingMessage.<anonymous> (/app/node_modules/wepay/lib/wepay.js:84:25)

I have not tested if this issue where you include an accented character in any other places fails the call but I would assume it might.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.