Skip to content

Commit

Permalink
Schemas are now merged in deeped, so currency is now set automaticall…
Browse files Browse the repository at this point in the history
…y. json-schema added to package.json. Version bumped
  • Loading branch information
Malte Legenhausen committed Mar 1, 2012
1 parent 4d34d3e commit bbab55f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -39,7 +39,7 @@ Create your first order request:

```
var order = ogone.createOrderRequest({
orderid: '123,
orderid: '123',
amount: 1.50, // Amount is automatically multiplied by 100
brand: 'VISA',
ed: '09/12',
Expand Down
11 changes: 6 additions & 5 deletions lib/ogone.js
Expand Up @@ -32,19 +32,19 @@ function Ogone(mode, defaults) {

Ogone.prototype.createOrderRequest = function(json, algorithm, key) {
json = json || {};
Object.merge(json, this.defaults);
Object.merge(json, this.defaults, true);
return new OrderRequest(this.mode, json, algorithm, key);
};

Ogone.prototype.createMaintenanceOrder = function(json) {
json = json || {};
Object.merge(json, this.defaults);
Object.merge(json, this.defaults, true);
return new MaintenanceRequest(this.mode, json);
};

Ogone.prototype.createQueryRequest = function(json) {
json = json || {};
Object.merge(json, this.defaults);
Object.merge(json, this.defaults, true);
return new QueryRequest(this.mode, json);
};

Expand All @@ -65,7 +65,7 @@ function Request(url, json, schema) {
required: true
}
}
});
}, true);
var result = JSONSchema.validate(json, schema);
if (!result.valid) throw new Error(result.errors);
this.query = Object.clone(json) || {};
Expand Down Expand Up @@ -143,7 +143,8 @@ function OrderRequest(mode, json, algorithm, key) {
},
currency: {
type: 'string',
'default': 'EUR'
'default': 'EUR',
required: true
},
brand: {
type: 'string',
Expand Down
5 changes: 3 additions & 2 deletions package.json
Expand Up @@ -2,7 +2,7 @@
"author": "Malte Legenhausen <mlegenhausen@gmail.com>",
"name": "ogone-directlink",
"description": "Thin wrapper around the directlink http api of the ogone payment service",
"version": "1.0.0",
"version": "1.0.1",
"repository": {
"type": "git",
"url": "git://github.com/mlegenhausen/node-ogone-directlink.git"
Expand All @@ -16,7 +16,8 @@
"dependencies": {
"xml2js": "0.x.x",
"sugar": "1.x.x",
"request": "1.x.x"
"request": "1.x.x",
"json-schema": "0.x.x"
},
"devDependencies": {
"nodeunit": "0.x.x"
Expand Down

0 comments on commit bbab55f

Please sign in to comment.