Security News
PyPI’s New Archival Feature Closes a Major Security Gap
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
v0.1.5
Created at Herd Hound Copyright (c)2011, by Branko Vukelic branko@herdhound.com.
Some rights reserved.
Licensed under MIT license (see LICENSE)
Daimyo (pronounced as dah-e-myoh) is a client library for the Samurai payment gateway from Fee Fighters. By the time 1.0 release is made, Daimyo will support all of Samurai's API, but the current immediate goal is to support the sale transactions and provide robust error reporting facilities.
For now, Daimyo is used in production at Herd Hound. It is still being polished for prime time, but the core functionality should work as documented/expected since v0.0.7. Keep track of changes on Github, and keep an eye on the issue tracker there.
_check
token verification would fail for credit and
void transaction because Samurai does not honor custom data for those
transaction types.success
flag in transaction responses.sandbox
parameter for creating sandbox payment
methods.daimyo.Card
constructor not handling custom data.card.method.custom
which was returned after loading a payment
method, and which always contained unused, empty object.checkamd
makefile target.daimyo.Card
constructor will throw a proper DaimyoError
on errors,
instead of generic Error
object as in previous versions.allowedCurrencies
setting which limits the currencies that can be usedtransaciton.Transaction.process()
will check allowed currencies and block
transactions that use disallowed currency.transaction.Transaction.process()
no longer throws exceptions. All errors
are passed to the callback instead.custom
field.checkamd
make target now generates file with version number.daimyo.Card
and
transaction.Transaction
objects.data
and path
properties on transaction.Transaction
objects
set-once properties similar to configuration locking.daimyo.Card
and
transaction.Transaction
objects. They can store any JSON-serializable
object, and that will be stored in Samurai gateway, and restored later with
methods like card.load()
or when transaction is completed.daimyo.Card.load()
are missing a token, the error will
now not be thrown, but passed to the callback instead, like all other
methods.daimyo
no longer has settings
property. You should use
daimyo.option()
to access options instead.daimyo.configure()
successfully for the first time,
configuration will now be permanently locked until you restart the app.
This is a feature not a bug. It prevents malicious code from tricking your
app into resetting some of the critical Daimyo options.The first release is a public preview release and it's not meant to be production-ready. There are still quite a few things to implement, and error handling is not very robust. Note that API might change as well. For starters, you should not rely on any method that has the @private tag in the inline comments (that do not appear in API documentation, that is), but the public methods may change as well, as well as method signatures.
Although there are unit tests, and Daimyo's development is test-driven, the tests do not currently provide complete coverage, and it is expected that some functionality may break in production. Target for first production-ready Daimyo is v0.1.
Easiest way to install Daimyo is by using npm:
npm install daimyo
That will install the latest release that we have made. Not that releases prior to 0.1 are not considered production-ready. See the Status section of this file to find out more about the current progress.
Since Daimyo is currently still very beta, if you wish to get a newer version with more features (please don't do this in production, though), you can add it as a dependency to your packages.json like this:
dependencies: {
....
,"daimyo": "https://github.com/HerdHound/Daimyo/tarball/master"
....
}
Using the above method, it is also possible to address individual commits. Go to GitHub, switch to a commit you want to depend on, click the download link, and right-click the tarball button, copy URL, and paste it into your dependency list like above.
Finally, you can clone the Daimyo repository using git and install from the cloned repository:
git clone https://github.com/HerdHound/Daimyo.git
cd /your/project/dir
npm install /path/to/daimyo/clone
var daimyo = require('daimyo');
// Configure Daimyo
daimyo.configure({
merchantKey: 'xxxxxxxxxxxxxxxxxxxxxxxx',
processorId: 'xxxxxxxxxxxxxxxxxxxxxxxx',
apiPassword: 'xxxxxxxxxxxxxxxxxxxxxxxx',
currency: 'USD', // default
debug: false, // default, should stay off in production at all costs
enabled: true, // default
sandbox: false // default
});
// Using transparent redirect with Express
app.get('/redirect_target', function(req, res, next) {
var token = req.param('payment_method_token');
var card = daimyo.Card({token: token});
// Create a new transaction
var transactionData = {
amount: 100,
billingReference: 'my billing ref #',
customerReference: "user's customer ref #',
type: 'purchase'
}
// Process the transaction using the card object
transaction.process(card, function(err) {
if (err) {
// Handle error and return error page
res.render('sorry', {});
return;
}
if (!transaction.messages.info ||
transaction.messages.info[0] === 'success') {
// The transaction was not successful
res.render('sorry, {messages: transaction.messages});
return;
}
// Ah, finally! All ur moneys are belong to us!
res.render('kthxbye', {});
// Don't forget to Email receipt!
emailReceipt({
issuer: card.issuer,
cardNo: '****-****-****-' + card.last4,
date: transaction.receipt.createdAt,
amount: transaction.receipt.amount
});
});
});
check
as AMD module in browsersThe `lib/check.js`` module contains generic functions for performing various checks on credit cards. It performs Luhn Mod-10 check to ensure that the card number is valid (although the card itself may not be valid), get the name of the issuer, or make sure that the CSC (also called CVV, CVC, or CCV) has the right number of digits, etc. It is always a good idea to perform this check browser-side to ensure that obviously invalid cards do not make it to the system, or that any typing errors are caught early on.
This module can be used in browsers with minimal modifications. For
convenience, the checkamd
target is provided in the makefile, which builds
an AMD module compatible with loaders like RequireJS.
To build the AMD version of check, simply type:
make checkamd
This will result in creation of a new file called check.js
in the project
directory. The file is not minified. If you want to minify it, you can use
tools such as UglifyJS.
To use it, simply require it from your module as usual:
// mymodule.js
define(['jquery', 'check'], function($, check) {
var cardNumber = $('input[name=card]).val();
var csc = $('input[name=csc]').val();
var isVaild = check.mod10check(cardNumber) ? true : false;
var isValid = isValid && check.cscCheck(cardNumber, csc) ? true : false
var issuer = check.getIssuer(cardNumber);
alert('Your card was issued by ' + issuer);
});
You can find more details on this module in the API documentation.
The dox-generated API documentation can be found at herdhound.github.com/Daimyo/. You can also generate the documentation for offline use using the provided makefile. See Offline documentaiton section for instructions.
You can generate offline documentation for Daimyo using the dox utility from Visionmedia. Install dox by typing:
sudo npm install dox -g
Now you can simpy type make docs
in the project directory. The
documentation will be generated in a newly created docs
directory. To
remove the documentation, just type make clean
.
To run unit tests you need Expresso,
and should.js. You also need to
create a file called test/config.js
, and add your keys there:
exports.merchantKey = 'xxxxxxxxxxxxxxxxxxxxxxxx';
exports.apiPassword = 'xxxxxxxxxxxxxxxxxxxxxxxx';
exports.processorId = 'xxxxxxxxxxxxxxxxxxxxxxxx';
The tests are run simply by simply typing make
in the project directory.
Alternatively, you can type:
expresso /test/*.tests.js
Do not run tests with your live processor. Make sure you are running in a sandbox.
You may use the issue tracker to report Daimyo bugs you find. Alternatively, you may contact the author directly at branko@herdhound.com. Of course, feature requests are also welcome, but currently, the basic functionality is top priority.
FAQs
Samurai payment gateway API client library for Node.js
We found that daimyo demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
Research
Security News
Malicious npm package postcss-optimizer delivers BeaverTail malware, targeting developer systems; similarities to past campaigns suggest a North Korean connection.
Security News
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.