dotdashpay
Advanced tools
Comparing version 0.3.1 to 0.3.2
@@ -6,24 +6,20 @@ /** | ||
var dotdashpay = require("dotdashpay"); | ||
dotdashpay.setup({ | ||
simulate: true | ||
}); | ||
var args = { | ||
staticIp: "192.168.1.128", | ||
staticSubnetMask: "255.255.255.0", | ||
staticGateway: "192.168.1.1", | ||
staticDns: "8.8.8.8", | ||
saveConfiguration: true, | ||
autoReconnect: true, | ||
staticIp: "192.168.1.128", | ||
staticSubnetMask: "255.255.255.0", | ||
staticGateway: "192.168.1.1", | ||
staticDns: "8.8.8.8", | ||
saveConfiguration: true, | ||
autoReconnect: true, | ||
}; | ||
dotdashpay.hardware.configureEthernet(args) | ||
.onConfiguredEthernet(function(response) {}) | ||
.onError(function(errorData) { | ||
if (errorData.errorCode == "") { | ||
console.log("Error: " + errorData.errorMessage); | ||
} | ||
}); | ||
.onConfiguredEthernet(function(response) { | ||
console.log("Received onConfiguredEthernet response", JSON.stringify(response)); | ||
}) | ||
.onError(function(errorData) { | ||
console.log("Error", JSON.stringify(errorData)); | ||
}); |
@@ -6,20 +6,16 @@ /** | ||
var dotdashpay = require("dotdashpay"); | ||
dotdashpay.setup({ | ||
simulate: true | ||
}); | ||
var args = { | ||
peripheralName: "MagTekSureSwipe21040145", | ||
disable: false, | ||
peripheralName: "MagTekSureSwipe21040145", | ||
disable: false, | ||
}; | ||
dotdashpay.hardware.configurePeripheral(args) | ||
.onConfiguredPeripheral(function(response) {}) | ||
.onError(function(errorData) { | ||
if (errorData.errorCode == "") { | ||
console.log("Error: " + errorData.errorMessage); | ||
} | ||
}); | ||
.onConfiguredPeripheral(function(response) { | ||
console.log("Received onConfiguredPeripheral response", JSON.stringify(response)); | ||
}) | ||
.onError(function(errorData) { | ||
console.log("Error", JSON.stringify(errorData)); | ||
}); |
@@ -6,21 +6,16 @@ /** | ||
var dotdashpay = require("dotdashpay"); | ||
dotdashpay.setup({ | ||
simulate: true | ||
}); | ||
var args = { | ||
livemode: false, | ||
livemode: false, | ||
}; | ||
dotdashpay.payment.configureProcessor(args) | ||
.onConfiguredProcessor(function(response) { | ||
var livemode = response.livemode; // livemode = false | ||
}) | ||
.onError(function(errorData) { | ||
if (errorData.errorCode == "") { | ||
console.log("Error: " + errorData.errorMessage); | ||
} | ||
}); | ||
.onConfiguredProcessor(function(response) { | ||
console.log("Received onConfiguredProcessor response", JSON.stringify(response)); | ||
var livemode = response.livemode; // e.g. false | ||
}) | ||
.onError(function(errorData) { | ||
console.log("Error", JSON.stringify(errorData)); | ||
}); |
@@ -6,28 +6,24 @@ /** | ||
var dotdashpay = require("dotdashpay"); | ||
dotdashpay.setup({ | ||
simulate: true | ||
}); | ||
var args = { | ||
essid: "Network Name", | ||
password: "wifi_password", | ||
username: "wifi_username", | ||
x509cert: "308202123082017b02020dfa300d06092a864886f70d010105050030819b310b3009060355040613024a50310e300c06035504081305546f6b796f3110300e060355040713074368756f2d6b753111300f060355040a13084672616e6b34444431183016060355040b130f5765624365727420537570706f7274311830160603550403130f4672616e6b344444205765622043413123302106092a864886f70d0109011614737570706f7274406672616e6b3464642e636f6d301e170d3132303832323035323635345a170d3137303832313035323635345a304a310b3009060355040613024a50310e300c06035504080c05546f6b796f3111300f060355040a0c084672616e6b3444443118301606035504030c0f7777772e6578616d706c652e636f6d305c300d06092a864886f70d0101010500034b0030480241009bfc6690798442bbab13fd2b7bf8de1512e5f193e3068a7bb8b1e19e26bb9501bfe730ed648502dd1569a834b006ec3f353c1e1b2b8ffa8f001bdf07c6ac53070203010001300d06092a864886f70d01010505000381810014b64cbb817933e671a4da516fcb081d8d60ecbc18c7734759b1f22048bb61fafc4dad898dd121ebd5d8e5bad6a636fd745083b60fc71ddf7de52e817f45e09fe23e79eed73031c72072d9582e2afe125a3445a119087c89475f4a95be23214a5372da2a052f2ec970f65bfafddfb431b2c14a9c062543a1e6b41e7f869b16400a", | ||
staticIp: "192.168.1.128", | ||
staticSubnetMask: "255.255.255.0", | ||
staticGateway: "192.168.1.1", | ||
staticDns: "8.8.8.8", | ||
saveConfiguration: true, | ||
autoReconnect: true, | ||
essid: "Network Name", | ||
password: "wifi_password", | ||
username: "wifi_username", | ||
x509cert: "308202123082017b02020dfa300d06092a864886f70d010105050030819b310b3009060355040613024a50310e300c06035504081305546f6b796f3110300e060355040713074368756f2d6b753111300f060355040a13084672616e6b34444431183016060355040b130f5765624365727420537570706f7274311830160603550403130f4672616e6b344444205765622043413123302106092a864886f70d0109011614737570706f7274406672616e6b3464642e636f6d301e170d3132303832323035323635345a170d3137303832313035323635345a304a310b3009060355040613024a50310e300c06035504080c05546f6b796f3111300f060355040a0c084672616e6b3444443118301606035504030c0f7777772e6578616d706c652e636f6d305c300d06092a864886f70d0101010500034b0030480241009bfc6690798442bbab13fd2b7bf8de1512e5f193e3068a7bb8b1e19e26bb9501bfe730ed648502dd1569a834b006ec3f353c1e1b2b8ffa8f001bdf07c6ac53070203010001300d06092a864886f70d01010505000381810014b64cbb817933e671a4da516fcb081d8d60ecbc18c7734759b1f22048bb61fafc4dad898dd121ebd5d8e5bad6a636fd745083b60fc71ddf7de52e817f45e09fe23e79eed73031c72072d9582e2afe125a3445a119087c89475f4a95be23214a5372da2a052f2ec970f65bfafddfb431b2c14a9c062543a1e6b41e7f869b16400a", | ||
staticIp: "192.168.1.128", | ||
staticSubnetMask: "255.255.255.0", | ||
staticGateway: "192.168.1.1", | ||
staticDns: "8.8.8.8", | ||
saveConfiguration: true, | ||
autoReconnect: true, | ||
}; | ||
dotdashpay.hardware.configureWifi(args) | ||
.onConfiguredWifi(function(response) {}) | ||
.onError(function(errorData) { | ||
if (errorData.errorCode == "") { | ||
console.log("Error: " + errorData.errorMessage); | ||
} | ||
}); | ||
.onConfiguredWifi(function(response) { | ||
console.log("Received onConfiguredWifi response", JSON.stringify(response)); | ||
}) | ||
.onError(function(errorData) { | ||
console.log("Error", JSON.stringify(errorData)); | ||
}); |
@@ -6,20 +6,15 @@ /** | ||
var dotdashpay = require("dotdashpay"); | ||
dotdashpay.setup({ | ||
simulate: true | ||
}); | ||
var args = {}; | ||
dotdashpay.hardware.getConnectedPeripherals(args) | ||
.onRetrievedConnectedPeripherals(function(response) { | ||
var attachedValidPeriphs = response.attachedValidPeriphs; // attachedValidPeriphs = [[u'MagTekSureSwipe21040145', u'...']] | ||
var attachedErrorPeriphs = response.attachedErrorPeriphs; // attachedErrorPeriphs = [[]] | ||
}) | ||
.onError(function(errorData) { | ||
if (errorData.errorCode == "") { | ||
console.log("Error: " + errorData.errorMessage); | ||
} | ||
}); | ||
.onRetrievedConnectedPeripherals(function(response) { | ||
console.log("Received onRetrievedConnectedPeripherals response", JSON.stringify(response)); | ||
var attachedValidPeriphs = response.attachedValidPeriphs; // e.g. [[u'MagTekSureSwipe21040145', u'...']] | ||
var attachedErrorPeriphs = response.attachedErrorPeriphs; // [[]] | ||
}) | ||
.onError(function(errorData) { | ||
console.log("Error", JSON.stringify(errorData)); | ||
}); |
@@ -6,21 +6,16 @@ /** | ||
var dotdashpay = require("dotdashpay"); | ||
dotdashpay.setup({ | ||
simulate: true | ||
}); | ||
var args = { | ||
token: "aeac1bc8f0735e4283305652ab", | ||
token: "aeac1bc8f0735e4283305652ab", | ||
}; | ||
dotdashpay.information.getCustomerId(args) | ||
.onRetrievedCustomerId(function(response) { | ||
var customerId = response.customerId; // customerId = "2DAuJMBrMyaC" | ||
}) | ||
.onError(function(errorData) { | ||
if (errorData.errorCode == "") { | ||
console.log("Error: " + errorData.errorMessage); | ||
} | ||
}); | ||
.onRetrievedCustomerId(function(response) { | ||
console.log("Received onRetrievedCustomerId response", JSON.stringify(response)); | ||
var customerId = response.customerId; // e.g. "2DAuJMBrMyaC" | ||
}) | ||
.onError(function(errorData) { | ||
console.log("Error", JSON.stringify(errorData)); | ||
}); |
@@ -6,20 +6,15 @@ /** | ||
var dotdashpay = require("dotdashpay"); | ||
dotdashpay.setup({ | ||
simulate: true | ||
}); | ||
var args = {}; | ||
dotdashpay.hardware.getDatalinkStatus(args) | ||
.onRetrievedDatalinkStatus(function(response) { | ||
var connected = response.connected; // connected = true | ||
var info = response.info; // info = "Human-readable description" | ||
}) | ||
.onError(function(errorData) { | ||
if (errorData.errorCode == "") { | ||
console.log("Error: " + errorData.errorMessage); | ||
} | ||
}); | ||
.onRetrievedDatalinkStatus(function(response) { | ||
console.log("Received onRetrievedDatalinkStatus response", JSON.stringify(response)); | ||
var connected = response.connected; // e.g. true | ||
var info = response.info; // "Human-readable description" | ||
}) | ||
.onError(function(errorData) { | ||
console.log("Error", JSON.stringify(errorData)); | ||
}); |
@@ -6,22 +6,17 @@ /** | ||
var dotdashpay = require("dotdashpay"); | ||
dotdashpay.setup({ | ||
simulate: true | ||
}); | ||
var args = {}; | ||
dotdashpay.hardware.getInternetStatus(args) | ||
.onRetrievedInternetStatus(function(response) { | ||
var connected = response.connected; // connected = true | ||
var info = response.info; // info = "Human-readable description" | ||
var connectedInterfaces = response.connectedInterfaces; // connectedInterfaces = [[u'wifi', u'...']] | ||
var ipAddresses = response.ipAddresses; // ipAddresses = [[u'192.168.1.128', u'...']] | ||
}) | ||
.onError(function(errorData) { | ||
if (errorData.errorCode == "") { | ||
console.log("Error: " + errorData.errorMessage); | ||
} | ||
}); | ||
.onRetrievedInternetStatus(function(response) { | ||
console.log("Received onRetrievedInternetStatus response", JSON.stringify(response)); | ||
var connected = response.connected; // e.g. true | ||
var info = response.info; // "Human-readable description" | ||
var connectedInterfaces = response.connectedInterfaces; // [[u'wifi', u'...']] | ||
var ipAddresses = response.ipAddresses; // [[u'192.168.1.128', u'...']] | ||
}) | ||
.onError(function(errorData) { | ||
console.log("Error", JSON.stringify(errorData)); | ||
}); |
@@ -6,43 +6,39 @@ /** | ||
var dotdashpay = require("dotdashpay"); | ||
dotdashpay.setup({ | ||
simulate: true | ||
}); | ||
var args = { | ||
paymentDataId: "pdid-iPqy9F82v5qexbtz", | ||
cents: 128, | ||
currency: "USD", | ||
paymentDataId: "pdid-iPqy9F82v5qexbtz", | ||
cents: 128, | ||
currency: "USD", | ||
}; | ||
dotdashpay.payment.preAuthorize(args) | ||
.onStartedPreAuthorizing(function(response) { | ||
var paymentDataId = response.paymentDataId; // paymentDataId = "pdid-iPqy9F82v5qexbtz" | ||
var cents = response.cents; // cents = 128 | ||
var currency = response.currency; // currency = "USD" | ||
var livemode = response.livemode; // livemode = false | ||
}) | ||
.onPreAuthorized(function(response) { | ||
var status = response.status; // status = "SUCCESS" | ||
var paymentDataId = response.paymentDataId; // paymentDataId = "pdid-iPqy9F82v5qexbtz" | ||
var preauthId = response.preauthId; // preauthId = "paut-Eo9YqkOTnmxt6EcL" | ||
var info = response.info; // info = "Human-readable description" | ||
var customerId = response.customerId; // customerId = "2DAuJMBrMyaC" | ||
var merchantAccountId = response.merchantAccountId; // merchantAccountId = "merchantAccountNumber" | ||
var cardType = response.cardType; // cardType = "Visa" | ||
var last4 = response.last4; // last4 = "0000" | ||
var commercial = response.commercial; // commercial = false | ||
var debit = response.debit; // debit = false | ||
var createdAt = response.createdAt; // createdAt = "915148799.75" | ||
var cents = response.cents; // cents = 128 | ||
var currency = response.currency; // currency = "USD" | ||
var livemode = response.livemode; // livemode = false | ||
var paymentType = response.paymentType; // paymentType = "CARD" | ||
}) | ||
.onError(function(errorData) { | ||
if (errorData.errorCode == "") { | ||
console.log("Error: " + errorData.errorMessage); | ||
} | ||
}); | ||
.onStartedPreAuthorizing(function(response) { | ||
console.log("Received onStartedPreAuthorizing response", JSON.stringify(response)); | ||
var paymentDataId = response.paymentDataId; // e.g. "pdid-iPqy9F82v5qexbtz" | ||
var cents = response.cents; // 128 | ||
var currency = response.currency; // "USD" | ||
var livemode = response.livemode; // false | ||
}) | ||
.onPreAuthorized(function(response) { | ||
console.log("Received onPreAuthorized response", JSON.stringify(response)); | ||
var status = response.status; // e.g. "SUCCESS" | ||
var paymentDataId = response.paymentDataId; // "pdid-iPqy9F82v5qexbtz" | ||
var preauthId = response.preauthId; // "paut-Eo9YqkOTnmxt6EcL" | ||
var info = response.info; // "Human-readable description" | ||
var customerId = response.customerId; // "2DAuJMBrMyaC" | ||
var merchantAccountId = response.merchantAccountId; // "merchantAccountNumber" | ||
var cardType = response.cardType; // "Visa" | ||
var last4 = response.last4; // "0000" | ||
var commercial = response.commercial; // false | ||
var debit = response.debit; // false | ||
var createdAt = response.createdAt; // "915148799.75" | ||
var cents = response.cents; // 128 | ||
var currency = response.currency; // "USD" | ||
var livemode = response.livemode; // false | ||
var paymentType = response.paymentType; // "CARD" | ||
}) | ||
.onError(function(errorData) { | ||
console.log("Error", JSON.stringify(errorData)); | ||
}); |
@@ -6,22 +6,17 @@ /** | ||
var dotdashpay = require("dotdashpay"); | ||
dotdashpay.setup({ | ||
simulate: true | ||
}); | ||
var args = { | ||
level: "DEBUG", | ||
level: "DEBUG", | ||
}; | ||
dotdashpay.information.receiveLogs(args) | ||
.onReceivedLogs(function(response) { | ||
var logMessage = response.logMessage; // logMessage = "The roof is on fire (you may need some water)." | ||
var level = response.level; // level = "DEBUG" | ||
}) | ||
.onError(function(errorData) { | ||
if (errorData.errorCode == "") { | ||
console.log("Error: " + errorData.errorMessage); | ||
} | ||
}); | ||
.onReceivedLogs(function(response) { | ||
console.log("Received onReceivedLogs response", JSON.stringify(response)); | ||
var logMessage = response.logMessage; // e.g. "The roof is on fire (you may need some water)." | ||
var level = response.level; // "DEBUG" | ||
}) | ||
.onError(function(errorData) { | ||
console.log("Error", JSON.stringify(errorData)); | ||
}); |
@@ -6,27 +6,23 @@ /** | ||
var dotdashpay = require("dotdashpay"); | ||
dotdashpay.setup({ | ||
simulate: true | ||
}); | ||
var args = { | ||
useExistingData: false, | ||
useExistingDataSecondsWindow: 5, | ||
useExistingData: false, | ||
useExistingDataSecondsWindow: 5, | ||
}; | ||
dotdashpay.hardware.receivePaymentData(args) | ||
.onStartedReceivingPaymentData(function(response) { | ||
var peripheralName = response.peripheralName; // peripheralName = "MagTekSureSwipe21040145" | ||
}) | ||
.onReceivedPaymentData(function(response) { | ||
var paymentDataId = response.paymentDataId; // paymentDataId = "pdid-iPqy9F82v5qexbtz" | ||
var token = response.token; // token = "aeac1bc8f0735e4283305652ab" | ||
var peripheralName = response.peripheralName; // peripheralName = "MagTekSureSwipe21040145" | ||
}) | ||
.onError(function(errorData) { | ||
if (errorData.errorCode == "") { | ||
console.log("Error: " + errorData.errorMessage); | ||
} | ||
}); | ||
.onStartedReceivingPaymentData(function(response) { | ||
console.log("Received onStartedReceivingPaymentData response", JSON.stringify(response)); | ||
var peripheralName = response.peripheralName; // e.g. "MagTekSureSwipe21040145" | ||
}) | ||
.onReceivedPaymentData(function(response) { | ||
console.log("Received onReceivedPaymentData response", JSON.stringify(response)); | ||
var paymentDataId = response.paymentDataId; // e.g. "pdid-iPqy9F82v5qexbtz" | ||
var token = response.token; // "aeac1bc8f0735e4283305652ab" | ||
var peripheralName = response.peripheralName; // "MagTekSureSwipe21040145" | ||
}) | ||
.onError(function(errorData) { | ||
console.log("Error", JSON.stringify(errorData)); | ||
}); |
@@ -6,52 +6,50 @@ /** | ||
var dotdashpay = require("dotdashpay"); | ||
dotdashpay.setup({ | ||
simulate: true | ||
}); | ||
var args = { | ||
cents: 128, | ||
currency: "USD", | ||
useExistingData: false, | ||
useExistingDataSecondsWindow: 5, | ||
cents: 128, | ||
currency: "USD", | ||
useExistingData: false, | ||
useExistingDataSecondsWindow: 5, | ||
}; | ||
dotdashpay.payment.receivePaymentDataThenPreAuthorize(args) | ||
.onStartedReceivingPaymentData(function(response) { | ||
var peripheralName = response.peripheralName; // peripheralName = "MagTekSureSwipe21040145" | ||
}) | ||
.onReceivedPaymentData(function(response) { | ||
var paymentDataId = response.paymentDataId; // paymentDataId = "pdid-iPqy9F82v5qexbtz" | ||
var token = response.token; // token = "aeac1bc8f0735e4283305652ab" | ||
var peripheralName = response.peripheralName; // peripheralName = "MagTekSureSwipe21040145" | ||
}) | ||
.onStartedPreAuthorizing(function(response) { | ||
var paymentDataId = response.paymentDataId; // paymentDataId = "pdid-iPqy9F82v5qexbtz" | ||
var cents = response.cents; // cents = 128 | ||
var currency = response.currency; // currency = "USD" | ||
var livemode = response.livemode; // livemode = false | ||
}) | ||
.onPreAuthorized(function(response) { | ||
var status = response.status; // status = "SUCCESS" | ||
var paymentDataId = response.paymentDataId; // paymentDataId = "pdid-iPqy9F82v5qexbtz" | ||
var preauthId = response.preauthId; // preauthId = "paut-Eo9YqkOTnmxt6EcL" | ||
var info = response.info; // info = "Human-readable description" | ||
var customerId = response.customerId; // customerId = "2DAuJMBrMyaC" | ||
var merchantAccountId = response.merchantAccountId; // merchantAccountId = "merchantAccountNumber" | ||
var cardType = response.cardType; // cardType = "Visa" | ||
var last4 = response.last4; // last4 = "0000" | ||
var commercial = response.commercial; // commercial = false | ||
var debit = response.debit; // debit = false | ||
var createdAt = response.createdAt; // createdAt = "915148799.75" | ||
var cents = response.cents; // cents = 128 | ||
var currency = response.currency; // currency = "USD" | ||
var livemode = response.livemode; // livemode = false | ||
var paymentType = response.paymentType; // paymentType = "CARD" | ||
}) | ||
.onError(function(errorData) { | ||
if (errorData.errorCode == "") { | ||
console.log("Error: " + errorData.errorMessage); | ||
} | ||
}); | ||
.onStartedReceivingPaymentData(function(response) { | ||
console.log("Received onStartedReceivingPaymentData response", JSON.stringify(response)); | ||
var peripheralName = response.peripheralName; // e.g. "MagTekSureSwipe21040145" | ||
}) | ||
.onReceivedPaymentData(function(response) { | ||
console.log("Received onReceivedPaymentData response", JSON.stringify(response)); | ||
var paymentDataId = response.paymentDataId; // e.g. "pdid-iPqy9F82v5qexbtz" | ||
var token = response.token; // "aeac1bc8f0735e4283305652ab" | ||
var peripheralName = response.peripheralName; // "MagTekSureSwipe21040145" | ||
}) | ||
.onStartedPreAuthorizing(function(response) { | ||
console.log("Received onStartedPreAuthorizing response", JSON.stringify(response)); | ||
var paymentDataId = response.paymentDataId; // e.g. "pdid-iPqy9F82v5qexbtz" | ||
var cents = response.cents; // 128 | ||
var currency = response.currency; // "USD" | ||
var livemode = response.livemode; // false | ||
}) | ||
.onPreAuthorized(function(response) { | ||
console.log("Received onPreAuthorized response", JSON.stringify(response)); | ||
var status = response.status; // e.g. "SUCCESS" | ||
var paymentDataId = response.paymentDataId; // "pdid-iPqy9F82v5qexbtz" | ||
var preauthId = response.preauthId; // "paut-Eo9YqkOTnmxt6EcL" | ||
var info = response.info; // "Human-readable description" | ||
var customerId = response.customerId; // "2DAuJMBrMyaC" | ||
var merchantAccountId = response.merchantAccountId; // "merchantAccountNumber" | ||
var cardType = response.cardType; // "Visa" | ||
var last4 = response.last4; // "0000" | ||
var commercial = response.commercial; // false | ||
var debit = response.debit; // false | ||
var createdAt = response.createdAt; // "915148799.75" | ||
var cents = response.cents; // 128 | ||
var currency = response.currency; // "USD" | ||
var livemode = response.livemode; // false | ||
var paymentType = response.paymentType; // "CARD" | ||
}) | ||
.onError(function(errorData) { | ||
console.log("Error", JSON.stringify(errorData)); | ||
}); |
@@ -6,54 +6,52 @@ /** | ||
var dotdashpay = require("dotdashpay"); | ||
dotdashpay.setup({ | ||
simulate: true | ||
}); | ||
var args = { | ||
cents: 128, | ||
currency: "USD", | ||
useExistingData: false, | ||
useExistingDataSecondsWindow: 5, | ||
cents: 128, | ||
currency: "USD", | ||
useExistingData: false, | ||
useExistingDataSecondsWindow: 5, | ||
}; | ||
dotdashpay.payment.receivePaymentDataThenSettle(args) | ||
.onStartedReceivingPaymentData(function(response) { | ||
var peripheralName = response.peripheralName; // peripheralName = "MagTekSureSwipe21040145" | ||
}) | ||
.onReceivedPaymentData(function(response) { | ||
var paymentDataId = response.paymentDataId; // paymentDataId = "pdid-iPqy9F82v5qexbtz" | ||
var token = response.token; // token = "aeac1bc8f0735e4283305652ab" | ||
var peripheralName = response.peripheralName; // peripheralName = "MagTekSureSwipe21040145" | ||
}) | ||
.onStartedSettling(function(response) { | ||
var paymentDataId = response.paymentDataId; // paymentDataId = "pdid-iPqy9F82v5qexbtz" | ||
var preauthId = response.preauthId; // preauthId = "paut-Eo9YqkOTnmxt6EcL" | ||
var cents = response.cents; // cents = 128 | ||
var currency = response.currency; // currency = "USD" | ||
var livemode = response.livemode; // livemode = false | ||
}) | ||
.onSettled(function(response) { | ||
var status = response.status; // status = "SUCCESS" | ||
var paymentDataId = response.paymentDataId; // paymentDataId = "pdid-iPqy9F82v5qexbtz" | ||
var preauthId = response.preauthId; // preauthId = "paut-Eo9YqkOTnmxt6EcL" | ||
var settleId = response.settleId; // settleId = "txn-NG9jR86SC3hjzQHA8h5X3pwz" | ||
var info = response.info; // info = "Human-readable description" | ||
var customerId = response.customerId; // customerId = "2DAuJMBrMyaC" | ||
var merchantAccountId = response.merchantAccountId; // merchantAccountId = "merchantAccountNumber" | ||
var cardType = response.cardType; // cardType = "Visa" | ||
var last4 = response.last4; // last4 = "0000" | ||
var commercial = response.commercial; // commercial = false | ||
var debit = response.debit; // debit = false | ||
var createdAt = response.createdAt; // createdAt = "915148799.75" | ||
var cents = response.cents; // cents = 128 | ||
var currency = response.currency; // currency = "USD" | ||
var livemode = response.livemode; // livemode = false | ||
var paymentType = response.paymentType; // paymentType = "CARD" | ||
}) | ||
.onError(function(errorData) { | ||
if (errorData.errorCode == "") { | ||
console.log("Error: " + errorData.errorMessage); | ||
} | ||
}); | ||
.onStartedReceivingPaymentData(function(response) { | ||
console.log("Received onStartedReceivingPaymentData response", JSON.stringify(response)); | ||
var peripheralName = response.peripheralName; // e.g. "MagTekSureSwipe21040145" | ||
}) | ||
.onReceivedPaymentData(function(response) { | ||
console.log("Received onReceivedPaymentData response", JSON.stringify(response)); | ||
var paymentDataId = response.paymentDataId; // e.g. "pdid-iPqy9F82v5qexbtz" | ||
var token = response.token; // "aeac1bc8f0735e4283305652ab" | ||
var peripheralName = response.peripheralName; // "MagTekSureSwipe21040145" | ||
}) | ||
.onStartedSettling(function(response) { | ||
console.log("Received onStartedSettling response", JSON.stringify(response)); | ||
var paymentDataId = response.paymentDataId; // e.g. "pdid-iPqy9F82v5qexbtz" | ||
var preauthId = response.preauthId; // "paut-Eo9YqkOTnmxt6EcL" | ||
var cents = response.cents; // 128 | ||
var currency = response.currency; // "USD" | ||
var livemode = response.livemode; // false | ||
}) | ||
.onSettled(function(response) { | ||
console.log("Received onSettled response", JSON.stringify(response)); | ||
var status = response.status; // e.g. "SUCCESS" | ||
var paymentDataId = response.paymentDataId; // "pdid-iPqy9F82v5qexbtz" | ||
var preauthId = response.preauthId; // "paut-Eo9YqkOTnmxt6EcL" | ||
var settleId = response.settleId; // "txn-NG9jR86SC3hjzQHA8h5X3pwz" | ||
var info = response.info; // "Human-readable description" | ||
var customerId = response.customerId; // "2DAuJMBrMyaC" | ||
var merchantAccountId = response.merchantAccountId; // "merchantAccountNumber" | ||
var cardType = response.cardType; // "Visa" | ||
var last4 = response.last4; // "0000" | ||
var commercial = response.commercial; // false | ||
var debit = response.debit; // false | ||
var createdAt = response.createdAt; // "915148799.75" | ||
var cents = response.cents; // 128 | ||
var currency = response.currency; // "USD" | ||
var livemode = response.livemode; // false | ||
var paymentType = response.paymentType; // "CARD" | ||
}) | ||
.onError(function(errorData) { | ||
console.log("Error", JSON.stringify(errorData)); | ||
}); |
@@ -1,22 +0,25 @@ | ||
// @lib-setup() | ||
// @standalone(try_api_short) | ||
var dotdashpay = require("dotdashpay"); | ||
dotdashpay.setup({ | ||
simulate: true | ||
simulate: true, | ||
apiToken: "@api-token()" | ||
}); | ||
// @lib-setup-end() | ||
// @try-api-short() | ||
dotdashpay.payment.receivePaymentDataThenSettle({ | ||
cents: 128 | ||
}) | ||
.onError(function(errorData) { | ||
console.error("Unexpected error while processing receivePaymentDataThenSettle: " + errorData); | ||
}) | ||
.onSettled(function(response) { | ||
console.log("Settlement finished! Transaction id: " + response.settle_id); | ||
}); | ||
// @try-api-short-end() | ||
dotdashpay.payment.receivePaymentDataThenSettle({ cents: 100 }) | ||
.onSettled(function(response) { | ||
console.log("sSettlement finished! Transaction id: " + response.settleId); | ||
process.exit(0); | ||
}) | ||
.onError(function(errorData) { | ||
console.error("Unexpected error while processing receivePaymentDataThenSettle: " + errorData); | ||
}); | ||
// @standalone-end() | ||
/** | ||
@@ -27,4 +30,2 @@ Autogenerated example for API request: PreAuthorize | ||
// @example() | ||
// @example-end() | ||
@@ -34,43 +35,48 @@ // @reference() | ||
// @example-args(Payment.PreAuthorize) | ||
var args = { | ||
paymentDataId: "pdid-iPqy9F82v5qexbtz", | ||
cents: 128, | ||
currency: "USD", | ||
paymentDataId: "pdid-iPqy9F82v5qexbtz", | ||
cents: 128, | ||
currency: "USD", | ||
}; | ||
// @example-args-end() | ||
// @example-request(Payment.PreAuthorize) | ||
dotdashpay.payment.preAuthorize(args) | ||
.onStartedPreAuthorizing(function(response) { | ||
var paymentDataId = response.paymentDataId; // paymentDataId = "pdid-iPqy9F82v5qexbtz" | ||
var cents = response.cents; // cents = 128 | ||
var currency = response.currency; // currency = "USD" | ||
var livemode = response.livemode; // livemode = false | ||
}) | ||
.onPreAuthorized(function(response) { | ||
var status = response.status; // status = "SUCCESS" | ||
var paymentDataId = response.paymentDataId; // paymentDataId = "pdid-iPqy9F82v5qexbtz" | ||
var preauthId = response.preauthId; // preauthId = "paut-Eo9YqkOTnmxt6EcL" | ||
var info = response.info; // info = "Human-readable description" | ||
var customerId = response.customerId; // customerId = "2DAuJMBrMyaC" | ||
var merchantAccountId = response.merchantAccountId; // merchantAccountId = "merchantAccountNumber" | ||
var cardType = response.cardType; // cardType = "Visa" | ||
var last4 = response.last4; // last4 = "0000" | ||
var commercial = response.commercial; // commercial = false | ||
var debit = response.debit; // debit = false | ||
var createdAt = response.createdAt; // createdAt = "915148799.75" | ||
var cents = response.cents; // cents = 128 | ||
var currency = response.currency; // currency = "USD" | ||
var livemode = response.livemode; // livemode = false | ||
var paymentType = response.paymentType; // paymentType = "CARD" | ||
}) | ||
.onError(function(errorData) { | ||
if (errorData.errorCode == "") { | ||
console.log("Error: " + errorData.errorMessage); | ||
} | ||
}); | ||
.onStartedPreAuthorizing(function(response) { | ||
console.log("Received onStartedPreAuthorizing response", JSON.stringify(response)); | ||
var paymentDataId = response.paymentDataId; // e.g. "pdid-iPqy9F82v5qexbtz" | ||
var cents = response.cents; // 128 | ||
var currency = response.currency; // "USD" | ||
var livemode = response.livemode; // false | ||
}) | ||
.onPreAuthorized(function(response) { | ||
console.log("Received onPreAuthorized response", JSON.stringify(response)); | ||
var status = response.status; // e.g. "SUCCESS" | ||
var paymentDataId = response.paymentDataId; // "pdid-iPqy9F82v5qexbtz" | ||
var preauthId = response.preauthId; // "paut-Eo9YqkOTnmxt6EcL" | ||
var info = response.info; // "Human-readable description" | ||
var customerId = response.customerId; // "2DAuJMBrMyaC" | ||
var merchantAccountId = response.merchantAccountId; // "merchantAccountNumber" | ||
var cardType = response.cardType; // "Visa" | ||
var last4 = response.last4; // "0000" | ||
var commercial = response.commercial; // false | ||
var debit = response.debit; // false | ||
var createdAt = response.createdAt; // "915148799.75" | ||
var cents = response.cents; // 128 | ||
var currency = response.currency; // "USD" | ||
var livemode = response.livemode; // false | ||
var paymentType = response.paymentType; // "CARD" | ||
}) | ||
.onError(function(errorData) { | ||
console.log("Error", JSON.stringify(errorData)); | ||
}); | ||
// @example-request-end() | ||
/** | ||
@@ -81,4 +87,2 @@ Autogenerated example for API request: Settle | ||
// @example() | ||
// @example-end() | ||
@@ -88,46 +92,51 @@ // @reference() | ||
// @example-args(Payment.Settle) | ||
var args = { | ||
paymentDataId: "pdid-iPqy9F82v5qexbtz", | ||
preauthId: "paut-Eo9YqkOTnmxt6EcL", | ||
cents: 128, | ||
currency: "USD", | ||
paymentDataId: "pdid-iPqy9F82v5qexbtz", | ||
preauthId: "paut-Eo9YqkOTnmxt6EcL", | ||
cents: 128, | ||
currency: "USD", | ||
}; | ||
// @example-args-end() | ||
// @example-request(Payment.Settle) | ||
dotdashpay.payment.settle(args) | ||
.onStartedSettling(function(response) { | ||
var paymentDataId = response.paymentDataId; // paymentDataId = "pdid-iPqy9F82v5qexbtz" | ||
var preauthId = response.preauthId; // preauthId = "paut-Eo9YqkOTnmxt6EcL" | ||
var cents = response.cents; // cents = 128 | ||
var currency = response.currency; // currency = "USD" | ||
var livemode = response.livemode; // livemode = false | ||
}) | ||
.onSettled(function(response) { | ||
var status = response.status; // status = "SUCCESS" | ||
var paymentDataId = response.paymentDataId; // paymentDataId = "pdid-iPqy9F82v5qexbtz" | ||
var preauthId = response.preauthId; // preauthId = "paut-Eo9YqkOTnmxt6EcL" | ||
var settleId = response.settleId; // settleId = "txn-NG9jR86SC3hjzQHA8h5X3pwz" | ||
var info = response.info; // info = "Human-readable description" | ||
var customerId = response.customerId; // customerId = "2DAuJMBrMyaC" | ||
var merchantAccountId = response.merchantAccountId; // merchantAccountId = "merchantAccountNumber" | ||
var cardType = response.cardType; // cardType = "Visa" | ||
var last4 = response.last4; // last4 = "0000" | ||
var commercial = response.commercial; // commercial = false | ||
var debit = response.debit; // debit = false | ||
var createdAt = response.createdAt; // createdAt = "915148799.75" | ||
var cents = response.cents; // cents = 128 | ||
var currency = response.currency; // currency = "USD" | ||
var livemode = response.livemode; // livemode = false | ||
var paymentType = response.paymentType; // paymentType = "CARD" | ||
}) | ||
.onError(function(errorData) { | ||
if (errorData.errorCode == "") { | ||
console.log("Error: " + errorData.errorMessage); | ||
} | ||
}); | ||
.onStartedSettling(function(response) { | ||
console.log("Received onStartedSettling response", JSON.stringify(response)); | ||
var paymentDataId = response.paymentDataId; // e.g. "pdid-iPqy9F82v5qexbtz" | ||
var preauthId = response.preauthId; // "paut-Eo9YqkOTnmxt6EcL" | ||
var cents = response.cents; // 128 | ||
var currency = response.currency; // "USD" | ||
var livemode = response.livemode; // false | ||
}) | ||
.onSettled(function(response) { | ||
console.log("Received onSettled response", JSON.stringify(response)); | ||
var status = response.status; // e.g. "SUCCESS" | ||
var paymentDataId = response.paymentDataId; // "pdid-iPqy9F82v5qexbtz" | ||
var preauthId = response.preauthId; // "paut-Eo9YqkOTnmxt6EcL" | ||
var settleId = response.settleId; // "txn-NG9jR86SC3hjzQHA8h5X3pwz" | ||
var info = response.info; // "Human-readable description" | ||
var customerId = response.customerId; // "2DAuJMBrMyaC" | ||
var merchantAccountId = response.merchantAccountId; // "merchantAccountNumber" | ||
var cardType = response.cardType; // "Visa" | ||
var last4 = response.last4; // "0000" | ||
var commercial = response.commercial; // false | ||
var debit = response.debit; // false | ||
var createdAt = response.createdAt; // "915148799.75" | ||
var cents = response.cents; // 128 | ||
var currency = response.currency; // "USD" | ||
var livemode = response.livemode; // false | ||
var paymentType = response.paymentType; // "CARD" | ||
}) | ||
.onError(function(errorData) { | ||
console.log("Error", JSON.stringify(errorData)); | ||
}); | ||
// @example-request-end() | ||
/** | ||
@@ -138,4 +147,2 @@ Autogenerated example for API request: VoidPreAuthorize | ||
// @example() | ||
// @example-end() | ||
@@ -145,34 +152,38 @@ // @reference() | ||
// @example-args(Payment.VoidPreAuthorize) | ||
var args = { | ||
preauthId: "paut-Eo9YqkOTnmxt6EcL", | ||
preauthId: "paut-Eo9YqkOTnmxt6EcL", | ||
}; | ||
// @example-args-end() | ||
// @example-request(Payment.VoidPreAuthorize) | ||
dotdashpay.payment.voidPreAuthorize(args) | ||
.onVoidedPreAuthorize(function(response) { | ||
var status = response.status; // status = "SUCCESS" | ||
var voidId = response.voidId; // voidId = "void-QTKL0uLZuO1gFaFm" | ||
var info = response.info; // info = "Human-readable description" | ||
var customerId = response.customerId; // customerId = "2DAuJMBrMyaC" | ||
var merchantAccountId = response.merchantAccountId; // merchantAccountId = "merchantAccountNumber" | ||
var cardType = response.cardType; // cardType = "Visa" | ||
var last4 = response.last4; // last4 = "0000" | ||
var commercial = response.commercial; // commercial = false | ||
var debit = response.debit; // debit = false | ||
var createdAt = response.createdAt; // createdAt = "915148799.75" | ||
var cents = response.cents; // cents = 128 | ||
var currency = response.currency; // currency = "USD" | ||
var livemode = response.livemode; // livemode = false | ||
var paymentType = response.paymentType; // paymentType = "CARD" | ||
}) | ||
.onError(function(errorData) { | ||
if (errorData.errorCode == "") { | ||
console.log("Error: " + errorData.errorMessage); | ||
} | ||
}); | ||
.onVoidedPreAuthorize(function(response) { | ||
console.log("Received onVoidedPreAuthorize response", JSON.stringify(response)); | ||
var status = response.status; // e.g. "SUCCESS" | ||
var voidId = response.voidId; // "void-QTKL0uLZuO1gFaFm" | ||
var info = response.info; // "Human-readable description" | ||
var customerId = response.customerId; // "2DAuJMBrMyaC" | ||
var merchantAccountId = response.merchantAccountId; // "merchantAccountNumber" | ||
var cardType = response.cardType; // "Visa" | ||
var last4 = response.last4; // "0000" | ||
var commercial = response.commercial; // false | ||
var debit = response.debit; // false | ||
var createdAt = response.createdAt; // "915148799.75" | ||
var cents = response.cents; // 128 | ||
var currency = response.currency; // "USD" | ||
var livemode = response.livemode; // false | ||
var paymentType = response.paymentType; // "CARD" | ||
}) | ||
.onError(function(errorData) { | ||
console.log("Error", JSON.stringify(errorData)); | ||
}); | ||
// @example-request-end() | ||
/** | ||
@@ -183,4 +194,2 @@ Autogenerated example for API request: Refund | ||
// @example() | ||
// @example-end() | ||
@@ -190,34 +199,38 @@ // @reference() | ||
// @example-args(Payment.Refund) | ||
var args = { | ||
settleId: "txn-NG9jR86SC3hjzQHA8h5X3pwz", | ||
settleId: "txn-NG9jR86SC3hjzQHA8h5X3pwz", | ||
}; | ||
// @example-args-end() | ||
// @example-request(Payment.Refund) | ||
dotdashpay.payment.refund(args) | ||
.onRefunded(function(response) { | ||
var status = response.status; // status = "SUCCESS" | ||
var refundId = response.refundId; // refundId = "rfnd-PFuJxu7hpWKcMsgs" | ||
var info = response.info; // info = "Human-readable description" | ||
var customerId = response.customerId; // customerId = "2DAuJMBrMyaC" | ||
var merchantAccountId = response.merchantAccountId; // merchantAccountId = "merchantAccountNumber" | ||
var cardType = response.cardType; // cardType = "Visa" | ||
var last4 = response.last4; // last4 = "0000" | ||
var commercial = response.commercial; // commercial = false | ||
var debit = response.debit; // debit = false | ||
var createdAt = response.createdAt; // createdAt = "915148799.75" | ||
var cents = response.cents; // cents = 128 | ||
var currency = response.currency; // currency = "USD" | ||
var livemode = response.livemode; // livemode = false | ||
var paymentType = response.paymentType; // paymentType = "CARD" | ||
}) | ||
.onError(function(errorData) { | ||
if (errorData.errorCode == "") { | ||
console.log("Error: " + errorData.errorMessage); | ||
} | ||
}); | ||
.onRefunded(function(response) { | ||
console.log("Received onRefunded response", JSON.stringify(response)); | ||
var status = response.status; // e.g. "SUCCESS" | ||
var refundId = response.refundId; // "rfnd-PFuJxu7hpWKcMsgs" | ||
var info = response.info; // "Human-readable description" | ||
var customerId = response.customerId; // "2DAuJMBrMyaC" | ||
var merchantAccountId = response.merchantAccountId; // "merchantAccountNumber" | ||
var cardType = response.cardType; // "Visa" | ||
var last4 = response.last4; // "0000" | ||
var commercial = response.commercial; // false | ||
var debit = response.debit; // false | ||
var createdAt = response.createdAt; // "915148799.75" | ||
var cents = response.cents; // 128 | ||
var currency = response.currency; // "USD" | ||
var livemode = response.livemode; // false | ||
var paymentType = response.paymentType; // "CARD" | ||
}) | ||
.onError(function(errorData) { | ||
console.log("Error", JSON.stringify(errorData)); | ||
}); | ||
// @example-request-end() | ||
/** | ||
@@ -228,4 +241,2 @@ Autogenerated example for API request: ConfigureProcessor | ||
// @example() | ||
// @example-end() | ||
@@ -235,21 +246,25 @@ // @reference() | ||
// @example-args(Payment.ConfigureProcessor) | ||
var args = { | ||
livemode: false, | ||
livemode: false, | ||
}; | ||
// @example-args-end() | ||
// @example-request(Payment.ConfigureProcessor) | ||
dotdashpay.payment.configureProcessor(args) | ||
.onConfiguredProcessor(function(response) { | ||
var livemode = response.livemode; // livemode = false | ||
}) | ||
.onError(function(errorData) { | ||
if (errorData.errorCode == "") { | ||
console.log("Error: " + errorData.errorMessage); | ||
} | ||
}); | ||
.onConfiguredProcessor(function(response) { | ||
console.log("Received onConfiguredProcessor response", JSON.stringify(response)); | ||
var livemode = response.livemode; // e.g. false | ||
}) | ||
.onError(function(errorData) { | ||
console.log("Error", JSON.stringify(errorData)); | ||
}); | ||
// @example-request-end() | ||
/** | ||
@@ -260,4 +275,2 @@ Autogenerated example for API request: ReceivePaymentDataThenSettle | ||
// @example() | ||
// @example-end() | ||
@@ -267,54 +280,124 @@ // @reference() | ||
// @reference() | ||
// @standalone(try_api_expanded) | ||
var dotdashpay = require("dotdashpay"); | ||
dotdashpay.setup({ | ||
simulate: true, | ||
apiToken: "@api-token()" | ||
}); | ||
var args = { | ||
cents: 128, | ||
currency: "USD", | ||
useExistingData: false, | ||
useExistingDataSecondsWindow: 5, | ||
}; | ||
dotdashpay.payment.receivePaymentDataThenSettle(args) | ||
.onStartedReceivingPaymentData(function(response) { | ||
console.log("Received onStartedReceivingPaymentData response", JSON.stringify(response)); | ||
var peripheralName = response.peripheralName; // e.g. "MagTekSureSwipe21040145" | ||
}) | ||
.onReceivedPaymentData(function(response) { | ||
console.log("Received onReceivedPaymentData response", JSON.stringify(response)); | ||
var paymentDataId = response.paymentDataId; // e.g. "pdid-iPqy9F82v5qexbtz" | ||
var token = response.token; // "aeac1bc8f0735e4283305652ab" | ||
var peripheralName = response.peripheralName; // "MagTekSureSwipe21040145" | ||
}) | ||
.onStartedSettling(function(response) { | ||
console.log("Received onStartedSettling response", JSON.stringify(response)); | ||
var paymentDataId = response.paymentDataId; // e.g. "pdid-iPqy9F82v5qexbtz" | ||
var preauthId = response.preauthId; // "paut-Eo9YqkOTnmxt6EcL" | ||
var cents = response.cents; // 128 | ||
var currency = response.currency; // "USD" | ||
var livemode = response.livemode; // false | ||
}) | ||
.onSettled(function(response) { | ||
console.log("Received onSettled response", JSON.stringify(response)); | ||
var status = response.status; // e.g. "SUCCESS" | ||
var paymentDataId = response.paymentDataId; // "pdid-iPqy9F82v5qexbtz" | ||
var preauthId = response.preauthId; // "paut-Eo9YqkOTnmxt6EcL" | ||
var settleId = response.settleId; // "txn-NG9jR86SC3hjzQHA8h5X3pwz" | ||
var info = response.info; // "Human-readable description" | ||
var customerId = response.customerId; // "2DAuJMBrMyaC" | ||
var merchantAccountId = response.merchantAccountId; // "merchantAccountNumber" | ||
var cardType = response.cardType; // "Visa" | ||
var last4 = response.last4; // "0000" | ||
var commercial = response.commercial; // false | ||
var debit = response.debit; // false | ||
var createdAt = response.createdAt; // "915148799.75" | ||
var cents = response.cents; // 128 | ||
var currency = response.currency; // "USD" | ||
var livemode = response.livemode; // false | ||
var paymentType = response.paymentType; // "CARD" | ||
process.exit(0); | ||
}) | ||
.onError(function(errorData) { | ||
console.log("Error", JSON.stringify(errorData)); | ||
process.exit(0); | ||
}); | ||
// @standalone-end() | ||
// @reference-end() | ||
// @example-args(Payment.ReceivePaymentDataThenSettle) | ||
var args = { | ||
cents: 128, | ||
currency: "USD", | ||
useExistingData: false, | ||
useExistingDataSecondsWindow: 5, | ||
cents: 128, | ||
currency: "USD", | ||
useExistingData: false, | ||
useExistingDataSecondsWindow: 5, | ||
}; | ||
// @example-args-end() | ||
// @example-request(Payment.ReceivePaymentDataThenSettle) | ||
dotdashpay.payment.receivePaymentDataThenSettle(args) | ||
.onStartedReceivingPaymentData(function(response) { | ||
var peripheralName = response.peripheralName; // peripheralName = "MagTekSureSwipe21040145" | ||
}) | ||
.onReceivedPaymentData(function(response) { | ||
var paymentDataId = response.paymentDataId; // paymentDataId = "pdid-iPqy9F82v5qexbtz" | ||
var token = response.token; // token = "aeac1bc8f0735e4283305652ab" | ||
var peripheralName = response.peripheralName; // peripheralName = "MagTekSureSwipe21040145" | ||
}) | ||
.onStartedSettling(function(response) { | ||
var paymentDataId = response.paymentDataId; // paymentDataId = "pdid-iPqy9F82v5qexbtz" | ||
var preauthId = response.preauthId; // preauthId = "paut-Eo9YqkOTnmxt6EcL" | ||
var cents = response.cents; // cents = 128 | ||
var currency = response.currency; // currency = "USD" | ||
var livemode = response.livemode; // livemode = false | ||
}) | ||
.onSettled(function(response) { | ||
var status = response.status; // status = "SUCCESS" | ||
var paymentDataId = response.paymentDataId; // paymentDataId = "pdid-iPqy9F82v5qexbtz" | ||
var preauthId = response.preauthId; // preauthId = "paut-Eo9YqkOTnmxt6EcL" | ||
var settleId = response.settleId; // settleId = "txn-NG9jR86SC3hjzQHA8h5X3pwz" | ||
var info = response.info; // info = "Human-readable description" | ||
var customerId = response.customerId; // customerId = "2DAuJMBrMyaC" | ||
var merchantAccountId = response.merchantAccountId; // merchantAccountId = "merchantAccountNumber" | ||
var cardType = response.cardType; // cardType = "Visa" | ||
var last4 = response.last4; // last4 = "0000" | ||
var commercial = response.commercial; // commercial = false | ||
var debit = response.debit; // debit = false | ||
var createdAt = response.createdAt; // createdAt = "915148799.75" | ||
var cents = response.cents; // cents = 128 | ||
var currency = response.currency; // currency = "USD" | ||
var livemode = response.livemode; // livemode = false | ||
var paymentType = response.paymentType; // paymentType = "CARD" | ||
}) | ||
.onError(function(errorData) { | ||
if (errorData.errorCode == "") { | ||
console.log("Error: " + errorData.errorMessage); | ||
} | ||
}); | ||
.onStartedReceivingPaymentData(function(response) { | ||
console.log("Received onStartedReceivingPaymentData response", JSON.stringify(response)); | ||
var peripheralName = response.peripheralName; // e.g. "MagTekSureSwipe21040145" | ||
}) | ||
.onReceivedPaymentData(function(response) { | ||
console.log("Received onReceivedPaymentData response", JSON.stringify(response)); | ||
var paymentDataId = response.paymentDataId; // e.g. "pdid-iPqy9F82v5qexbtz" | ||
var token = response.token; // "aeac1bc8f0735e4283305652ab" | ||
var peripheralName = response.peripheralName; // "MagTekSureSwipe21040145" | ||
}) | ||
.onStartedSettling(function(response) { | ||
console.log("Received onStartedSettling response", JSON.stringify(response)); | ||
var paymentDataId = response.paymentDataId; // e.g. "pdid-iPqy9F82v5qexbtz" | ||
var preauthId = response.preauthId; // "paut-Eo9YqkOTnmxt6EcL" | ||
var cents = response.cents; // 128 | ||
var currency = response.currency; // "USD" | ||
var livemode = response.livemode; // false | ||
}) | ||
.onSettled(function(response) { | ||
console.log("Received onSettled response", JSON.stringify(response)); | ||
var status = response.status; // e.g. "SUCCESS" | ||
var paymentDataId = response.paymentDataId; // "pdid-iPqy9F82v5qexbtz" | ||
var preauthId = response.preauthId; // "paut-Eo9YqkOTnmxt6EcL" | ||
var settleId = response.settleId; // "txn-NG9jR86SC3hjzQHA8h5X3pwz" | ||
var info = response.info; // "Human-readable description" | ||
var customerId = response.customerId; // "2DAuJMBrMyaC" | ||
var merchantAccountId = response.merchantAccountId; // "merchantAccountNumber" | ||
var cardType = response.cardType; // "Visa" | ||
var last4 = response.last4; // "0000" | ||
var commercial = response.commercial; // false | ||
var debit = response.debit; // false | ||
var createdAt = response.createdAt; // "915148799.75" | ||
var cents = response.cents; // 128 | ||
var currency = response.currency; // "USD" | ||
var livemode = response.livemode; // false | ||
var paymentType = response.paymentType; // "CARD" | ||
}) | ||
.onError(function(errorData) { | ||
console.log("Error", JSON.stringify(errorData)); | ||
}); | ||
// @example-request-end() | ||
/** | ||
@@ -325,4 +408,2 @@ Autogenerated example for API request: ReceivePaymentDataThenPreAuthorize | ||
// @example() | ||
// @example-end() | ||
@@ -332,52 +413,59 @@ // @reference() | ||
// @example-args(Payment.ReceivePaymentDataThenPreAuthorize) | ||
var args = { | ||
cents: 128, | ||
currency: "USD", | ||
useExistingData: false, | ||
useExistingDataSecondsWindow: 5, | ||
cents: 128, | ||
currency: "USD", | ||
useExistingData: false, | ||
useExistingDataSecondsWindow: 5, | ||
}; | ||
// @example-args-end() | ||
// @example-request(Payment.ReceivePaymentDataThenPreAuthorize) | ||
dotdashpay.payment.receivePaymentDataThenPreAuthorize(args) | ||
.onStartedReceivingPaymentData(function(response) { | ||
var peripheralName = response.peripheralName; // peripheralName = "MagTekSureSwipe21040145" | ||
}) | ||
.onReceivedPaymentData(function(response) { | ||
var paymentDataId = response.paymentDataId; // paymentDataId = "pdid-iPqy9F82v5qexbtz" | ||
var token = response.token; // token = "aeac1bc8f0735e4283305652ab" | ||
var peripheralName = response.peripheralName; // peripheralName = "MagTekSureSwipe21040145" | ||
}) | ||
.onStartedPreAuthorizing(function(response) { | ||
var paymentDataId = response.paymentDataId; // paymentDataId = "pdid-iPqy9F82v5qexbtz" | ||
var cents = response.cents; // cents = 128 | ||
var currency = response.currency; // currency = "USD" | ||
var livemode = response.livemode; // livemode = false | ||
}) | ||
.onPreAuthorized(function(response) { | ||
var status = response.status; // status = "SUCCESS" | ||
var paymentDataId = response.paymentDataId; // paymentDataId = "pdid-iPqy9F82v5qexbtz" | ||
var preauthId = response.preauthId; // preauthId = "paut-Eo9YqkOTnmxt6EcL" | ||
var info = response.info; // info = "Human-readable description" | ||
var customerId = response.customerId; // customerId = "2DAuJMBrMyaC" | ||
var merchantAccountId = response.merchantAccountId; // merchantAccountId = "merchantAccountNumber" | ||
var cardType = response.cardType; // cardType = "Visa" | ||
var last4 = response.last4; // last4 = "0000" | ||
var commercial = response.commercial; // commercial = false | ||
var debit = response.debit; // debit = false | ||
var createdAt = response.createdAt; // createdAt = "915148799.75" | ||
var cents = response.cents; // cents = 128 | ||
var currency = response.currency; // currency = "USD" | ||
var livemode = response.livemode; // livemode = false | ||
var paymentType = response.paymentType; // paymentType = "CARD" | ||
}) | ||
.onError(function(errorData) { | ||
if (errorData.errorCode == "") { | ||
console.log("Error: " + errorData.errorMessage); | ||
} | ||
}); | ||
.onStartedReceivingPaymentData(function(response) { | ||
console.log("Received onStartedReceivingPaymentData response", JSON.stringify(response)); | ||
var peripheralName = response.peripheralName; // e.g. "MagTekSureSwipe21040145" | ||
}) | ||
.onReceivedPaymentData(function(response) { | ||
console.log("Received onReceivedPaymentData response", JSON.stringify(response)); | ||
var paymentDataId = response.paymentDataId; // e.g. "pdid-iPqy9F82v5qexbtz" | ||
var token = response.token; // "aeac1bc8f0735e4283305652ab" | ||
var peripheralName = response.peripheralName; // "MagTekSureSwipe21040145" | ||
}) | ||
.onStartedPreAuthorizing(function(response) { | ||
console.log("Received onStartedPreAuthorizing response", JSON.stringify(response)); | ||
var paymentDataId = response.paymentDataId; // e.g. "pdid-iPqy9F82v5qexbtz" | ||
var cents = response.cents; // 128 | ||
var currency = response.currency; // "USD" | ||
var livemode = response.livemode; // false | ||
}) | ||
.onPreAuthorized(function(response) { | ||
console.log("Received onPreAuthorized response", JSON.stringify(response)); | ||
var status = response.status; // e.g. "SUCCESS" | ||
var paymentDataId = response.paymentDataId; // "pdid-iPqy9F82v5qexbtz" | ||
var preauthId = response.preauthId; // "paut-Eo9YqkOTnmxt6EcL" | ||
var info = response.info; // "Human-readable description" | ||
var customerId = response.customerId; // "2DAuJMBrMyaC" | ||
var merchantAccountId = response.merchantAccountId; // "merchantAccountNumber" | ||
var cardType = response.cardType; // "Visa" | ||
var last4 = response.last4; // "0000" | ||
var commercial = response.commercial; // false | ||
var debit = response.debit; // false | ||
var createdAt = response.createdAt; // "915148799.75" | ||
var cents = response.cents; // 128 | ||
var currency = response.currency; // "USD" | ||
var livemode = response.livemode; // false | ||
var paymentType = response.paymentType; // "CARD" | ||
}) | ||
.onError(function(errorData) { | ||
console.log("Error", JSON.stringify(errorData)); | ||
}); | ||
// @example-request-end() | ||
/** | ||
@@ -388,4 +476,2 @@ Autogenerated example for API request: ReceivePaymentData | ||
// @example() | ||
// @example-end() | ||
@@ -395,27 +481,32 @@ // @reference() | ||
// @example-args(Hardware.ReceivePaymentData) | ||
var args = { | ||
useExistingData: false, | ||
useExistingDataSecondsWindow: 5, | ||
useExistingData: false, | ||
useExistingDataSecondsWindow: 5, | ||
}; | ||
// @example-args-end() | ||
// @example-request(Hardware.ReceivePaymentData) | ||
dotdashpay.hardware.receivePaymentData(args) | ||
.onStartedReceivingPaymentData(function(response) { | ||
var peripheralName = response.peripheralName; // peripheralName = "MagTekSureSwipe21040145" | ||
}) | ||
.onReceivedPaymentData(function(response) { | ||
var paymentDataId = response.paymentDataId; // paymentDataId = "pdid-iPqy9F82v5qexbtz" | ||
var token = response.token; // token = "aeac1bc8f0735e4283305652ab" | ||
var peripheralName = response.peripheralName; // peripheralName = "MagTekSureSwipe21040145" | ||
}) | ||
.onError(function(errorData) { | ||
if (errorData.errorCode == "") { | ||
console.log("Error: " + errorData.errorMessage); | ||
} | ||
}); | ||
.onStartedReceivingPaymentData(function(response) { | ||
console.log("Received onStartedReceivingPaymentData response", JSON.stringify(response)); | ||
var peripheralName = response.peripheralName; // e.g. "MagTekSureSwipe21040145" | ||
}) | ||
.onReceivedPaymentData(function(response) { | ||
console.log("Received onReceivedPaymentData response", JSON.stringify(response)); | ||
var paymentDataId = response.paymentDataId; // e.g. "pdid-iPqy9F82v5qexbtz" | ||
var token = response.token; // "aeac1bc8f0735e4283305652ab" | ||
var peripheralName = response.peripheralName; // "MagTekSureSwipe21040145" | ||
}) | ||
.onError(function(errorData) { | ||
console.log("Error", JSON.stringify(errorData)); | ||
}); | ||
// @example-request-end() | ||
/** | ||
@@ -426,4 +517,2 @@ Autogenerated example for API request: GetDatalinkStatus | ||
// @example() | ||
// @example-end() | ||
@@ -433,2 +522,3 @@ // @reference() | ||
// @example-args(Hardware.GetDatalinkStatus) | ||
@@ -438,16 +528,19 @@ var args = {}; | ||
// @example-request(Hardware.GetDatalinkStatus) | ||
dotdashpay.hardware.getDatalinkStatus(args) | ||
.onRetrievedDatalinkStatus(function(response) { | ||
var connected = response.connected; // connected = true | ||
var info = response.info; // info = "Human-readable description" | ||
}) | ||
.onError(function(errorData) { | ||
if (errorData.errorCode == "") { | ||
console.log("Error: " + errorData.errorMessage); | ||
} | ||
}); | ||
.onRetrievedDatalinkStatus(function(response) { | ||
console.log("Received onRetrievedDatalinkStatus response", JSON.stringify(response)); | ||
var connected = response.connected; // e.g. true | ||
var info = response.info; // "Human-readable description" | ||
}) | ||
.onError(function(errorData) { | ||
console.log("Error", JSON.stringify(errorData)); | ||
}); | ||
// @example-request-end() | ||
/** | ||
@@ -458,4 +551,2 @@ Autogenerated example for API request: GetInternetStatus | ||
// @example() | ||
// @example-end() | ||
@@ -465,2 +556,3 @@ // @reference() | ||
// @example-args(Hardware.GetInternetStatus) | ||
@@ -470,18 +562,21 @@ var args = {}; | ||
// @example-request(Hardware.GetInternetStatus) | ||
dotdashpay.hardware.getInternetStatus(args) | ||
.onRetrievedInternetStatus(function(response) { | ||
var connected = response.connected; // connected = true | ||
var info = response.info; // info = "Human-readable description" | ||
var connectedInterfaces = response.connectedInterfaces; // connectedInterfaces = [[u'wifi', u'...']] | ||
var ipAddresses = response.ipAddresses; // ipAddresses = [[u'192.168.1.128', u'...']] | ||
}) | ||
.onError(function(errorData) { | ||
if (errorData.errorCode == "") { | ||
console.log("Error: " + errorData.errorMessage); | ||
} | ||
}); | ||
.onRetrievedInternetStatus(function(response) { | ||
console.log("Received onRetrievedInternetStatus response", JSON.stringify(response)); | ||
var connected = response.connected; // e.g. true | ||
var info = response.info; // "Human-readable description" | ||
var connectedInterfaces = response.connectedInterfaces; // [[u'wifi', u'...']] | ||
var ipAddresses = response.ipAddresses; // [[u'192.168.1.128', u'...']] | ||
}) | ||
.onError(function(errorData) { | ||
console.log("Error", JSON.stringify(errorData)); | ||
}); | ||
// @example-request-end() | ||
/** | ||
@@ -492,4 +587,2 @@ Autogenerated example for API request: ConfigurePeripheral | ||
// @example() | ||
// @example-end() | ||
@@ -499,20 +592,25 @@ // @reference() | ||
// @example-args(Hardware.ConfigurePeripheral) | ||
var args = { | ||
peripheralName: "MagTekSureSwipe21040145", | ||
disable: false, | ||
peripheralName: "MagTekSureSwipe21040145", | ||
disable: false, | ||
}; | ||
// @example-args-end() | ||
// @example-request(Hardware.ConfigurePeripheral) | ||
dotdashpay.hardware.configurePeripheral(args) | ||
.onConfiguredPeripheral(function(response) {}) | ||
.onError(function(errorData) { | ||
if (errorData.errorCode == "") { | ||
console.log("Error: " + errorData.errorMessage); | ||
} | ||
}); | ||
.onConfiguredPeripheral(function(response) { | ||
console.log("Received onConfiguredPeripheral response", JSON.stringify(response)); | ||
}) | ||
.onError(function(errorData) { | ||
console.log("Error", JSON.stringify(errorData)); | ||
}); | ||
// @example-request-end() | ||
/** | ||
@@ -523,4 +621,2 @@ Autogenerated example for API request: ConfigureWifi | ||
// @example() | ||
// @example-end() | ||
@@ -530,28 +626,33 @@ // @reference() | ||
// @example-args(Hardware.ConfigureWifi) | ||
var args = { | ||
essid: "Network Name", | ||
password: "wifi_password", | ||
username: "wifi_username", | ||
x509cert: "308202123082017b02020dfa300d06092a864886f70d010105050030819b310b3009060355040613024a50310e300c06035504081305546f6b796f3110300e060355040713074368756f2d6b753111300f060355040a13084672616e6b34444431183016060355040b130f5765624365727420537570706f7274311830160603550403130f4672616e6b344444205765622043413123302106092a864886f70d0109011614737570706f7274406672616e6b3464642e636f6d301e170d3132303832323035323635345a170d3137303832313035323635345a304a310b3009060355040613024a50310e300c06035504080c05546f6b796f3111300f060355040a0c084672616e6b3444443118301606035504030c0f7777772e6578616d706c652e636f6d305c300d06092a864886f70d0101010500034b0030480241009bfc6690798442bbab13fd2b7bf8de1512e5f193e3068a7bb8b1e19e26bb9501bfe730ed648502dd1569a834b006ec3f353c1e1b2b8ffa8f001bdf07c6ac53070203010001300d06092a864886f70d01010505000381810014b64cbb817933e671a4da516fcb081d8d60ecbc18c7734759b1f22048bb61fafc4dad898dd121ebd5d8e5bad6a636fd745083b60fc71ddf7de52e817f45e09fe23e79eed73031c72072d9582e2afe125a3445a119087c89475f4a95be23214a5372da2a052f2ec970f65bfafddfb431b2c14a9c062543a1e6b41e7f869b16400a", | ||
staticIp: "192.168.1.128", | ||
staticSubnetMask: "255.255.255.0", | ||
staticGateway: "192.168.1.1", | ||
staticDns: "8.8.8.8", | ||
saveConfiguration: true, | ||
autoReconnect: true, | ||
essid: "Network Name", | ||
password: "wifi_password", | ||
username: "wifi_username", | ||
x509cert: "308202123082017b02020dfa300d06092a864886f70d010105050030819b310b3009060355040613024a50310e300c06035504081305546f6b796f3110300e060355040713074368756f2d6b753111300f060355040a13084672616e6b34444431183016060355040b130f5765624365727420537570706f7274311830160603550403130f4672616e6b344444205765622043413123302106092a864886f70d0109011614737570706f7274406672616e6b3464642e636f6d301e170d3132303832323035323635345a170d3137303832313035323635345a304a310b3009060355040613024a50310e300c06035504080c05546f6b796f3111300f060355040a0c084672616e6b3444443118301606035504030c0f7777772e6578616d706c652e636f6d305c300d06092a864886f70d0101010500034b0030480241009bfc6690798442bbab13fd2b7bf8de1512e5f193e3068a7bb8b1e19e26bb9501bfe730ed648502dd1569a834b006ec3f353c1e1b2b8ffa8f001bdf07c6ac53070203010001300d06092a864886f70d01010505000381810014b64cbb817933e671a4da516fcb081d8d60ecbc18c7734759b1f22048bb61fafc4dad898dd121ebd5d8e5bad6a636fd745083b60fc71ddf7de52e817f45e09fe23e79eed73031c72072d9582e2afe125a3445a119087c89475f4a95be23214a5372da2a052f2ec970f65bfafddfb431b2c14a9c062543a1e6b41e7f869b16400a", | ||
staticIp: "192.168.1.128", | ||
staticSubnetMask: "255.255.255.0", | ||
staticGateway: "192.168.1.1", | ||
staticDns: "8.8.8.8", | ||
saveConfiguration: true, | ||
autoReconnect: true, | ||
}; | ||
// @example-args-end() | ||
// @example-request(Hardware.ConfigureWifi) | ||
dotdashpay.hardware.configureWifi(args) | ||
.onConfiguredWifi(function(response) {}) | ||
.onError(function(errorData) { | ||
if (errorData.errorCode == "") { | ||
console.log("Error: " + errorData.errorMessage); | ||
} | ||
}); | ||
.onConfiguredWifi(function(response) { | ||
console.log("Received onConfiguredWifi response", JSON.stringify(response)); | ||
}) | ||
.onError(function(errorData) { | ||
console.log("Error", JSON.stringify(errorData)); | ||
}); | ||
// @example-request-end() | ||
/** | ||
@@ -562,4 +663,2 @@ Autogenerated example for API request: ConfigureEthernet | ||
// @example() | ||
// @example-end() | ||
@@ -569,24 +668,29 @@ // @reference() | ||
// @example-args(Hardware.ConfigureEthernet) | ||
var args = { | ||
staticIp: "192.168.1.128", | ||
staticSubnetMask: "255.255.255.0", | ||
staticGateway: "192.168.1.1", | ||
staticDns: "8.8.8.8", | ||
saveConfiguration: true, | ||
autoReconnect: true, | ||
staticIp: "192.168.1.128", | ||
staticSubnetMask: "255.255.255.0", | ||
staticGateway: "192.168.1.1", | ||
staticDns: "8.8.8.8", | ||
saveConfiguration: true, | ||
autoReconnect: true, | ||
}; | ||
// @example-args-end() | ||
// @example-request(Hardware.ConfigureEthernet) | ||
dotdashpay.hardware.configureEthernet(args) | ||
.onConfiguredEthernet(function(response) {}) | ||
.onError(function(errorData) { | ||
if (errorData.errorCode == "") { | ||
console.log("Error: " + errorData.errorMessage); | ||
} | ||
}); | ||
.onConfiguredEthernet(function(response) { | ||
console.log("Received onConfiguredEthernet response", JSON.stringify(response)); | ||
}) | ||
.onError(function(errorData) { | ||
console.log("Error", JSON.stringify(errorData)); | ||
}); | ||
// @example-request-end() | ||
/** | ||
@@ -597,4 +701,2 @@ Autogenerated example for API request: GetConnectedPeripherals | ||
// @example() | ||
// @example-end() | ||
@@ -604,2 +706,3 @@ // @reference() | ||
// @example-args(Hardware.GetConnectedPeripherals) | ||
@@ -609,16 +712,19 @@ var args = {}; | ||
// @example-request(Hardware.GetConnectedPeripherals) | ||
dotdashpay.hardware.getConnectedPeripherals(args) | ||
.onRetrievedConnectedPeripherals(function(response) { | ||
var attachedValidPeriphs = response.attachedValidPeriphs; // attachedValidPeriphs = [[u'MagTekSureSwipe21040145', u'...']] | ||
var attachedErrorPeriphs = response.attachedErrorPeriphs; // attachedErrorPeriphs = [[]] | ||
}) | ||
.onError(function(errorData) { | ||
if (errorData.errorCode == "") { | ||
console.log("Error: " + errorData.errorMessage); | ||
} | ||
}); | ||
.onRetrievedConnectedPeripherals(function(response) { | ||
console.log("Received onRetrievedConnectedPeripherals response", JSON.stringify(response)); | ||
var attachedValidPeriphs = response.attachedValidPeriphs; // e.g. [[u'MagTekSureSwipe21040145', u'...']] | ||
var attachedErrorPeriphs = response.attachedErrorPeriphs; // [[]] | ||
}) | ||
.onError(function(errorData) { | ||
console.log("Error", JSON.stringify(errorData)); | ||
}); | ||
// @example-request-end() | ||
/** | ||
@@ -629,4 +735,2 @@ Autogenerated example for API request: GetCustomerId | ||
// @example() | ||
// @example-end() | ||
@@ -636,21 +740,25 @@ // @reference() | ||
// @example-args(Information.GetCustomerId) | ||
var args = { | ||
token: "aeac1bc8f0735e4283305652ab", | ||
token: "aeac1bc8f0735e4283305652ab", | ||
}; | ||
// @example-args-end() | ||
// @example-request(Information.GetCustomerId) | ||
dotdashpay.information.getCustomerId(args) | ||
.onRetrievedCustomerId(function(response) { | ||
var customerId = response.customerId; // customerId = "2DAuJMBrMyaC" | ||
}) | ||
.onError(function(errorData) { | ||
if (errorData.errorCode == "") { | ||
console.log("Error: " + errorData.errorMessage); | ||
} | ||
}); | ||
.onRetrievedCustomerId(function(response) { | ||
console.log("Received onRetrievedCustomerId response", JSON.stringify(response)); | ||
var customerId = response.customerId; // e.g. "2DAuJMBrMyaC" | ||
}) | ||
.onError(function(errorData) { | ||
console.log("Error", JSON.stringify(errorData)); | ||
}); | ||
// @example-request-end() | ||
/** | ||
@@ -661,4 +769,2 @@ Autogenerated example for API request: ReceiveLogs | ||
// @example() | ||
// @example-end() | ||
@@ -668,20 +774,19 @@ // @reference() | ||
// @example-args(Information.ReceiveLogs) | ||
var args = { | ||
level: "DEBUG", | ||
level: "DEBUG", | ||
}; | ||
// @example-args-end() | ||
// @example-request(Information.ReceiveLogs) | ||
dotdashpay.information.receiveLogs(args) | ||
.onReceivedLogs(function(response) { | ||
var logMessage = response.logMessage; // logMessage = "The roof is on fire (you may need some water)." | ||
var level = response.level; // level = "DEBUG" | ||
}) | ||
.onError(function(errorData) { | ||
if (errorData.errorCode == "") { | ||
console.log("Error: " + errorData.errorMessage); | ||
} | ||
}); | ||
.onReceivedLogs(function(response) { | ||
console.log("Received onReceivedLogs response", JSON.stringify(response)); | ||
var logMessage = response.logMessage; // e.g. "The roof is on fire (you may need some water)." | ||
var level = response.level; // "DEBUG" | ||
}) | ||
.onError(function(errorData) { | ||
console.log("Error", JSON.stringify(errorData)); | ||
}); | ||
// @example-request-end() |
@@ -6,34 +6,29 @@ /** | ||
var dotdashpay = require("dotdashpay"); | ||
dotdashpay.setup({ | ||
simulate: true | ||
}); | ||
var args = { | ||
settleId: "txn-NG9jR86SC3hjzQHA8h5X3pwz", | ||
settleId: "txn-NG9jR86SC3hjzQHA8h5X3pwz", | ||
}; | ||
dotdashpay.payment.refund(args) | ||
.onRefunded(function(response) { | ||
var status = response.status; // status = "SUCCESS" | ||
var refundId = response.refundId; // refundId = "rfnd-PFuJxu7hpWKcMsgs" | ||
var info = response.info; // info = "Human-readable description" | ||
var customerId = response.customerId; // customerId = "2DAuJMBrMyaC" | ||
var merchantAccountId = response.merchantAccountId; // merchantAccountId = "merchantAccountNumber" | ||
var cardType = response.cardType; // cardType = "Visa" | ||
var last4 = response.last4; // last4 = "0000" | ||
var commercial = response.commercial; // commercial = false | ||
var debit = response.debit; // debit = false | ||
var createdAt = response.createdAt; // createdAt = "915148799.75" | ||
var cents = response.cents; // cents = 128 | ||
var currency = response.currency; // currency = "USD" | ||
var livemode = response.livemode; // livemode = false | ||
var paymentType = response.paymentType; // paymentType = "CARD" | ||
}) | ||
.onError(function(errorData) { | ||
if (errorData.errorCode == "") { | ||
console.log("Error: " + errorData.errorMessage); | ||
} | ||
}); | ||
.onRefunded(function(response) { | ||
console.log("Received onRefunded response", JSON.stringify(response)); | ||
var status = response.status; // e.g. "SUCCESS" | ||
var refundId = response.refundId; // "rfnd-PFuJxu7hpWKcMsgs" | ||
var info = response.info; // "Human-readable description" | ||
var customerId = response.customerId; // "2DAuJMBrMyaC" | ||
var merchantAccountId = response.merchantAccountId; // "merchantAccountNumber" | ||
var cardType = response.cardType; // "Visa" | ||
var last4 = response.last4; // "0000" | ||
var commercial = response.commercial; // false | ||
var debit = response.debit; // false | ||
var createdAt = response.createdAt; // "915148799.75" | ||
var cents = response.cents; // 128 | ||
var currency = response.currency; // "USD" | ||
var livemode = response.livemode; // false | ||
var paymentType = response.paymentType; // "CARD" | ||
}) | ||
.onError(function(errorData) { | ||
console.log("Error", JSON.stringify(errorData)); | ||
}); |
@@ -6,46 +6,42 @@ /** | ||
var dotdashpay = require("dotdashpay"); | ||
dotdashpay.setup({ | ||
simulate: true | ||
}); | ||
var args = { | ||
paymentDataId: "pdid-iPqy9F82v5qexbtz", | ||
preauthId: "paut-Eo9YqkOTnmxt6EcL", | ||
cents: 128, | ||
currency: "USD", | ||
paymentDataId: "pdid-iPqy9F82v5qexbtz", | ||
preauthId: "paut-Eo9YqkOTnmxt6EcL", | ||
cents: 128, | ||
currency: "USD", | ||
}; | ||
dotdashpay.payment.settle(args) | ||
.onStartedSettling(function(response) { | ||
var paymentDataId = response.paymentDataId; // paymentDataId = "pdid-iPqy9F82v5qexbtz" | ||
var preauthId = response.preauthId; // preauthId = "paut-Eo9YqkOTnmxt6EcL" | ||
var cents = response.cents; // cents = 128 | ||
var currency = response.currency; // currency = "USD" | ||
var livemode = response.livemode; // livemode = false | ||
}) | ||
.onSettled(function(response) { | ||
var status = response.status; // status = "SUCCESS" | ||
var paymentDataId = response.paymentDataId; // paymentDataId = "pdid-iPqy9F82v5qexbtz" | ||
var preauthId = response.preauthId; // preauthId = "paut-Eo9YqkOTnmxt6EcL" | ||
var settleId = response.settleId; // settleId = "txn-NG9jR86SC3hjzQHA8h5X3pwz" | ||
var info = response.info; // info = "Human-readable description" | ||
var customerId = response.customerId; // customerId = "2DAuJMBrMyaC" | ||
var merchantAccountId = response.merchantAccountId; // merchantAccountId = "merchantAccountNumber" | ||
var cardType = response.cardType; // cardType = "Visa" | ||
var last4 = response.last4; // last4 = "0000" | ||
var commercial = response.commercial; // commercial = false | ||
var debit = response.debit; // debit = false | ||
var createdAt = response.createdAt; // createdAt = "915148799.75" | ||
var cents = response.cents; // cents = 128 | ||
var currency = response.currency; // currency = "USD" | ||
var livemode = response.livemode; // livemode = false | ||
var paymentType = response.paymentType; // paymentType = "CARD" | ||
}) | ||
.onError(function(errorData) { | ||
if (errorData.errorCode == "") { | ||
console.log("Error: " + errorData.errorMessage); | ||
} | ||
}); | ||
.onStartedSettling(function(response) { | ||
console.log("Received onStartedSettling response", JSON.stringify(response)); | ||
var paymentDataId = response.paymentDataId; // e.g. "pdid-iPqy9F82v5qexbtz" | ||
var preauthId = response.preauthId; // "paut-Eo9YqkOTnmxt6EcL" | ||
var cents = response.cents; // 128 | ||
var currency = response.currency; // "USD" | ||
var livemode = response.livemode; // false | ||
}) | ||
.onSettled(function(response) { | ||
console.log("Received onSettled response", JSON.stringify(response)); | ||
var status = response.status; // e.g. "SUCCESS" | ||
var paymentDataId = response.paymentDataId; // "pdid-iPqy9F82v5qexbtz" | ||
var preauthId = response.preauthId; // "paut-Eo9YqkOTnmxt6EcL" | ||
var settleId = response.settleId; // "txn-NG9jR86SC3hjzQHA8h5X3pwz" | ||
var info = response.info; // "Human-readable description" | ||
var customerId = response.customerId; // "2DAuJMBrMyaC" | ||
var merchantAccountId = response.merchantAccountId; // "merchantAccountNumber" | ||
var cardType = response.cardType; // "Visa" | ||
var last4 = response.last4; // "0000" | ||
var commercial = response.commercial; // false | ||
var debit = response.debit; // false | ||
var createdAt = response.createdAt; // "915148799.75" | ||
var cents = response.cents; // 128 | ||
var currency = response.currency; // "USD" | ||
var livemode = response.livemode; // false | ||
var paymentType = response.paymentType; // "CARD" | ||
}) | ||
.onError(function(errorData) { | ||
console.log("Error", JSON.stringify(errorData)); | ||
}); |
@@ -6,34 +6,29 @@ /** | ||
var dotdashpay = require("dotdashpay"); | ||
dotdashpay.setup({ | ||
simulate: true | ||
}); | ||
var args = { | ||
preauthId: "paut-Eo9YqkOTnmxt6EcL", | ||
preauthId: "paut-Eo9YqkOTnmxt6EcL", | ||
}; | ||
dotdashpay.payment.voidPreAuthorize(args) | ||
.onVoidedPreAuthorize(function(response) { | ||
var status = response.status; // status = "SUCCESS" | ||
var voidId = response.voidId; // voidId = "void-QTKL0uLZuO1gFaFm" | ||
var info = response.info; // info = "Human-readable description" | ||
var customerId = response.customerId; // customerId = "2DAuJMBrMyaC" | ||
var merchantAccountId = response.merchantAccountId; // merchantAccountId = "merchantAccountNumber" | ||
var cardType = response.cardType; // cardType = "Visa" | ||
var last4 = response.last4; // last4 = "0000" | ||
var commercial = response.commercial; // commercial = false | ||
var debit = response.debit; // debit = false | ||
var createdAt = response.createdAt; // createdAt = "915148799.75" | ||
var cents = response.cents; // cents = 128 | ||
var currency = response.currency; // currency = "USD" | ||
var livemode = response.livemode; // livemode = false | ||
var paymentType = response.paymentType; // paymentType = "CARD" | ||
}) | ||
.onError(function(errorData) { | ||
if (errorData.errorCode == "") { | ||
console.log("Error: " + errorData.errorMessage); | ||
} | ||
}); | ||
.onVoidedPreAuthorize(function(response) { | ||
console.log("Received onVoidedPreAuthorize response", JSON.stringify(response)); | ||
var status = response.status; // e.g. "SUCCESS" | ||
var voidId = response.voidId; // "void-QTKL0uLZuO1gFaFm" | ||
var info = response.info; // "Human-readable description" | ||
var customerId = response.customerId; // "2DAuJMBrMyaC" | ||
var merchantAccountId = response.merchantAccountId; // "merchantAccountNumber" | ||
var cardType = response.cardType; // "Visa" | ||
var last4 = response.last4; // "0000" | ||
var commercial = response.commercial; // false | ||
var debit = response.debit; // false | ||
var createdAt = response.createdAt; // "915148799.75" | ||
var cents = response.cents; // 128 | ||
var currency = response.currency; // "USD" | ||
var livemode = response.livemode; // false | ||
var paymentType = response.paymentType; // "CARD" | ||
}) | ||
.onError(function(errorData) { | ||
console.log("Error", JSON.stringify(errorData)); | ||
}); |
@@ -10,41 +10,41 @@ /** | ||
module.exports.receivePaymentData = function receivePaymentData(receivePaymentDataArgs) { | ||
var request = new ReceivePaymentDataRequest(receivePaymentDataArgs); | ||
server.sendRequest(request); | ||
return request; | ||
var request = new ReceivePaymentDataRequest(receivePaymentDataArgs); | ||
server.sendRequest(request); | ||
return request; | ||
}; | ||
module.exports.getDatalinkStatus = function getDatalinkStatus(getDatalinkStatusArgs) { | ||
var request = new GetDatalinkStatusRequest(getDatalinkStatusArgs); | ||
server.sendRequest(request); | ||
return request; | ||
var request = new GetDatalinkStatusRequest(getDatalinkStatusArgs); | ||
server.sendRequest(request); | ||
return request; | ||
}; | ||
module.exports.getInternetStatus = function getInternetStatus(getInternetStatusArgs) { | ||
var request = new GetInternetStatusRequest(getInternetStatusArgs); | ||
server.sendRequest(request); | ||
return request; | ||
var request = new GetInternetStatusRequest(getInternetStatusArgs); | ||
server.sendRequest(request); | ||
return request; | ||
}; | ||
module.exports.configurePeripheral = function configurePeripheral(configurePeripheralArgs) { | ||
var request = new ConfigurePeripheralRequest(configurePeripheralArgs); | ||
server.sendRequest(request); | ||
return request; | ||
var request = new ConfigurePeripheralRequest(configurePeripheralArgs); | ||
server.sendRequest(request); | ||
return request; | ||
}; | ||
module.exports.configureWifi = function configureWifi(configureWifiArgs) { | ||
var request = new ConfigureWifiRequest(configureWifiArgs); | ||
server.sendRequest(request); | ||
return request; | ||
var request = new ConfigureWifiRequest(configureWifiArgs); | ||
server.sendRequest(request); | ||
return request; | ||
}; | ||
module.exports.configureEthernet = function configureEthernet(configureEthernetArgs) { | ||
var request = new ConfigureEthernetRequest(configureEthernetArgs); | ||
server.sendRequest(request); | ||
return request; | ||
var request = new ConfigureEthernetRequest(configureEthernetArgs); | ||
server.sendRequest(request); | ||
return request; | ||
}; | ||
module.exports.getConnectedPeripherals = function getConnectedPeripherals(getConnectedPeripheralsArgs) { | ||
var request = new GetConnectedPeripheralsRequest(getConnectedPeripheralsArgs); | ||
server.sendRequest(request); | ||
return request; | ||
var request = new GetConnectedPeripheralsRequest(getConnectedPeripheralsArgs); | ||
server.sendRequest(request); | ||
return request; | ||
}; | ||
@@ -68,24 +68,24 @@ | ||
var ReceivePaymentDataRequest = function ReceivePaymentDataRequest(requestDataArgs) { | ||
var thisReq = this; | ||
var thisReq = this; | ||
// Setup the request response signals to handle events | ||
thisReq._signals = {}; | ||
thisReq._signals.StartedReceivingPaymentData = new Signal(); | ||
thisReq._signals.ReceivedPaymentData = new Signal(); | ||
thisReq._signals.ErrorResponse = new Signal(); | ||
// Setup the request response signals to handle events | ||
thisReq._signals = {}; | ||
thisReq._signals.StartedReceivingPaymentData = new Signal(); | ||
thisReq._signals.ReceivedPaymentData = new Signal(); | ||
thisReq._signals.ErrorResponse = new Signal(); | ||
thisReq._protobuf = protobufTools.getProtobuf("ReceivePaymentDataArgs"); | ||
thisReq._protobuf.META = thisReq._protobuf.META || {}; | ||
var thisProtobuf = thisReq._protobuf; | ||
if (requestDataArgs) { | ||
_.each(requestDataArgs, function(val, key) { | ||
thisProtobuf[key] = val; | ||
}); | ||
} | ||
thisReq._protobuf = protobufTools.getProtobuf("ReceivePaymentDataArgs"); | ||
thisReq._protobuf.META = thisReq._protobuf.META || {}; | ||
var thisProtobuf = thisReq._protobuf; | ||
if (requestDataArgs) { | ||
_.each(requestDataArgs, function(val, key) { | ||
thisProtobuf[key] = val; | ||
}); | ||
} | ||
// Set helper data for the protobuf | ||
thisProtobuf._protoName = "ReceivePaymentDataArgs"; | ||
thisProtobuf._rpcName = "ReceivePaymentData"; | ||
// Set helper data for the protobuf | ||
thisProtobuf._protoName = "ReceivePaymentDataArgs"; | ||
thisProtobuf._rpcName = "ReceivePaymentData"; | ||
return thisReq; | ||
return thisReq; | ||
}; | ||
@@ -97,8 +97,8 @@ | ||
ReceivePaymentDataRequest.prototype.onStartedReceivingPaymentData = | ||
function onStartedReceivingPaymentData(callbackFunction) { | ||
var thisReq = this; | ||
// TODO(cjrd) should the default be a permanent cb or "once" cb? | ||
thisReq._signals.StartedReceivingPaymentData.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
function onStartedReceivingPaymentData(callbackFunction) { | ||
var thisReq = this; | ||
// TODO(cjrd) should the default be a permanent cb or "once" cb? | ||
thisReq._signals.StartedReceivingPaymentData.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
@@ -109,8 +109,8 @@ /** | ||
ReceivePaymentDataRequest.prototype.onReceivedPaymentData = | ||
function onReceivedPaymentData(callbackFunction) { | ||
var thisReq = this; | ||
// TODO(cjrd) should the default be a permanent cb or "once" cb? | ||
thisReq._signals.ReceivedPaymentData.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
function onReceivedPaymentData(callbackFunction) { | ||
var thisReq = this; | ||
// TODO(cjrd) should the default be a permanent cb or "once" cb? | ||
thisReq._signals.ReceivedPaymentData.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
@@ -121,7 +121,7 @@ /** | ||
ReceivePaymentDataRequest.prototype.onError = | ||
function onError(callbackFunction) { | ||
var thisReq = this; | ||
thisReq._signals.ErrorResponse.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
function onError(callbackFunction) { | ||
var thisReq = this; | ||
thisReq._signals.ErrorResponse.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
@@ -134,23 +134,23 @@ /** | ||
var GetDatalinkStatusRequest = function GetDatalinkStatusRequest(requestDataArgs) { | ||
var thisReq = this; | ||
var thisReq = this; | ||
// Setup the request response signals to handle events | ||
thisReq._signals = {}; | ||
thisReq._signals.RetrievedDatalinkStatus = new Signal(); | ||
thisReq._signals.ErrorResponse = new Signal(); | ||
// Setup the request response signals to handle events | ||
thisReq._signals = {}; | ||
thisReq._signals.RetrievedDatalinkStatus = new Signal(); | ||
thisReq._signals.ErrorResponse = new Signal(); | ||
thisReq._protobuf = protobufTools.getProtobuf("GetDatalinkStatusArgs"); | ||
thisReq._protobuf.META = thisReq._protobuf.META || {}; | ||
var thisProtobuf = thisReq._protobuf; | ||
if (requestDataArgs) { | ||
_.each(requestDataArgs, function(val, key) { | ||
thisProtobuf[key] = val; | ||
}); | ||
} | ||
thisReq._protobuf = protobufTools.getProtobuf("GetDatalinkStatusArgs"); | ||
thisReq._protobuf.META = thisReq._protobuf.META || {}; | ||
var thisProtobuf = thisReq._protobuf; | ||
if (requestDataArgs) { | ||
_.each(requestDataArgs, function(val, key) { | ||
thisProtobuf[key] = val; | ||
}); | ||
} | ||
// Set helper data for the protobuf | ||
thisProtobuf._protoName = "GetDatalinkStatusArgs"; | ||
thisProtobuf._rpcName = "GetDatalinkStatus"; | ||
// Set helper data for the protobuf | ||
thisProtobuf._protoName = "GetDatalinkStatusArgs"; | ||
thisProtobuf._rpcName = "GetDatalinkStatus"; | ||
return thisReq; | ||
return thisReq; | ||
}; | ||
@@ -162,8 +162,8 @@ | ||
GetDatalinkStatusRequest.prototype.onRetrievedDatalinkStatus = | ||
function onRetrievedDatalinkStatus(callbackFunction) { | ||
var thisReq = this; | ||
// TODO(cjrd) should the default be a permanent cb or "once" cb? | ||
thisReq._signals.RetrievedDatalinkStatus.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
function onRetrievedDatalinkStatus(callbackFunction) { | ||
var thisReq = this; | ||
// TODO(cjrd) should the default be a permanent cb or "once" cb? | ||
thisReq._signals.RetrievedDatalinkStatus.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
@@ -174,7 +174,7 @@ /** | ||
GetDatalinkStatusRequest.prototype.onError = | ||
function onError(callbackFunction) { | ||
var thisReq = this; | ||
thisReq._signals.ErrorResponse.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
function onError(callbackFunction) { | ||
var thisReq = this; | ||
thisReq._signals.ErrorResponse.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
@@ -187,23 +187,23 @@ /** | ||
var GetInternetStatusRequest = function GetInternetStatusRequest(requestDataArgs) { | ||
var thisReq = this; | ||
var thisReq = this; | ||
// Setup the request response signals to handle events | ||
thisReq._signals = {}; | ||
thisReq._signals.RetrievedInternetStatus = new Signal(); | ||
thisReq._signals.ErrorResponse = new Signal(); | ||
// Setup the request response signals to handle events | ||
thisReq._signals = {}; | ||
thisReq._signals.RetrievedInternetStatus = new Signal(); | ||
thisReq._signals.ErrorResponse = new Signal(); | ||
thisReq._protobuf = protobufTools.getProtobuf("GetInternetStatusArgs"); | ||
thisReq._protobuf.META = thisReq._protobuf.META || {}; | ||
var thisProtobuf = thisReq._protobuf; | ||
if (requestDataArgs) { | ||
_.each(requestDataArgs, function(val, key) { | ||
thisProtobuf[key] = val; | ||
}); | ||
} | ||
thisReq._protobuf = protobufTools.getProtobuf("GetInternetStatusArgs"); | ||
thisReq._protobuf.META = thisReq._protobuf.META || {}; | ||
var thisProtobuf = thisReq._protobuf; | ||
if (requestDataArgs) { | ||
_.each(requestDataArgs, function(val, key) { | ||
thisProtobuf[key] = val; | ||
}); | ||
} | ||
// Set helper data for the protobuf | ||
thisProtobuf._protoName = "GetInternetStatusArgs"; | ||
thisProtobuf._rpcName = "GetInternetStatus"; | ||
// Set helper data for the protobuf | ||
thisProtobuf._protoName = "GetInternetStatusArgs"; | ||
thisProtobuf._rpcName = "GetInternetStatus"; | ||
return thisReq; | ||
return thisReq; | ||
}; | ||
@@ -215,8 +215,8 @@ | ||
GetInternetStatusRequest.prototype.onRetrievedInternetStatus = | ||
function onRetrievedInternetStatus(callbackFunction) { | ||
var thisReq = this; | ||
// TODO(cjrd) should the default be a permanent cb or "once" cb? | ||
thisReq._signals.RetrievedInternetStatus.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
function onRetrievedInternetStatus(callbackFunction) { | ||
var thisReq = this; | ||
// TODO(cjrd) should the default be a permanent cb or "once" cb? | ||
thisReq._signals.RetrievedInternetStatus.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
@@ -227,7 +227,7 @@ /** | ||
GetInternetStatusRequest.prototype.onError = | ||
function onError(callbackFunction) { | ||
var thisReq = this; | ||
thisReq._signals.ErrorResponse.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
function onError(callbackFunction) { | ||
var thisReq = this; | ||
thisReq._signals.ErrorResponse.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
@@ -240,23 +240,23 @@ /** | ||
var ConfigurePeripheralRequest = function ConfigurePeripheralRequest(requestDataArgs) { | ||
var thisReq = this; | ||
var thisReq = this; | ||
// Setup the request response signals to handle events | ||
thisReq._signals = {}; | ||
thisReq._signals.ConfiguredPeripheral = new Signal(); | ||
thisReq._signals.ErrorResponse = new Signal(); | ||
// Setup the request response signals to handle events | ||
thisReq._signals = {}; | ||
thisReq._signals.ConfiguredPeripheral = new Signal(); | ||
thisReq._signals.ErrorResponse = new Signal(); | ||
thisReq._protobuf = protobufTools.getProtobuf("ConfigurePeripheralArgs"); | ||
thisReq._protobuf.META = thisReq._protobuf.META || {}; | ||
var thisProtobuf = thisReq._protobuf; | ||
if (requestDataArgs) { | ||
_.each(requestDataArgs, function(val, key) { | ||
thisProtobuf[key] = val; | ||
}); | ||
} | ||
thisReq._protobuf = protobufTools.getProtobuf("ConfigurePeripheralArgs"); | ||
thisReq._protobuf.META = thisReq._protobuf.META || {}; | ||
var thisProtobuf = thisReq._protobuf; | ||
if (requestDataArgs) { | ||
_.each(requestDataArgs, function(val, key) { | ||
thisProtobuf[key] = val; | ||
}); | ||
} | ||
// Set helper data for the protobuf | ||
thisProtobuf._protoName = "ConfigurePeripheralArgs"; | ||
thisProtobuf._rpcName = "ConfigurePeripheral"; | ||
// Set helper data for the protobuf | ||
thisProtobuf._protoName = "ConfigurePeripheralArgs"; | ||
thisProtobuf._rpcName = "ConfigurePeripheral"; | ||
return thisReq; | ||
return thisReq; | ||
}; | ||
@@ -268,8 +268,8 @@ | ||
ConfigurePeripheralRequest.prototype.onConfiguredPeripheral = | ||
function onConfiguredPeripheral(callbackFunction) { | ||
var thisReq = this; | ||
// TODO(cjrd) should the default be a permanent cb or "once" cb? | ||
thisReq._signals.ConfiguredPeripheral.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
function onConfiguredPeripheral(callbackFunction) { | ||
var thisReq = this; | ||
// TODO(cjrd) should the default be a permanent cb or "once" cb? | ||
thisReq._signals.ConfiguredPeripheral.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
@@ -280,7 +280,7 @@ /** | ||
ConfigurePeripheralRequest.prototype.onError = | ||
function onError(callbackFunction) { | ||
var thisReq = this; | ||
thisReq._signals.ErrorResponse.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
function onError(callbackFunction) { | ||
var thisReq = this; | ||
thisReq._signals.ErrorResponse.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
@@ -293,23 +293,23 @@ /** | ||
var ConfigureWifiRequest = function ConfigureWifiRequest(requestDataArgs) { | ||
var thisReq = this; | ||
var thisReq = this; | ||
// Setup the request response signals to handle events | ||
thisReq._signals = {}; | ||
thisReq._signals.ConfiguredWifi = new Signal(); | ||
thisReq._signals.ErrorResponse = new Signal(); | ||
// Setup the request response signals to handle events | ||
thisReq._signals = {}; | ||
thisReq._signals.ConfiguredWifi = new Signal(); | ||
thisReq._signals.ErrorResponse = new Signal(); | ||
thisReq._protobuf = protobufTools.getProtobuf("ConfigureWifiArgs"); | ||
thisReq._protobuf.META = thisReq._protobuf.META || {}; | ||
var thisProtobuf = thisReq._protobuf; | ||
if (requestDataArgs) { | ||
_.each(requestDataArgs, function(val, key) { | ||
thisProtobuf[key] = val; | ||
}); | ||
} | ||
thisReq._protobuf = protobufTools.getProtobuf("ConfigureWifiArgs"); | ||
thisReq._protobuf.META = thisReq._protobuf.META || {}; | ||
var thisProtobuf = thisReq._protobuf; | ||
if (requestDataArgs) { | ||
_.each(requestDataArgs, function(val, key) { | ||
thisProtobuf[key] = val; | ||
}); | ||
} | ||
// Set helper data for the protobuf | ||
thisProtobuf._protoName = "ConfigureWifiArgs"; | ||
thisProtobuf._rpcName = "ConfigureWifi"; | ||
// Set helper data for the protobuf | ||
thisProtobuf._protoName = "ConfigureWifiArgs"; | ||
thisProtobuf._rpcName = "ConfigureWifi"; | ||
return thisReq; | ||
return thisReq; | ||
}; | ||
@@ -321,8 +321,8 @@ | ||
ConfigureWifiRequest.prototype.onConfiguredWifi = | ||
function onConfiguredWifi(callbackFunction) { | ||
var thisReq = this; | ||
// TODO(cjrd) should the default be a permanent cb or "once" cb? | ||
thisReq._signals.ConfiguredWifi.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
function onConfiguredWifi(callbackFunction) { | ||
var thisReq = this; | ||
// TODO(cjrd) should the default be a permanent cb or "once" cb? | ||
thisReq._signals.ConfiguredWifi.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
@@ -333,7 +333,7 @@ /** | ||
ConfigureWifiRequest.prototype.onError = | ||
function onError(callbackFunction) { | ||
var thisReq = this; | ||
thisReq._signals.ErrorResponse.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
function onError(callbackFunction) { | ||
var thisReq = this; | ||
thisReq._signals.ErrorResponse.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
@@ -346,23 +346,23 @@ /** | ||
var ConfigureEthernetRequest = function ConfigureEthernetRequest(requestDataArgs) { | ||
var thisReq = this; | ||
var thisReq = this; | ||
// Setup the request response signals to handle events | ||
thisReq._signals = {}; | ||
thisReq._signals.ConfiguredEthernet = new Signal(); | ||
thisReq._signals.ErrorResponse = new Signal(); | ||
// Setup the request response signals to handle events | ||
thisReq._signals = {}; | ||
thisReq._signals.ConfiguredEthernet = new Signal(); | ||
thisReq._signals.ErrorResponse = new Signal(); | ||
thisReq._protobuf = protobufTools.getProtobuf("ConfigureEthernetArgs"); | ||
thisReq._protobuf.META = thisReq._protobuf.META || {}; | ||
var thisProtobuf = thisReq._protobuf; | ||
if (requestDataArgs) { | ||
_.each(requestDataArgs, function(val, key) { | ||
thisProtobuf[key] = val; | ||
}); | ||
} | ||
thisReq._protobuf = protobufTools.getProtobuf("ConfigureEthernetArgs"); | ||
thisReq._protobuf.META = thisReq._protobuf.META || {}; | ||
var thisProtobuf = thisReq._protobuf; | ||
if (requestDataArgs) { | ||
_.each(requestDataArgs, function(val, key) { | ||
thisProtobuf[key] = val; | ||
}); | ||
} | ||
// Set helper data for the protobuf | ||
thisProtobuf._protoName = "ConfigureEthernetArgs"; | ||
thisProtobuf._rpcName = "ConfigureEthernet"; | ||
// Set helper data for the protobuf | ||
thisProtobuf._protoName = "ConfigureEthernetArgs"; | ||
thisProtobuf._rpcName = "ConfigureEthernet"; | ||
return thisReq; | ||
return thisReq; | ||
}; | ||
@@ -374,8 +374,8 @@ | ||
ConfigureEthernetRequest.prototype.onConfiguredEthernet = | ||
function onConfiguredEthernet(callbackFunction) { | ||
var thisReq = this; | ||
// TODO(cjrd) should the default be a permanent cb or "once" cb? | ||
thisReq._signals.ConfiguredEthernet.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
function onConfiguredEthernet(callbackFunction) { | ||
var thisReq = this; | ||
// TODO(cjrd) should the default be a permanent cb or "once" cb? | ||
thisReq._signals.ConfiguredEthernet.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
@@ -386,7 +386,7 @@ /** | ||
ConfigureEthernetRequest.prototype.onError = | ||
function onError(callbackFunction) { | ||
var thisReq = this; | ||
thisReq._signals.ErrorResponse.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
function onError(callbackFunction) { | ||
var thisReq = this; | ||
thisReq._signals.ErrorResponse.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
@@ -399,23 +399,23 @@ /** | ||
var GetConnectedPeripheralsRequest = function GetConnectedPeripheralsRequest(requestDataArgs) { | ||
var thisReq = this; | ||
var thisReq = this; | ||
// Setup the request response signals to handle events | ||
thisReq._signals = {}; | ||
thisReq._signals.RetrievedConnectedPeripherals = new Signal(); | ||
thisReq._signals.ErrorResponse = new Signal(); | ||
// Setup the request response signals to handle events | ||
thisReq._signals = {}; | ||
thisReq._signals.RetrievedConnectedPeripherals = new Signal(); | ||
thisReq._signals.ErrorResponse = new Signal(); | ||
thisReq._protobuf = protobufTools.getProtobuf("GetConnectedPeripheralsArgs"); | ||
thisReq._protobuf.META = thisReq._protobuf.META || {}; | ||
var thisProtobuf = thisReq._protobuf; | ||
if (requestDataArgs) { | ||
_.each(requestDataArgs, function(val, key) { | ||
thisProtobuf[key] = val; | ||
}); | ||
} | ||
thisReq._protobuf = protobufTools.getProtobuf("GetConnectedPeripheralsArgs"); | ||
thisReq._protobuf.META = thisReq._protobuf.META || {}; | ||
var thisProtobuf = thisReq._protobuf; | ||
if (requestDataArgs) { | ||
_.each(requestDataArgs, function(val, key) { | ||
thisProtobuf[key] = val; | ||
}); | ||
} | ||
// Set helper data for the protobuf | ||
thisProtobuf._protoName = "GetConnectedPeripheralsArgs"; | ||
thisProtobuf._rpcName = "GetConnectedPeripherals"; | ||
// Set helper data for the protobuf | ||
thisProtobuf._protoName = "GetConnectedPeripheralsArgs"; | ||
thisProtobuf._rpcName = "GetConnectedPeripherals"; | ||
return thisReq; | ||
return thisReq; | ||
}; | ||
@@ -427,8 +427,8 @@ | ||
GetConnectedPeripheralsRequest.prototype.onRetrievedConnectedPeripherals = | ||
function onRetrievedConnectedPeripherals(callbackFunction) { | ||
var thisReq = this; | ||
// TODO(cjrd) should the default be a permanent cb or "once" cb? | ||
thisReq._signals.RetrievedConnectedPeripherals.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
function onRetrievedConnectedPeripherals(callbackFunction) { | ||
var thisReq = this; | ||
// TODO(cjrd) should the default be a permanent cb or "once" cb? | ||
thisReq._signals.RetrievedConnectedPeripherals.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
@@ -439,6 +439,6 @@ /** | ||
GetConnectedPeripheralsRequest.prototype.onError = | ||
function onError(callbackFunction) { | ||
var thisReq = this; | ||
thisReq._signals.ErrorResponse.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
function onError(callbackFunction) { | ||
var thisReq = this; | ||
thisReq._signals.ErrorResponse.add(callbackFunction); | ||
return thisReq; | ||
}; |
@@ -10,11 +10,11 @@ /** | ||
module.exports.getCustomerId = function getCustomerId(getCustomerIdArgs) { | ||
var request = new GetCustomerIdRequest(getCustomerIdArgs); | ||
server.sendRequest(request); | ||
return request; | ||
var request = new GetCustomerIdRequest(getCustomerIdArgs); | ||
server.sendRequest(request); | ||
return request; | ||
}; | ||
module.exports.receiveLogs = function receiveLogs(receiveLogsArgs) { | ||
var request = new ReceiveLogsRequest(receiveLogsArgs); | ||
server.sendRequest(request); | ||
return request; | ||
var request = new ReceiveLogsRequest(receiveLogsArgs); | ||
server.sendRequest(request); | ||
return request; | ||
}; | ||
@@ -38,23 +38,23 @@ | ||
var GetCustomerIdRequest = function GetCustomerIdRequest(requestDataArgs) { | ||
var thisReq = this; | ||
var thisReq = this; | ||
// Setup the request response signals to handle events | ||
thisReq._signals = {}; | ||
thisReq._signals.RetrievedCustomerId = new Signal(); | ||
thisReq._signals.ErrorResponse = new Signal(); | ||
// Setup the request response signals to handle events | ||
thisReq._signals = {}; | ||
thisReq._signals.RetrievedCustomerId = new Signal(); | ||
thisReq._signals.ErrorResponse = new Signal(); | ||
thisReq._protobuf = protobufTools.getProtobuf("GetCustomerIdArgs"); | ||
thisReq._protobuf.META = thisReq._protobuf.META || {}; | ||
var thisProtobuf = thisReq._protobuf; | ||
if (requestDataArgs) { | ||
_.each(requestDataArgs, function(val, key) { | ||
thisProtobuf[key] = val; | ||
}); | ||
} | ||
thisReq._protobuf = protobufTools.getProtobuf("GetCustomerIdArgs"); | ||
thisReq._protobuf.META = thisReq._protobuf.META || {}; | ||
var thisProtobuf = thisReq._protobuf; | ||
if (requestDataArgs) { | ||
_.each(requestDataArgs, function(val, key) { | ||
thisProtobuf[key] = val; | ||
}); | ||
} | ||
// Set helper data for the protobuf | ||
thisProtobuf._protoName = "GetCustomerIdArgs"; | ||
thisProtobuf._rpcName = "GetCustomerId"; | ||
// Set helper data for the protobuf | ||
thisProtobuf._protoName = "GetCustomerIdArgs"; | ||
thisProtobuf._rpcName = "GetCustomerId"; | ||
return thisReq; | ||
return thisReq; | ||
}; | ||
@@ -66,8 +66,8 @@ | ||
GetCustomerIdRequest.prototype.onRetrievedCustomerId = | ||
function onRetrievedCustomerId(callbackFunction) { | ||
var thisReq = this; | ||
// TODO(cjrd) should the default be a permanent cb or "once" cb? | ||
thisReq._signals.RetrievedCustomerId.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
function onRetrievedCustomerId(callbackFunction) { | ||
var thisReq = this; | ||
// TODO(cjrd) should the default be a permanent cb or "once" cb? | ||
thisReq._signals.RetrievedCustomerId.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
@@ -78,7 +78,7 @@ /** | ||
GetCustomerIdRequest.prototype.onError = | ||
function onError(callbackFunction) { | ||
var thisReq = this; | ||
thisReq._signals.ErrorResponse.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
function onError(callbackFunction) { | ||
var thisReq = this; | ||
thisReq._signals.ErrorResponse.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
@@ -91,23 +91,23 @@ /** | ||
var ReceiveLogsRequest = function ReceiveLogsRequest(requestDataArgs) { | ||
var thisReq = this; | ||
var thisReq = this; | ||
// Setup the request response signals to handle events | ||
thisReq._signals = {}; | ||
thisReq._signals.ReceivedLogs = new Signal(); | ||
thisReq._signals.ErrorResponse = new Signal(); | ||
// Setup the request response signals to handle events | ||
thisReq._signals = {}; | ||
thisReq._signals.ReceivedLogs = new Signal(); | ||
thisReq._signals.ErrorResponse = new Signal(); | ||
thisReq._protobuf = protobufTools.getProtobuf("ReceiveLogsArgs"); | ||
thisReq._protobuf.META = thisReq._protobuf.META || {}; | ||
var thisProtobuf = thisReq._protobuf; | ||
if (requestDataArgs) { | ||
_.each(requestDataArgs, function(val, key) { | ||
thisProtobuf[key] = val; | ||
}); | ||
} | ||
thisReq._protobuf = protobufTools.getProtobuf("ReceiveLogsArgs"); | ||
thisReq._protobuf.META = thisReq._protobuf.META || {}; | ||
var thisProtobuf = thisReq._protobuf; | ||
if (requestDataArgs) { | ||
_.each(requestDataArgs, function(val, key) { | ||
thisProtobuf[key] = val; | ||
}); | ||
} | ||
// Set helper data for the protobuf | ||
thisProtobuf._protoName = "ReceiveLogsArgs"; | ||
thisProtobuf._rpcName = "ReceiveLogs"; | ||
// Set helper data for the protobuf | ||
thisProtobuf._protoName = "ReceiveLogsArgs"; | ||
thisProtobuf._rpcName = "ReceiveLogs"; | ||
return thisReq; | ||
return thisReq; | ||
}; | ||
@@ -119,8 +119,8 @@ | ||
ReceiveLogsRequest.prototype.onReceivedLogs = | ||
function onReceivedLogs(callbackFunction) { | ||
var thisReq = this; | ||
// TODO(cjrd) should the default be a permanent cb or "once" cb? | ||
thisReq._signals.ReceivedLogs.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
function onReceivedLogs(callbackFunction) { | ||
var thisReq = this; | ||
// TODO(cjrd) should the default be a permanent cb or "once" cb? | ||
thisReq._signals.ReceivedLogs.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
@@ -131,6 +131,6 @@ /** | ||
ReceiveLogsRequest.prototype.onError = | ||
function onError(callbackFunction) { | ||
var thisReq = this; | ||
thisReq._signals.ErrorResponse.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
function onError(callbackFunction) { | ||
var thisReq = this; | ||
thisReq._signals.ErrorResponse.add(callbackFunction); | ||
return thisReq; | ||
}; |
@@ -10,41 +10,41 @@ /** | ||
module.exports.preAuthorize = function preAuthorize(preAuthorizeArgs) { | ||
var request = new PreAuthorizeRequest(preAuthorizeArgs); | ||
server.sendRequest(request); | ||
return request; | ||
var request = new PreAuthorizeRequest(preAuthorizeArgs); | ||
server.sendRequest(request); | ||
return request; | ||
}; | ||
module.exports.settle = function settle(settleArgs) { | ||
var request = new SettleRequest(settleArgs); | ||
server.sendRequest(request); | ||
return request; | ||
var request = new SettleRequest(settleArgs); | ||
server.sendRequest(request); | ||
return request; | ||
}; | ||
module.exports.voidPreAuthorize = function voidPreAuthorize(voidPreAuthorizeArgs) { | ||
var request = new VoidPreAuthorizeRequest(voidPreAuthorizeArgs); | ||
server.sendRequest(request); | ||
return request; | ||
var request = new VoidPreAuthorizeRequest(voidPreAuthorizeArgs); | ||
server.sendRequest(request); | ||
return request; | ||
}; | ||
module.exports.refund = function refund(refundArgs) { | ||
var request = new RefundRequest(refundArgs); | ||
server.sendRequest(request); | ||
return request; | ||
var request = new RefundRequest(refundArgs); | ||
server.sendRequest(request); | ||
return request; | ||
}; | ||
module.exports.configureProcessor = function configureProcessor(configureProcessorArgs) { | ||
var request = new ConfigureProcessorRequest(configureProcessorArgs); | ||
server.sendRequest(request); | ||
return request; | ||
var request = new ConfigureProcessorRequest(configureProcessorArgs); | ||
server.sendRequest(request); | ||
return request; | ||
}; | ||
module.exports.receivePaymentDataThenSettle = function receivePaymentDataThenSettle(receivePaymentDataThenSettleArgs) { | ||
var request = new ReceivePaymentDataThenSettleRequest(receivePaymentDataThenSettleArgs); | ||
server.sendRequest(request); | ||
return request; | ||
var request = new ReceivePaymentDataThenSettleRequest(receivePaymentDataThenSettleArgs); | ||
server.sendRequest(request); | ||
return request; | ||
}; | ||
module.exports.receivePaymentDataThenPreAuthorize = function receivePaymentDataThenPreAuthorize(receivePaymentDataThenPreAuthorizeArgs) { | ||
var request = new ReceivePaymentDataThenPreAuthorizeRequest(receivePaymentDataThenPreAuthorizeArgs); | ||
server.sendRequest(request); | ||
return request; | ||
var request = new ReceivePaymentDataThenPreAuthorizeRequest(receivePaymentDataThenPreAuthorizeArgs); | ||
server.sendRequest(request); | ||
return request; | ||
}; | ||
@@ -68,24 +68,24 @@ | ||
var PreAuthorizeRequest = function PreAuthorizeRequest(requestDataArgs) { | ||
var thisReq = this; | ||
var thisReq = this; | ||
// Setup the request response signals to handle events | ||
thisReq._signals = {}; | ||
thisReq._signals.StartedPreAuthorizing = new Signal(); | ||
thisReq._signals.PreAuthorized = new Signal(); | ||
thisReq._signals.ErrorResponse = new Signal(); | ||
// Setup the request response signals to handle events | ||
thisReq._signals = {}; | ||
thisReq._signals.StartedPreAuthorizing = new Signal(); | ||
thisReq._signals.PreAuthorized = new Signal(); | ||
thisReq._signals.ErrorResponse = new Signal(); | ||
thisReq._protobuf = protobufTools.getProtobuf("PreAuthorizeArgs"); | ||
thisReq._protobuf.META = thisReq._protobuf.META || {}; | ||
var thisProtobuf = thisReq._protobuf; | ||
if (requestDataArgs) { | ||
_.each(requestDataArgs, function(val, key) { | ||
thisProtobuf[key] = val; | ||
}); | ||
} | ||
thisReq._protobuf = protobufTools.getProtobuf("PreAuthorizeArgs"); | ||
thisReq._protobuf.META = thisReq._protobuf.META || {}; | ||
var thisProtobuf = thisReq._protobuf; | ||
if (requestDataArgs) { | ||
_.each(requestDataArgs, function(val, key) { | ||
thisProtobuf[key] = val; | ||
}); | ||
} | ||
// Set helper data for the protobuf | ||
thisProtobuf._protoName = "PreAuthorizeArgs"; | ||
thisProtobuf._rpcName = "PreAuthorize"; | ||
// Set helper data for the protobuf | ||
thisProtobuf._protoName = "PreAuthorizeArgs"; | ||
thisProtobuf._rpcName = "PreAuthorize"; | ||
return thisReq; | ||
return thisReq; | ||
}; | ||
@@ -97,8 +97,8 @@ | ||
PreAuthorizeRequest.prototype.onStartedPreAuthorizing = | ||
function onStartedPreAuthorizing(callbackFunction) { | ||
var thisReq = this; | ||
// TODO(cjrd) should the default be a permanent cb or "once" cb? | ||
thisReq._signals.StartedPreAuthorizing.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
function onStartedPreAuthorizing(callbackFunction) { | ||
var thisReq = this; | ||
// TODO(cjrd) should the default be a permanent cb or "once" cb? | ||
thisReq._signals.StartedPreAuthorizing.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
@@ -109,8 +109,8 @@ /** | ||
PreAuthorizeRequest.prototype.onPreAuthorized = | ||
function onPreAuthorized(callbackFunction) { | ||
var thisReq = this; | ||
// TODO(cjrd) should the default be a permanent cb or "once" cb? | ||
thisReq._signals.PreAuthorized.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
function onPreAuthorized(callbackFunction) { | ||
var thisReq = this; | ||
// TODO(cjrd) should the default be a permanent cb or "once" cb? | ||
thisReq._signals.PreAuthorized.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
@@ -121,7 +121,7 @@ /** | ||
PreAuthorizeRequest.prototype.onError = | ||
function onError(callbackFunction) { | ||
var thisReq = this; | ||
thisReq._signals.ErrorResponse.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
function onError(callbackFunction) { | ||
var thisReq = this; | ||
thisReq._signals.ErrorResponse.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
@@ -134,24 +134,24 @@ /** | ||
var SettleRequest = function SettleRequest(requestDataArgs) { | ||
var thisReq = this; | ||
var thisReq = this; | ||
// Setup the request response signals to handle events | ||
thisReq._signals = {}; | ||
thisReq._signals.StartedSettling = new Signal(); | ||
thisReq._signals.Settled = new Signal(); | ||
thisReq._signals.ErrorResponse = new Signal(); | ||
// Setup the request response signals to handle events | ||
thisReq._signals = {}; | ||
thisReq._signals.StartedSettling = new Signal(); | ||
thisReq._signals.Settled = new Signal(); | ||
thisReq._signals.ErrorResponse = new Signal(); | ||
thisReq._protobuf = protobufTools.getProtobuf("SettleArgs"); | ||
thisReq._protobuf.META = thisReq._protobuf.META || {}; | ||
var thisProtobuf = thisReq._protobuf; | ||
if (requestDataArgs) { | ||
_.each(requestDataArgs, function(val, key) { | ||
thisProtobuf[key] = val; | ||
}); | ||
} | ||
thisReq._protobuf = protobufTools.getProtobuf("SettleArgs"); | ||
thisReq._protobuf.META = thisReq._protobuf.META || {}; | ||
var thisProtobuf = thisReq._protobuf; | ||
if (requestDataArgs) { | ||
_.each(requestDataArgs, function(val, key) { | ||
thisProtobuf[key] = val; | ||
}); | ||
} | ||
// Set helper data for the protobuf | ||
thisProtobuf._protoName = "SettleArgs"; | ||
thisProtobuf._rpcName = "Settle"; | ||
// Set helper data for the protobuf | ||
thisProtobuf._protoName = "SettleArgs"; | ||
thisProtobuf._rpcName = "Settle"; | ||
return thisReq; | ||
return thisReq; | ||
}; | ||
@@ -163,8 +163,8 @@ | ||
SettleRequest.prototype.onStartedSettling = | ||
function onStartedSettling(callbackFunction) { | ||
var thisReq = this; | ||
// TODO(cjrd) should the default be a permanent cb or "once" cb? | ||
thisReq._signals.StartedSettling.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
function onStartedSettling(callbackFunction) { | ||
var thisReq = this; | ||
// TODO(cjrd) should the default be a permanent cb or "once" cb? | ||
thisReq._signals.StartedSettling.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
@@ -175,8 +175,8 @@ /** | ||
SettleRequest.prototype.onSettled = | ||
function onSettled(callbackFunction) { | ||
var thisReq = this; | ||
// TODO(cjrd) should the default be a permanent cb or "once" cb? | ||
thisReq._signals.Settled.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
function onSettled(callbackFunction) { | ||
var thisReq = this; | ||
// TODO(cjrd) should the default be a permanent cb or "once" cb? | ||
thisReq._signals.Settled.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
@@ -187,7 +187,7 @@ /** | ||
SettleRequest.prototype.onError = | ||
function onError(callbackFunction) { | ||
var thisReq = this; | ||
thisReq._signals.ErrorResponse.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
function onError(callbackFunction) { | ||
var thisReq = this; | ||
thisReq._signals.ErrorResponse.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
@@ -200,23 +200,23 @@ /** | ||
var VoidPreAuthorizeRequest = function VoidPreAuthorizeRequest(requestDataArgs) { | ||
var thisReq = this; | ||
var thisReq = this; | ||
// Setup the request response signals to handle events | ||
thisReq._signals = {}; | ||
thisReq._signals.VoidedPreAuthorize = new Signal(); | ||
thisReq._signals.ErrorResponse = new Signal(); | ||
// Setup the request response signals to handle events | ||
thisReq._signals = {}; | ||
thisReq._signals.VoidedPreAuthorize = new Signal(); | ||
thisReq._signals.ErrorResponse = new Signal(); | ||
thisReq._protobuf = protobufTools.getProtobuf("VoidPreAuthorizeArgs"); | ||
thisReq._protobuf.META = thisReq._protobuf.META || {}; | ||
var thisProtobuf = thisReq._protobuf; | ||
if (requestDataArgs) { | ||
_.each(requestDataArgs, function(val, key) { | ||
thisProtobuf[key] = val; | ||
}); | ||
} | ||
thisReq._protobuf = protobufTools.getProtobuf("VoidPreAuthorizeArgs"); | ||
thisReq._protobuf.META = thisReq._protobuf.META || {}; | ||
var thisProtobuf = thisReq._protobuf; | ||
if (requestDataArgs) { | ||
_.each(requestDataArgs, function(val, key) { | ||
thisProtobuf[key] = val; | ||
}); | ||
} | ||
// Set helper data for the protobuf | ||
thisProtobuf._protoName = "VoidPreAuthorizeArgs"; | ||
thisProtobuf._rpcName = "VoidPreAuthorize"; | ||
// Set helper data for the protobuf | ||
thisProtobuf._protoName = "VoidPreAuthorizeArgs"; | ||
thisProtobuf._rpcName = "VoidPreAuthorize"; | ||
return thisReq; | ||
return thisReq; | ||
}; | ||
@@ -228,8 +228,8 @@ | ||
VoidPreAuthorizeRequest.prototype.onVoidedPreAuthorize = | ||
function onVoidedPreAuthorize(callbackFunction) { | ||
var thisReq = this; | ||
// TODO(cjrd) should the default be a permanent cb or "once" cb? | ||
thisReq._signals.VoidedPreAuthorize.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
function onVoidedPreAuthorize(callbackFunction) { | ||
var thisReq = this; | ||
// TODO(cjrd) should the default be a permanent cb or "once" cb? | ||
thisReq._signals.VoidedPreAuthorize.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
@@ -240,7 +240,7 @@ /** | ||
VoidPreAuthorizeRequest.prototype.onError = | ||
function onError(callbackFunction) { | ||
var thisReq = this; | ||
thisReq._signals.ErrorResponse.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
function onError(callbackFunction) { | ||
var thisReq = this; | ||
thisReq._signals.ErrorResponse.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
@@ -253,23 +253,23 @@ /** | ||
var RefundRequest = function RefundRequest(requestDataArgs) { | ||
var thisReq = this; | ||
var thisReq = this; | ||
// Setup the request response signals to handle events | ||
thisReq._signals = {}; | ||
thisReq._signals.Refunded = new Signal(); | ||
thisReq._signals.ErrorResponse = new Signal(); | ||
// Setup the request response signals to handle events | ||
thisReq._signals = {}; | ||
thisReq._signals.Refunded = new Signal(); | ||
thisReq._signals.ErrorResponse = new Signal(); | ||
thisReq._protobuf = protobufTools.getProtobuf("RefundArgs"); | ||
thisReq._protobuf.META = thisReq._protobuf.META || {}; | ||
var thisProtobuf = thisReq._protobuf; | ||
if (requestDataArgs) { | ||
_.each(requestDataArgs, function(val, key) { | ||
thisProtobuf[key] = val; | ||
}); | ||
} | ||
thisReq._protobuf = protobufTools.getProtobuf("RefundArgs"); | ||
thisReq._protobuf.META = thisReq._protobuf.META || {}; | ||
var thisProtobuf = thisReq._protobuf; | ||
if (requestDataArgs) { | ||
_.each(requestDataArgs, function(val, key) { | ||
thisProtobuf[key] = val; | ||
}); | ||
} | ||
// Set helper data for the protobuf | ||
thisProtobuf._protoName = "RefundArgs"; | ||
thisProtobuf._rpcName = "Refund"; | ||
// Set helper data for the protobuf | ||
thisProtobuf._protoName = "RefundArgs"; | ||
thisProtobuf._rpcName = "Refund"; | ||
return thisReq; | ||
return thisReq; | ||
}; | ||
@@ -281,8 +281,8 @@ | ||
RefundRequest.prototype.onRefunded = | ||
function onRefunded(callbackFunction) { | ||
var thisReq = this; | ||
// TODO(cjrd) should the default be a permanent cb or "once" cb? | ||
thisReq._signals.Refunded.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
function onRefunded(callbackFunction) { | ||
var thisReq = this; | ||
// TODO(cjrd) should the default be a permanent cb or "once" cb? | ||
thisReq._signals.Refunded.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
@@ -293,7 +293,7 @@ /** | ||
RefundRequest.prototype.onError = | ||
function onError(callbackFunction) { | ||
var thisReq = this; | ||
thisReq._signals.ErrorResponse.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
function onError(callbackFunction) { | ||
var thisReq = this; | ||
thisReq._signals.ErrorResponse.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
@@ -306,23 +306,23 @@ /** | ||
var ConfigureProcessorRequest = function ConfigureProcessorRequest(requestDataArgs) { | ||
var thisReq = this; | ||
var thisReq = this; | ||
// Setup the request response signals to handle events | ||
thisReq._signals = {}; | ||
thisReq._signals.ConfiguredProcessor = new Signal(); | ||
thisReq._signals.ErrorResponse = new Signal(); | ||
// Setup the request response signals to handle events | ||
thisReq._signals = {}; | ||
thisReq._signals.ConfiguredProcessor = new Signal(); | ||
thisReq._signals.ErrorResponse = new Signal(); | ||
thisReq._protobuf = protobufTools.getProtobuf("ConfigureProcessorArgs"); | ||
thisReq._protobuf.META = thisReq._protobuf.META || {}; | ||
var thisProtobuf = thisReq._protobuf; | ||
if (requestDataArgs) { | ||
_.each(requestDataArgs, function(val, key) { | ||
thisProtobuf[key] = val; | ||
}); | ||
} | ||
thisReq._protobuf = protobufTools.getProtobuf("ConfigureProcessorArgs"); | ||
thisReq._protobuf.META = thisReq._protobuf.META || {}; | ||
var thisProtobuf = thisReq._protobuf; | ||
if (requestDataArgs) { | ||
_.each(requestDataArgs, function(val, key) { | ||
thisProtobuf[key] = val; | ||
}); | ||
} | ||
// Set helper data for the protobuf | ||
thisProtobuf._protoName = "ConfigureProcessorArgs"; | ||
thisProtobuf._rpcName = "ConfigureProcessor"; | ||
// Set helper data for the protobuf | ||
thisProtobuf._protoName = "ConfigureProcessorArgs"; | ||
thisProtobuf._rpcName = "ConfigureProcessor"; | ||
return thisReq; | ||
return thisReq; | ||
}; | ||
@@ -334,8 +334,8 @@ | ||
ConfigureProcessorRequest.prototype.onConfiguredProcessor = | ||
function onConfiguredProcessor(callbackFunction) { | ||
var thisReq = this; | ||
// TODO(cjrd) should the default be a permanent cb or "once" cb? | ||
thisReq._signals.ConfiguredProcessor.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
function onConfiguredProcessor(callbackFunction) { | ||
var thisReq = this; | ||
// TODO(cjrd) should the default be a permanent cb or "once" cb? | ||
thisReq._signals.ConfiguredProcessor.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
@@ -346,7 +346,7 @@ /** | ||
ConfigureProcessorRequest.prototype.onError = | ||
function onError(callbackFunction) { | ||
var thisReq = this; | ||
thisReq._signals.ErrorResponse.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
function onError(callbackFunction) { | ||
var thisReq = this; | ||
thisReq._signals.ErrorResponse.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
@@ -359,26 +359,26 @@ /** | ||
var ReceivePaymentDataThenSettleRequest = function ReceivePaymentDataThenSettleRequest(requestDataArgs) { | ||
var thisReq = this; | ||
var thisReq = this; | ||
// Setup the request response signals to handle events | ||
thisReq._signals = {}; | ||
thisReq._signals.StartedReceivingPaymentData = new Signal(); | ||
thisReq._signals.ReceivedPaymentData = new Signal(); | ||
thisReq._signals.StartedSettling = new Signal(); | ||
thisReq._signals.Settled = new Signal(); | ||
thisReq._signals.ErrorResponse = new Signal(); | ||
// Setup the request response signals to handle events | ||
thisReq._signals = {}; | ||
thisReq._signals.StartedReceivingPaymentData = new Signal(); | ||
thisReq._signals.ReceivedPaymentData = new Signal(); | ||
thisReq._signals.StartedSettling = new Signal(); | ||
thisReq._signals.Settled = new Signal(); | ||
thisReq._signals.ErrorResponse = new Signal(); | ||
thisReq._protobuf = protobufTools.getProtobuf("ReceivePaymentDataThenSettleArgs"); | ||
thisReq._protobuf.META = thisReq._protobuf.META || {}; | ||
var thisProtobuf = thisReq._protobuf; | ||
if (requestDataArgs) { | ||
_.each(requestDataArgs, function(val, key) { | ||
thisProtobuf[key] = val; | ||
}); | ||
} | ||
thisReq._protobuf = protobufTools.getProtobuf("ReceivePaymentDataThenSettleArgs"); | ||
thisReq._protobuf.META = thisReq._protobuf.META || {}; | ||
var thisProtobuf = thisReq._protobuf; | ||
if (requestDataArgs) { | ||
_.each(requestDataArgs, function(val, key) { | ||
thisProtobuf[key] = val; | ||
}); | ||
} | ||
// Set helper data for the protobuf | ||
thisProtobuf._protoName = "ReceivePaymentDataThenSettleArgs"; | ||
thisProtobuf._rpcName = "ReceivePaymentDataThenSettle"; | ||
// Set helper data for the protobuf | ||
thisProtobuf._protoName = "ReceivePaymentDataThenSettleArgs"; | ||
thisProtobuf._rpcName = "ReceivePaymentDataThenSettle"; | ||
return thisReq; | ||
return thisReq; | ||
}; | ||
@@ -390,8 +390,8 @@ | ||
ReceivePaymentDataThenSettleRequest.prototype.onStartedReceivingPaymentData = | ||
function onStartedReceivingPaymentData(callbackFunction) { | ||
var thisReq = this; | ||
// TODO(cjrd) should the default be a permanent cb or "once" cb? | ||
thisReq._signals.StartedReceivingPaymentData.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
function onStartedReceivingPaymentData(callbackFunction) { | ||
var thisReq = this; | ||
// TODO(cjrd) should the default be a permanent cb or "once" cb? | ||
thisReq._signals.StartedReceivingPaymentData.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
@@ -402,8 +402,8 @@ /** | ||
ReceivePaymentDataThenSettleRequest.prototype.onReceivedPaymentData = | ||
function onReceivedPaymentData(callbackFunction) { | ||
var thisReq = this; | ||
// TODO(cjrd) should the default be a permanent cb or "once" cb? | ||
thisReq._signals.ReceivedPaymentData.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
function onReceivedPaymentData(callbackFunction) { | ||
var thisReq = this; | ||
// TODO(cjrd) should the default be a permanent cb or "once" cb? | ||
thisReq._signals.ReceivedPaymentData.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
@@ -414,8 +414,8 @@ /** | ||
ReceivePaymentDataThenSettleRequest.prototype.onStartedSettling = | ||
function onStartedSettling(callbackFunction) { | ||
var thisReq = this; | ||
// TODO(cjrd) should the default be a permanent cb or "once" cb? | ||
thisReq._signals.StartedSettling.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
function onStartedSettling(callbackFunction) { | ||
var thisReq = this; | ||
// TODO(cjrd) should the default be a permanent cb or "once" cb? | ||
thisReq._signals.StartedSettling.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
@@ -426,8 +426,8 @@ /** | ||
ReceivePaymentDataThenSettleRequest.prototype.onSettled = | ||
function onSettled(callbackFunction) { | ||
var thisReq = this; | ||
// TODO(cjrd) should the default be a permanent cb or "once" cb? | ||
thisReq._signals.Settled.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
function onSettled(callbackFunction) { | ||
var thisReq = this; | ||
// TODO(cjrd) should the default be a permanent cb or "once" cb? | ||
thisReq._signals.Settled.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
@@ -438,7 +438,7 @@ /** | ||
ReceivePaymentDataThenSettleRequest.prototype.onError = | ||
function onError(callbackFunction) { | ||
var thisReq = this; | ||
thisReq._signals.ErrorResponse.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
function onError(callbackFunction) { | ||
var thisReq = this; | ||
thisReq._signals.ErrorResponse.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
@@ -451,26 +451,26 @@ /** | ||
var ReceivePaymentDataThenPreAuthorizeRequest = function ReceivePaymentDataThenPreAuthorizeRequest(requestDataArgs) { | ||
var thisReq = this; | ||
var thisReq = this; | ||
// Setup the request response signals to handle events | ||
thisReq._signals = {}; | ||
thisReq._signals.StartedReceivingPaymentData = new Signal(); | ||
thisReq._signals.ReceivedPaymentData = new Signal(); | ||
thisReq._signals.StartedPreAuthorizing = new Signal(); | ||
thisReq._signals.PreAuthorized = new Signal(); | ||
thisReq._signals.ErrorResponse = new Signal(); | ||
// Setup the request response signals to handle events | ||
thisReq._signals = {}; | ||
thisReq._signals.StartedReceivingPaymentData = new Signal(); | ||
thisReq._signals.ReceivedPaymentData = new Signal(); | ||
thisReq._signals.StartedPreAuthorizing = new Signal(); | ||
thisReq._signals.PreAuthorized = new Signal(); | ||
thisReq._signals.ErrorResponse = new Signal(); | ||
thisReq._protobuf = protobufTools.getProtobuf("ReceivePaymentDataThenPreAuthorizeArgs"); | ||
thisReq._protobuf.META = thisReq._protobuf.META || {}; | ||
var thisProtobuf = thisReq._protobuf; | ||
if (requestDataArgs) { | ||
_.each(requestDataArgs, function(val, key) { | ||
thisProtobuf[key] = val; | ||
}); | ||
} | ||
thisReq._protobuf = protobufTools.getProtobuf("ReceivePaymentDataThenPreAuthorizeArgs"); | ||
thisReq._protobuf.META = thisReq._protobuf.META || {}; | ||
var thisProtobuf = thisReq._protobuf; | ||
if (requestDataArgs) { | ||
_.each(requestDataArgs, function(val, key) { | ||
thisProtobuf[key] = val; | ||
}); | ||
} | ||
// Set helper data for the protobuf | ||
thisProtobuf._protoName = "ReceivePaymentDataThenPreAuthorizeArgs"; | ||
thisProtobuf._rpcName = "ReceivePaymentDataThenPreAuthorize"; | ||
// Set helper data for the protobuf | ||
thisProtobuf._protoName = "ReceivePaymentDataThenPreAuthorizeArgs"; | ||
thisProtobuf._rpcName = "ReceivePaymentDataThenPreAuthorize"; | ||
return thisReq; | ||
return thisReq; | ||
}; | ||
@@ -482,8 +482,8 @@ | ||
ReceivePaymentDataThenPreAuthorizeRequest.prototype.onStartedReceivingPaymentData = | ||
function onStartedReceivingPaymentData(callbackFunction) { | ||
var thisReq = this; | ||
// TODO(cjrd) should the default be a permanent cb or "once" cb? | ||
thisReq._signals.StartedReceivingPaymentData.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
function onStartedReceivingPaymentData(callbackFunction) { | ||
var thisReq = this; | ||
// TODO(cjrd) should the default be a permanent cb or "once" cb? | ||
thisReq._signals.StartedReceivingPaymentData.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
@@ -494,8 +494,8 @@ /** | ||
ReceivePaymentDataThenPreAuthorizeRequest.prototype.onReceivedPaymentData = | ||
function onReceivedPaymentData(callbackFunction) { | ||
var thisReq = this; | ||
// TODO(cjrd) should the default be a permanent cb or "once" cb? | ||
thisReq._signals.ReceivedPaymentData.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
function onReceivedPaymentData(callbackFunction) { | ||
var thisReq = this; | ||
// TODO(cjrd) should the default be a permanent cb or "once" cb? | ||
thisReq._signals.ReceivedPaymentData.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
@@ -506,8 +506,8 @@ /** | ||
ReceivePaymentDataThenPreAuthorizeRequest.prototype.onStartedPreAuthorizing = | ||
function onStartedPreAuthorizing(callbackFunction) { | ||
var thisReq = this; | ||
// TODO(cjrd) should the default be a permanent cb or "once" cb? | ||
thisReq._signals.StartedPreAuthorizing.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
function onStartedPreAuthorizing(callbackFunction) { | ||
var thisReq = this; | ||
// TODO(cjrd) should the default be a permanent cb or "once" cb? | ||
thisReq._signals.StartedPreAuthorizing.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
@@ -518,8 +518,8 @@ /** | ||
ReceivePaymentDataThenPreAuthorizeRequest.prototype.onPreAuthorized = | ||
function onPreAuthorized(callbackFunction) { | ||
var thisReq = this; | ||
// TODO(cjrd) should the default be a permanent cb or "once" cb? | ||
thisReq._signals.PreAuthorized.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
function onPreAuthorized(callbackFunction) { | ||
var thisReq = this; | ||
// TODO(cjrd) should the default be a permanent cb or "once" cb? | ||
thisReq._signals.PreAuthorized.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
@@ -530,6 +530,6 @@ /** | ||
ReceivePaymentDataThenPreAuthorizeRequest.prototype.onError = | ||
function onError(callbackFunction) { | ||
var thisReq = this; | ||
thisReq._signals.ErrorResponse.add(callbackFunction); | ||
return thisReq; | ||
}; | ||
function onError(callbackFunction) { | ||
var thisReq = this; | ||
thisReq._signals.ErrorResponse.add(callbackFunction); | ||
return thisReq; | ||
}; |
@@ -10,5 +10,6 @@ /** | ||
var _ = require("lodash"); | ||
var cloudLogger = require("./util/cloud-logger"); | ||
var config = require("./config"); | ||
var logger = require("./logging"); | ||
var shortid = require("shortid"); | ||
var logger = require("./logging"); | ||
var cloudLogger = require("./util/cloud-logger"); | ||
@@ -93,4 +94,12 @@ // internal state | ||
logger.debug("Server received handled API response", response); | ||
reqObj._signals[response.name].dispatch(response.message); | ||
cloudLogger.logAPIResponse(response.name, response.message, true); | ||
var cloudPromise = cloudLogger.logAPIResponse(response.name, response.message, true); | ||
// wait to send responses during simulation so that all logs reach the server | ||
if (config.simulate && cloudPromise) { | ||
cloudPromise && cloudPromise.then(function () { | ||
reqObj._signals[response.name].dispatch(response.message); | ||
}); | ||
} else { | ||
reqObj._signals[response.name].dispatch(response.message); | ||
} | ||
} else { | ||
@@ -97,0 +106,0 @@ logger.debug("Server received unhandled API response", response); |
{ | ||
"name": "dotdashpay", | ||
"version": "0.3.1", | ||
"version": "0.3.2", | ||
"description": "DotDashPay Node API", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -5,2 +5,3 @@ /** | ||
var _ = require("lodash"); | ||
@@ -14,77 +15,73 @@ var assert = require('chai').assert; | ||
var args = { | ||
staticIp: "192.168.1.128", | ||
staticSubnetMask: "255.255.255.0", | ||
staticGateway: "192.168.1.1", | ||
staticDns: "8.8.8.8", | ||
saveConfiguration: true, | ||
autoReconnect: true, | ||
staticIp: "192.168.1.128", | ||
staticSubnetMask: "255.255.255.0", | ||
staticGateway: "192.168.1.1", | ||
staticDns: "8.8.8.8", | ||
saveConfiguration: true, | ||
autoReconnect: true, | ||
}; | ||
describe("Hardware", function() { | ||
describe("configureEthernet", function() { | ||
beforeEach(function() { | ||
dotdashpay._reset(); | ||
dotdashpay.setup({ | ||
simulate: true | ||
}); | ||
describe("configureEthernet", function() { | ||
beforeEach(function() { | ||
dotdashpay._reset(); | ||
dotdashpay.setup({ simulate: true }); | ||
}); | ||
it("should have no undefined fields", function(done) { | ||
this.timeout(10000); | ||
var callbacksVisited = 0; | ||
dotdashpay.hardware.configureEthernet(args) | ||
.onConfiguredEthernet(function(response) { | ||
console.log("Received onConfiguredEthernet response", JSON.stringify(response)); | ||
callbacksVisited++; | ||
assert.equal(callbacksVisited, 1, "Not all callbacks were called") | ||
done(); | ||
}) | ||
.onError(function(errorData) { | ||
console.log("Error", JSON.stringify(errorData)); | ||
fail(null, null, "This example should never return an error"); | ||
}); | ||
it("should have no undefined fields", function(done) { | ||
this.timeout(10000); | ||
var callbacksVisited = 0; | ||
}); | ||
dotdashpay.hardware.configureEthernet(args) | ||
.onConfiguredEthernet(function(response) { | ||
callbacksVisited++; | ||
assert.equal(callbacksVisited, 1, "Not all callbacks were called") | ||
done(); | ||
}) | ||
.onError(function(errorData) { | ||
if (errorData.errorCode == "") { | ||
console.log("Error: " + errorData.errorMessage); | ||
} | ||
fail(null, null, "This example should never return an error"); | ||
}); | ||
it("should be able to specify an error response with the simulator", function(done) { | ||
this.timeout(10000); | ||
var testErrorMessage = "Test error message"; | ||
var testErrorCode = 1; | ||
dotdashpay.simulator.setResponse("ConfiguredEthernet", { | ||
errorMessage: testErrorMessage, | ||
errorCode: testErrorCode | ||
}, | ||
true); | ||
dotdashpay.hardware.configureEthernet(args) | ||
.onConfiguredEthernet(function(response) { | ||
fail(null, null, "This example should only have an onError callback event, not ConfiguredEthernet"); | ||
}) | ||
.onError(function(errorData) { | ||
assert.equal(testErrorMessage, errorData.errorMessage, | ||
"Simulator error message was not returned correctly"); | ||
assert.equal(testErrorCode, errorData.errorCode, | ||
"Simulator error code was not returned correctly"); | ||
dotdashpay.simulator.resetAllResponses(); | ||
done(); | ||
}); | ||
}); | ||
it("should be able to specify an error response with the simulator", function(done) { | ||
this.timeout(10000); | ||
var testErrorMessage = "Test error message"; | ||
var testErrorCode = 1; | ||
dotdashpay.simulator.setResponse("ConfiguredEthernet", { | ||
errorMessage: testErrorMessage, | ||
errorCode: testErrorCode | ||
}, | ||
true); | ||
dotdashpay.hardware.configureEthernet(args) | ||
.onConfiguredEthernet(function(response) { | ||
fail(null, null, "This example should only have an onError callback event, not ConfiguredEthernet"); | ||
}) | ||
.onError(function(errorData) { | ||
assert.equal(testErrorMessage, errorData.errorMessage, | ||
"Simulator error message was not returned correctly"); | ||
assert.equal(testErrorCode, errorData.errorCode, | ||
"Simulator error code was not returned correctly"); | ||
dotdashpay.simulator.resetAllResponses(); | ||
done(); | ||
}); | ||
}); | ||
it("should be able to specify a particular response from the simulator", function(done) { | ||
this.timeout(10000); | ||
// need a string value that we can overwrite | ||
var newVals = {}; | ||
it("should be able to specify a particular response from the simulator", function(done) { | ||
this.timeout(10000); | ||
// need a string value that we can overwrite | ||
var newVals = {}; | ||
dotdashpay.simulator.setResponse("ConfiguredEthernet", newVals); | ||
dotdashpay.simulator.setResponse("ConfiguredEthernet", newVals); | ||
dotdashpay.hardware.configureEthernet(args) | ||
.onConfiguredEthernet(function(response) { | ||
_.each(newVals, function(val, key) { | ||
assert.deepEqual(response[key], val); | ||
}); | ||
done(); | ||
}); | ||
dotdashpay.hardware.configureEthernet(args) | ||
.onConfiguredEthernet(function(response) { | ||
_.each(newVals, function(val, key) { | ||
assert.deepEqual(response[key], val); | ||
}); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); |
@@ -5,2 +5,3 @@ /** | ||
var _ = require("lodash"); | ||
@@ -14,73 +15,69 @@ var assert = require('chai').assert; | ||
var args = { | ||
peripheralName: "MagTekSureSwipe21040145", | ||
disable: false, | ||
peripheralName: "MagTekSureSwipe21040145", | ||
disable: false, | ||
}; | ||
describe("Hardware", function() { | ||
describe("configurePeripheral", function() { | ||
beforeEach(function() { | ||
dotdashpay._reset(); | ||
dotdashpay.setup({ | ||
simulate: true | ||
}); | ||
describe("configurePeripheral", function() { | ||
beforeEach(function() { | ||
dotdashpay._reset(); | ||
dotdashpay.setup({ simulate: true }); | ||
}); | ||
it("should have no undefined fields", function(done) { | ||
this.timeout(10000); | ||
var callbacksVisited = 0; | ||
dotdashpay.hardware.configurePeripheral(args) | ||
.onConfiguredPeripheral(function(response) { | ||
console.log("Received onConfiguredPeripheral response", JSON.stringify(response)); | ||
callbacksVisited++; | ||
assert.equal(callbacksVisited, 1, "Not all callbacks were called") | ||
done(); | ||
}) | ||
.onError(function(errorData) { | ||
console.log("Error", JSON.stringify(errorData)); | ||
fail(null, null, "This example should never return an error"); | ||
}); | ||
it("should have no undefined fields", function(done) { | ||
this.timeout(10000); | ||
var callbacksVisited = 0; | ||
}); | ||
dotdashpay.hardware.configurePeripheral(args) | ||
.onConfiguredPeripheral(function(response) { | ||
callbacksVisited++; | ||
assert.equal(callbacksVisited, 1, "Not all callbacks were called") | ||
done(); | ||
}) | ||
.onError(function(errorData) { | ||
if (errorData.errorCode == "") { | ||
console.log("Error: " + errorData.errorMessage); | ||
} | ||
fail(null, null, "This example should never return an error"); | ||
}); | ||
it("should be able to specify an error response with the simulator", function(done) { | ||
this.timeout(10000); | ||
var testErrorMessage = "Test error message"; | ||
var testErrorCode = 1; | ||
dotdashpay.simulator.setResponse("ConfiguredPeripheral", { | ||
errorMessage: testErrorMessage, | ||
errorCode: testErrorCode | ||
}, | ||
true); | ||
dotdashpay.hardware.configurePeripheral(args) | ||
.onConfiguredPeripheral(function(response) { | ||
fail(null, null, "This example should only have an onError callback event, not ConfiguredPeripheral"); | ||
}) | ||
.onError(function(errorData) { | ||
assert.equal(testErrorMessage, errorData.errorMessage, | ||
"Simulator error message was not returned correctly"); | ||
assert.equal(testErrorCode, errorData.errorCode, | ||
"Simulator error code was not returned correctly"); | ||
dotdashpay.simulator.resetAllResponses(); | ||
done(); | ||
}); | ||
}); | ||
it("should be able to specify an error response with the simulator", function(done) { | ||
this.timeout(10000); | ||
var testErrorMessage = "Test error message"; | ||
var testErrorCode = 1; | ||
dotdashpay.simulator.setResponse("ConfiguredPeripheral", { | ||
errorMessage: testErrorMessage, | ||
errorCode: testErrorCode | ||
}, | ||
true); | ||
dotdashpay.hardware.configurePeripheral(args) | ||
.onConfiguredPeripheral(function(response) { | ||
fail(null, null, "This example should only have an onError callback event, not ConfiguredPeripheral"); | ||
}) | ||
.onError(function(errorData) { | ||
assert.equal(testErrorMessage, errorData.errorMessage, | ||
"Simulator error message was not returned correctly"); | ||
assert.equal(testErrorCode, errorData.errorCode, | ||
"Simulator error code was not returned correctly"); | ||
dotdashpay.simulator.resetAllResponses(); | ||
done(); | ||
}); | ||
}); | ||
it("should be able to specify a particular response from the simulator", function(done) { | ||
this.timeout(10000); | ||
// need a string value that we can overwrite | ||
var newVals = {}; | ||
it("should be able to specify a particular response from the simulator", function(done) { | ||
this.timeout(10000); | ||
// need a string value that we can overwrite | ||
var newVals = {}; | ||
dotdashpay.simulator.setResponse("ConfiguredPeripheral", newVals); | ||
dotdashpay.simulator.setResponse("ConfiguredPeripheral", newVals); | ||
dotdashpay.hardware.configurePeripheral(args) | ||
.onConfiguredPeripheral(function(response) { | ||
_.each(newVals, function(val, key) { | ||
assert.deepEqual(response[key], val); | ||
}); | ||
done(); | ||
}); | ||
dotdashpay.hardware.configurePeripheral(args) | ||
.onConfiguredPeripheral(function(response) { | ||
_.each(newVals, function(val, key) { | ||
assert.deepEqual(response[key], val); | ||
}); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); |
@@ -5,2 +5,3 @@ /** | ||
var _ = require("lodash"); | ||
@@ -14,74 +15,70 @@ var assert = require('chai').assert; | ||
var args = { | ||
livemode: false, | ||
livemode: false, | ||
}; | ||
describe("Payment", function() { | ||
describe("configureProcessor", function() { | ||
beforeEach(function() { | ||
dotdashpay._reset(); | ||
dotdashpay.setup({ | ||
simulate: true | ||
}); | ||
describe("configureProcessor", function() { | ||
beforeEach(function() { | ||
dotdashpay._reset(); | ||
dotdashpay.setup({ simulate: true }); | ||
}); | ||
it("should have no undefined fields", function(done) { | ||
this.timeout(10000); | ||
var callbacksVisited = 0; | ||
dotdashpay.payment.configureProcessor(args) | ||
.onConfiguredProcessor(function(response) { | ||
console.log("Received onConfiguredProcessor response", JSON.stringify(response)); | ||
var livemode = response.livemode; // e.g. false | ||
assert.isDefined(livemode); | ||
callbacksVisited++; | ||
assert.equal(callbacksVisited, 1, "Not all callbacks were called") | ||
done(); | ||
}) | ||
.onError(function(errorData) { | ||
console.log("Error", JSON.stringify(errorData)); | ||
fail(null, null, "This example should never return an error"); | ||
}); | ||
it("should have no undefined fields", function(done) { | ||
this.timeout(10000); | ||
var callbacksVisited = 0; | ||
}); | ||
dotdashpay.payment.configureProcessor(args) | ||
.onConfiguredProcessor(function(response) { | ||
var livemode = response.livemode; // livemode = false | ||
assert.isDefined(livemode); | ||
callbacksVisited++; | ||
assert.equal(callbacksVisited, 1, "Not all callbacks were called") | ||
done(); | ||
}) | ||
.onError(function(errorData) { | ||
if (errorData.errorCode == "") { | ||
console.log("Error: " + errorData.errorMessage); | ||
} | ||
fail(null, null, "This example should never return an error"); | ||
}); | ||
it("should be able to specify an error response with the simulator", function(done) { | ||
this.timeout(10000); | ||
var testErrorMessage = "Test error message"; | ||
var testErrorCode = 1; | ||
dotdashpay.simulator.setResponse("ConfiguredProcessor", { | ||
errorMessage: testErrorMessage, | ||
errorCode: testErrorCode | ||
}, | ||
true); | ||
dotdashpay.payment.configureProcessor(args) | ||
.onConfiguredProcessor(function(response) { | ||
fail(null, null, "This example should only have an onError callback event, not ConfiguredProcessor"); | ||
}) | ||
.onError(function(errorData) { | ||
assert.equal(testErrorMessage, errorData.errorMessage, | ||
"Simulator error message was not returned correctly"); | ||
assert.equal(testErrorCode, errorData.errorCode, | ||
"Simulator error code was not returned correctly"); | ||
dotdashpay.simulator.resetAllResponses(); | ||
done(); | ||
}); | ||
}); | ||
it("should be able to specify an error response with the simulator", function(done) { | ||
this.timeout(10000); | ||
var testErrorMessage = "Test error message"; | ||
var testErrorCode = 1; | ||
dotdashpay.simulator.setResponse("ConfiguredProcessor", { | ||
errorMessage: testErrorMessage, | ||
errorCode: testErrorCode | ||
}, | ||
true); | ||
dotdashpay.payment.configureProcessor(args) | ||
.onConfiguredProcessor(function(response) { | ||
fail(null, null, "This example should only have an onError callback event, not ConfiguredProcessor"); | ||
}) | ||
.onError(function(errorData) { | ||
assert.equal(testErrorMessage, errorData.errorMessage, | ||
"Simulator error message was not returned correctly"); | ||
assert.equal(testErrorCode, errorData.errorCode, | ||
"Simulator error code was not returned correctly"); | ||
dotdashpay.simulator.resetAllResponses(); | ||
done(); | ||
}); | ||
}); | ||
it("should be able to specify a particular response from the simulator", function(done) { | ||
this.timeout(10000); | ||
// need a string value that we can overwrite | ||
var newVals = {}; | ||
it("should be able to specify a particular response from the simulator", function(done) { | ||
this.timeout(10000); | ||
// need a string value that we can overwrite | ||
var newVals = {}; | ||
dotdashpay.simulator.setResponse("ConfiguredProcessor", newVals); | ||
dotdashpay.simulator.setResponse("ConfiguredProcessor", newVals); | ||
dotdashpay.payment.configureProcessor(args) | ||
.onConfiguredProcessor(function(response) { | ||
_.each(newVals, function(val, key) { | ||
assert.deepEqual(response[key], val); | ||
}); | ||
done(); | ||
}); | ||
dotdashpay.payment.configureProcessor(args) | ||
.onConfiguredProcessor(function(response) { | ||
_.each(newVals, function(val, key) { | ||
assert.deepEqual(response[key], val); | ||
}); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); |
@@ -5,2 +5,3 @@ /** | ||
var _ = require("lodash"); | ||
@@ -14,81 +15,77 @@ var assert = require('chai').assert; | ||
var args = { | ||
essid: "Network Name", | ||
password: "wifi_password", | ||
username: "wifi_username", | ||
x509cert: "308202123082017b02020dfa300d06092a864886f70d010105050030819b310b3009060355040613024a50310e300c06035504081305546f6b796f3110300e060355040713074368756f2d6b753111300f060355040a13084672616e6b34444431183016060355040b130f5765624365727420537570706f7274311830160603550403130f4672616e6b344444205765622043413123302106092a864886f70d0109011614737570706f7274406672616e6b3464642e636f6d301e170d3132303832323035323635345a170d3137303832313035323635345a304a310b3009060355040613024a50310e300c06035504080c05546f6b796f3111300f060355040a0c084672616e6b3444443118301606035504030c0f7777772e6578616d706c652e636f6d305c300d06092a864886f70d0101010500034b0030480241009bfc6690798442bbab13fd2b7bf8de1512e5f193e3068a7bb8b1e19e26bb9501bfe730ed648502dd1569a834b006ec3f353c1e1b2b8ffa8f001bdf07c6ac53070203010001300d06092a864886f70d01010505000381810014b64cbb817933e671a4da516fcb081d8d60ecbc18c7734759b1f22048bb61fafc4dad898dd121ebd5d8e5bad6a636fd745083b60fc71ddf7de52e817f45e09fe23e79eed73031c72072d9582e2afe125a3445a119087c89475f4a95be23214a5372da2a052f2ec970f65bfafddfb431b2c14a9c062543a1e6b41e7f869b16400a", | ||
staticIp: "192.168.1.128", | ||
staticSubnetMask: "255.255.255.0", | ||
staticGateway: "192.168.1.1", | ||
staticDns: "8.8.8.8", | ||
saveConfiguration: true, | ||
autoReconnect: true, | ||
essid: "Network Name", | ||
password: "wifi_password", | ||
username: "wifi_username", | ||
x509cert: "308202123082017b02020dfa300d06092a864886f70d010105050030819b310b3009060355040613024a50310e300c06035504081305546f6b796f3110300e060355040713074368756f2d6b753111300f060355040a13084672616e6b34444431183016060355040b130f5765624365727420537570706f7274311830160603550403130f4672616e6b344444205765622043413123302106092a864886f70d0109011614737570706f7274406672616e6b3464642e636f6d301e170d3132303832323035323635345a170d3137303832313035323635345a304a310b3009060355040613024a50310e300c06035504080c05546f6b796f3111300f060355040a0c084672616e6b3444443118301606035504030c0f7777772e6578616d706c652e636f6d305c300d06092a864886f70d0101010500034b0030480241009bfc6690798442bbab13fd2b7bf8de1512e5f193e3068a7bb8b1e19e26bb9501bfe730ed648502dd1569a834b006ec3f353c1e1b2b8ffa8f001bdf07c6ac53070203010001300d06092a864886f70d01010505000381810014b64cbb817933e671a4da516fcb081d8d60ecbc18c7734759b1f22048bb61fafc4dad898dd121ebd5d8e5bad6a636fd745083b60fc71ddf7de52e817f45e09fe23e79eed73031c72072d9582e2afe125a3445a119087c89475f4a95be23214a5372da2a052f2ec970f65bfafddfb431b2c14a9c062543a1e6b41e7f869b16400a", | ||
staticIp: "192.168.1.128", | ||
staticSubnetMask: "255.255.255.0", | ||
staticGateway: "192.168.1.1", | ||
staticDns: "8.8.8.8", | ||
saveConfiguration: true, | ||
autoReconnect: true, | ||
}; | ||
describe("Hardware", function() { | ||
describe("configureWifi", function() { | ||
beforeEach(function() { | ||
dotdashpay._reset(); | ||
dotdashpay.setup({ | ||
simulate: true | ||
}); | ||
describe("configureWifi", function() { | ||
beforeEach(function() { | ||
dotdashpay._reset(); | ||
dotdashpay.setup({ simulate: true }); | ||
}); | ||
it("should have no undefined fields", function(done) { | ||
this.timeout(10000); | ||
var callbacksVisited = 0; | ||
dotdashpay.hardware.configureWifi(args) | ||
.onConfiguredWifi(function(response) { | ||
console.log("Received onConfiguredWifi response", JSON.stringify(response)); | ||
callbacksVisited++; | ||
assert.equal(callbacksVisited, 1, "Not all callbacks were called") | ||
done(); | ||
}) | ||
.onError(function(errorData) { | ||
console.log("Error", JSON.stringify(errorData)); | ||
fail(null, null, "This example should never return an error"); | ||
}); | ||
it("should have no undefined fields", function(done) { | ||
this.timeout(10000); | ||
var callbacksVisited = 0; | ||
}); | ||
dotdashpay.hardware.configureWifi(args) | ||
.onConfiguredWifi(function(response) { | ||
callbacksVisited++; | ||
assert.equal(callbacksVisited, 1, "Not all callbacks were called") | ||
done(); | ||
}) | ||
.onError(function(errorData) { | ||
if (errorData.errorCode == "") { | ||
console.log("Error: " + errorData.errorMessage); | ||
} | ||
fail(null, null, "This example should never return an error"); | ||
}); | ||
it("should be able to specify an error response with the simulator", function(done) { | ||
this.timeout(10000); | ||
var testErrorMessage = "Test error message"; | ||
var testErrorCode = 1; | ||
dotdashpay.simulator.setResponse("ConfiguredWifi", { | ||
errorMessage: testErrorMessage, | ||
errorCode: testErrorCode | ||
}, | ||
true); | ||
dotdashpay.hardware.configureWifi(args) | ||
.onConfiguredWifi(function(response) { | ||
fail(null, null, "This example should only have an onError callback event, not ConfiguredWifi"); | ||
}) | ||
.onError(function(errorData) { | ||
assert.equal(testErrorMessage, errorData.errorMessage, | ||
"Simulator error message was not returned correctly"); | ||
assert.equal(testErrorCode, errorData.errorCode, | ||
"Simulator error code was not returned correctly"); | ||
dotdashpay.simulator.resetAllResponses(); | ||
done(); | ||
}); | ||
}); | ||
it("should be able to specify an error response with the simulator", function(done) { | ||
this.timeout(10000); | ||
var testErrorMessage = "Test error message"; | ||
var testErrorCode = 1; | ||
dotdashpay.simulator.setResponse("ConfiguredWifi", { | ||
errorMessage: testErrorMessage, | ||
errorCode: testErrorCode | ||
}, | ||
true); | ||
dotdashpay.hardware.configureWifi(args) | ||
.onConfiguredWifi(function(response) { | ||
fail(null, null, "This example should only have an onError callback event, not ConfiguredWifi"); | ||
}) | ||
.onError(function(errorData) { | ||
assert.equal(testErrorMessage, errorData.errorMessage, | ||
"Simulator error message was not returned correctly"); | ||
assert.equal(testErrorCode, errorData.errorCode, | ||
"Simulator error code was not returned correctly"); | ||
dotdashpay.simulator.resetAllResponses(); | ||
done(); | ||
}); | ||
}); | ||
it("should be able to specify a particular response from the simulator", function(done) { | ||
this.timeout(10000); | ||
// need a string value that we can overwrite | ||
var newVals = {}; | ||
it("should be able to specify a particular response from the simulator", function(done) { | ||
this.timeout(10000); | ||
// need a string value that we can overwrite | ||
var newVals = {}; | ||
dotdashpay.simulator.setResponse("ConfiguredWifi", newVals); | ||
dotdashpay.simulator.setResponse("ConfiguredWifi", newVals); | ||
dotdashpay.hardware.configureWifi(args) | ||
.onConfiguredWifi(function(response) { | ||
_.each(newVals, function(val, key) { | ||
assert.deepEqual(response[key], val); | ||
}); | ||
done(); | ||
}); | ||
dotdashpay.hardware.configureWifi(args) | ||
.onConfiguredWifi(function(response) { | ||
_.each(newVals, function(val, key) { | ||
assert.deepEqual(response[key], val); | ||
}); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); |
@@ -5,2 +5,3 @@ /** | ||
var _ = require("lodash"); | ||
@@ -16,72 +17,68 @@ var assert = require('chai').assert; | ||
describe("Hardware", function() { | ||
describe("getConnectedPeripherals", function() { | ||
beforeEach(function() { | ||
dotdashpay._reset(); | ||
dotdashpay.setup({ | ||
simulate: true | ||
}); | ||
describe("getConnectedPeripherals", function() { | ||
beforeEach(function() { | ||
dotdashpay._reset(); | ||
dotdashpay.setup({ simulate: true }); | ||
}); | ||
it("should have no undefined fields", function(done) { | ||
this.timeout(10000); | ||
var callbacksVisited = 0; | ||
dotdashpay.hardware.getConnectedPeripherals(args) | ||
.onRetrievedConnectedPeripherals(function(response) { | ||
console.log("Received onRetrievedConnectedPeripherals response", JSON.stringify(response)); | ||
var attachedValidPeriphs = response.attachedValidPeriphs; // e.g. [[u'MagTekSureSwipe21040145', u'...']] | ||
assert.isDefined(attachedValidPeriphs); | ||
var attachedErrorPeriphs = response.attachedErrorPeriphs; // [[]] | ||
assert.isDefined(attachedErrorPeriphs); | ||
callbacksVisited++; | ||
assert.equal(callbacksVisited, 1, "Not all callbacks were called") | ||
done(); | ||
}) | ||
.onError(function(errorData) { | ||
console.log("Error", JSON.stringify(errorData)); | ||
fail(null, null, "This example should never return an error"); | ||
}); | ||
it("should have no undefined fields", function(done) { | ||
this.timeout(10000); | ||
var callbacksVisited = 0; | ||
}); | ||
dotdashpay.hardware.getConnectedPeripherals(args) | ||
.onRetrievedConnectedPeripherals(function(response) { | ||
var attachedValidPeriphs = response.attachedValidPeriphs; // attachedValidPeriphs = [[u'MagTekSureSwipe21040145', u'...']] | ||
assert.isDefined(attachedValidPeriphs); | ||
var attachedErrorPeriphs = response.attachedErrorPeriphs; // attachedErrorPeriphs = [[]] | ||
assert.isDefined(attachedErrorPeriphs); | ||
callbacksVisited++; | ||
assert.equal(callbacksVisited, 1, "Not all callbacks were called") | ||
done(); | ||
}) | ||
.onError(function(errorData) { | ||
if (errorData.errorCode == "") { | ||
console.log("Error: " + errorData.errorMessage); | ||
} | ||
fail(null, null, "This example should never return an error"); | ||
}); | ||
it("should be able to specify an error response with the simulator", function(done) { | ||
this.timeout(10000); | ||
var testErrorMessage = "Test error message"; | ||
var testErrorCode = 1; | ||
dotdashpay.simulator.setResponse("RetrievedConnectedPeripherals", { | ||
errorMessage: testErrorMessage, | ||
errorCode: testErrorCode | ||
}, | ||
true); | ||
dotdashpay.hardware.getConnectedPeripherals(args) | ||
.onRetrievedConnectedPeripherals(function(response) { | ||
fail(null, null, "This example should only have an onError callback event, not RetrievedConnectedPeripherals"); | ||
}) | ||
.onError(function(errorData) { | ||
assert.equal(testErrorMessage, errorData.errorMessage, | ||
"Simulator error message was not returned correctly"); | ||
assert.equal(testErrorCode, errorData.errorCode, | ||
"Simulator error code was not returned correctly"); | ||
dotdashpay.simulator.resetAllResponses(); | ||
done(); | ||
}); | ||
}); | ||
it("should be able to specify an error response with the simulator", function(done) { | ||
this.timeout(10000); | ||
var testErrorMessage = "Test error message"; | ||
var testErrorCode = 1; | ||
dotdashpay.simulator.setResponse("RetrievedConnectedPeripherals", { | ||
errorMessage: testErrorMessage, | ||
errorCode: testErrorCode | ||
}, | ||
true); | ||
dotdashpay.hardware.getConnectedPeripherals(args) | ||
.onRetrievedConnectedPeripherals(function(response) { | ||
fail(null, null, "This example should only have an onError callback event, not RetrievedConnectedPeripherals"); | ||
}) | ||
.onError(function(errorData) { | ||
assert.equal(testErrorMessage, errorData.errorMessage, | ||
"Simulator error message was not returned correctly"); | ||
assert.equal(testErrorCode, errorData.errorCode, | ||
"Simulator error code was not returned correctly"); | ||
dotdashpay.simulator.resetAllResponses(); | ||
done(); | ||
}); | ||
}); | ||
it("should be able to specify a particular response from the simulator", function(done) { | ||
this.timeout(10000); | ||
// need a string value that we can overwrite | ||
var newVals = {}; | ||
it("should be able to specify a particular response from the simulator", function(done) { | ||
this.timeout(10000); | ||
// need a string value that we can overwrite | ||
var newVals = {}; | ||
dotdashpay.simulator.setResponse("RetrievedConnectedPeripherals", newVals); | ||
dotdashpay.simulator.setResponse("RetrievedConnectedPeripherals", newVals); | ||
dotdashpay.hardware.getConnectedPeripherals(args) | ||
.onRetrievedConnectedPeripherals(function(response) { | ||
_.each(newVals, function(val, key) { | ||
assert.deepEqual(response[key], val); | ||
}); | ||
done(); | ||
}); | ||
dotdashpay.hardware.getConnectedPeripherals(args) | ||
.onRetrievedConnectedPeripherals(function(response) { | ||
_.each(newVals, function(val, key) { | ||
assert.deepEqual(response[key], val); | ||
}); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); |
@@ -5,2 +5,3 @@ /** | ||
var _ = require("lodash"); | ||
@@ -14,76 +15,72 @@ var assert = require('chai').assert; | ||
var args = { | ||
token: "aeac1bc8f0735e4283305652ab", | ||
token: "aeac1bc8f0735e4283305652ab", | ||
}; | ||
describe("Information", function() { | ||
describe("getCustomerId", function() { | ||
beforeEach(function() { | ||
dotdashpay._reset(); | ||
dotdashpay.setup({ | ||
simulate: true | ||
}); | ||
describe("getCustomerId", function() { | ||
beforeEach(function() { | ||
dotdashpay._reset(); | ||
dotdashpay.setup({ simulate: true }); | ||
}); | ||
it("should have no undefined fields", function(done) { | ||
this.timeout(10000); | ||
var callbacksVisited = 0; | ||
dotdashpay.information.getCustomerId(args) | ||
.onRetrievedCustomerId(function(response) { | ||
console.log("Received onRetrievedCustomerId response", JSON.stringify(response)); | ||
var customerId = response.customerId; // e.g. "2DAuJMBrMyaC" | ||
assert.isDefined(customerId); | ||
callbacksVisited++; | ||
assert.equal(callbacksVisited, 1, "Not all callbacks were called") | ||
done(); | ||
}) | ||
.onError(function(errorData) { | ||
console.log("Error", JSON.stringify(errorData)); | ||
fail(null, null, "This example should never return an error"); | ||
}); | ||
it("should have no undefined fields", function(done) { | ||
this.timeout(10000); | ||
var callbacksVisited = 0; | ||
}); | ||
dotdashpay.information.getCustomerId(args) | ||
.onRetrievedCustomerId(function(response) { | ||
var customerId = response.customerId; // customerId = "2DAuJMBrMyaC" | ||
assert.isDefined(customerId); | ||
callbacksVisited++; | ||
assert.equal(callbacksVisited, 1, "Not all callbacks were called") | ||
done(); | ||
}) | ||
.onError(function(errorData) { | ||
if (errorData.errorCode == "") { | ||
console.log("Error: " + errorData.errorMessage); | ||
} | ||
fail(null, null, "This example should never return an error"); | ||
}); | ||
it("should be able to specify an error response with the simulator", function(done) { | ||
this.timeout(10000); | ||
var testErrorMessage = "Test error message"; | ||
var testErrorCode = 1; | ||
dotdashpay.simulator.setResponse("RetrievedCustomerId", { | ||
errorMessage: testErrorMessage, | ||
errorCode: testErrorCode | ||
}, | ||
true); | ||
dotdashpay.information.getCustomerId(args) | ||
.onRetrievedCustomerId(function(response) { | ||
fail(null, null, "This example should only have an onError callback event, not RetrievedCustomerId"); | ||
}) | ||
.onError(function(errorData) { | ||
assert.equal(testErrorMessage, errorData.errorMessage, | ||
"Simulator error message was not returned correctly"); | ||
assert.equal(testErrorCode, errorData.errorCode, | ||
"Simulator error code was not returned correctly"); | ||
dotdashpay.simulator.resetAllResponses(); | ||
done(); | ||
}); | ||
}); | ||
it("should be able to specify an error response with the simulator", function(done) { | ||
this.timeout(10000); | ||
var testErrorMessage = "Test error message"; | ||
var testErrorCode = 1; | ||
dotdashpay.simulator.setResponse("RetrievedCustomerId", { | ||
errorMessage: testErrorMessage, | ||
errorCode: testErrorCode | ||
}, | ||
true); | ||
dotdashpay.information.getCustomerId(args) | ||
.onRetrievedCustomerId(function(response) { | ||
fail(null, null, "This example should only have an onError callback event, not RetrievedCustomerId"); | ||
}) | ||
.onError(function(errorData) { | ||
assert.equal(testErrorMessage, errorData.errorMessage, | ||
"Simulator error message was not returned correctly"); | ||
assert.equal(testErrorCode, errorData.errorCode, | ||
"Simulator error code was not returned correctly"); | ||
dotdashpay.simulator.resetAllResponses(); | ||
done(); | ||
}); | ||
}); | ||
it("should be able to specify a particular response from the simulator", function(done) { | ||
this.timeout(10000); | ||
// need a string value that we can overwrite | ||
var newVals = { | ||
customerId: "2DAuJMBrMyaC" + "-changed", | ||
}; | ||
it("should be able to specify a particular response from the simulator", function(done) { | ||
this.timeout(10000); | ||
// need a string value that we can overwrite | ||
var newVals = { | ||
customerId: "2DAuJMBrMyaC" + "-changed", | ||
}; | ||
dotdashpay.simulator.setResponse("RetrievedCustomerId", newVals); | ||
dotdashpay.simulator.setResponse("RetrievedCustomerId", newVals); | ||
dotdashpay.information.getCustomerId(args) | ||
.onRetrievedCustomerId(function(response) { | ||
_.each(newVals, function(val, key) { | ||
assert.deepEqual(response[key], val); | ||
}); | ||
done(); | ||
}); | ||
dotdashpay.information.getCustomerId(args) | ||
.onRetrievedCustomerId(function(response) { | ||
_.each(newVals, function(val, key) { | ||
assert.deepEqual(response[key], val); | ||
}); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); |
@@ -5,2 +5,3 @@ /** | ||
var _ = require("lodash"); | ||
@@ -16,74 +17,70 @@ var assert = require('chai').assert; | ||
describe("Hardware", function() { | ||
describe("getDatalinkStatus", function() { | ||
beforeEach(function() { | ||
dotdashpay._reset(); | ||
dotdashpay.setup({ | ||
simulate: true | ||
}); | ||
describe("getDatalinkStatus", function() { | ||
beforeEach(function() { | ||
dotdashpay._reset(); | ||
dotdashpay.setup({ simulate: true }); | ||
}); | ||
it("should have no undefined fields", function(done) { | ||
this.timeout(10000); | ||
var callbacksVisited = 0; | ||
dotdashpay.hardware.getDatalinkStatus(args) | ||
.onRetrievedDatalinkStatus(function(response) { | ||
console.log("Received onRetrievedDatalinkStatus response", JSON.stringify(response)); | ||
var connected = response.connected; // e.g. true | ||
assert.isDefined(connected); | ||
var info = response.info; // "Human-readable description" | ||
assert.isDefined(info); | ||
callbacksVisited++; | ||
assert.equal(callbacksVisited, 1, "Not all callbacks were called") | ||
done(); | ||
}) | ||
.onError(function(errorData) { | ||
console.log("Error", JSON.stringify(errorData)); | ||
fail(null, null, "This example should never return an error"); | ||
}); | ||
it("should have no undefined fields", function(done) { | ||
this.timeout(10000); | ||
var callbacksVisited = 0; | ||
}); | ||
dotdashpay.hardware.getDatalinkStatus(args) | ||
.onRetrievedDatalinkStatus(function(response) { | ||
var connected = response.connected; // connected = true | ||
assert.isDefined(connected); | ||
var info = response.info; // info = "Human-readable description" | ||
assert.isDefined(info); | ||
callbacksVisited++; | ||
assert.equal(callbacksVisited, 1, "Not all callbacks were called") | ||
done(); | ||
}) | ||
.onError(function(errorData) { | ||
if (errorData.errorCode == "") { | ||
console.log("Error: " + errorData.errorMessage); | ||
} | ||
fail(null, null, "This example should never return an error"); | ||
}); | ||
it("should be able to specify an error response with the simulator", function(done) { | ||
this.timeout(10000); | ||
var testErrorMessage = "Test error message"; | ||
var testErrorCode = 1; | ||
dotdashpay.simulator.setResponse("RetrievedDatalinkStatus", { | ||
errorMessage: testErrorMessage, | ||
errorCode: testErrorCode | ||
}, | ||
true); | ||
dotdashpay.hardware.getDatalinkStatus(args) | ||
.onRetrievedDatalinkStatus(function(response) { | ||
fail(null, null, "This example should only have an onError callback event, not RetrievedDatalinkStatus"); | ||
}) | ||
.onError(function(errorData) { | ||
assert.equal(testErrorMessage, errorData.errorMessage, | ||
"Simulator error message was not returned correctly"); | ||
assert.equal(testErrorCode, errorData.errorCode, | ||
"Simulator error code was not returned correctly"); | ||
dotdashpay.simulator.resetAllResponses(); | ||
done(); | ||
}); | ||
}); | ||
it("should be able to specify an error response with the simulator", function(done) { | ||
this.timeout(10000); | ||
var testErrorMessage = "Test error message"; | ||
var testErrorCode = 1; | ||
dotdashpay.simulator.setResponse("RetrievedDatalinkStatus", { | ||
errorMessage: testErrorMessage, | ||
errorCode: testErrorCode | ||
}, | ||
true); | ||
dotdashpay.hardware.getDatalinkStatus(args) | ||
.onRetrievedDatalinkStatus(function(response) { | ||
fail(null, null, "This example should only have an onError callback event, not RetrievedDatalinkStatus"); | ||
}) | ||
.onError(function(errorData) { | ||
assert.equal(testErrorMessage, errorData.errorMessage, | ||
"Simulator error message was not returned correctly"); | ||
assert.equal(testErrorCode, errorData.errorCode, | ||
"Simulator error code was not returned correctly"); | ||
dotdashpay.simulator.resetAllResponses(); | ||
done(); | ||
}); | ||
}); | ||
it("should be able to specify a particular response from the simulator", function(done) { | ||
this.timeout(10000); | ||
// need a string value that we can overwrite | ||
var newVals = { | ||
info: "Human-readable description" + "-changed", | ||
}; | ||
it("should be able to specify a particular response from the simulator", function(done) { | ||
this.timeout(10000); | ||
// need a string value that we can overwrite | ||
var newVals = { | ||
info: "Human-readable description" + "-changed", | ||
}; | ||
dotdashpay.simulator.setResponse("RetrievedDatalinkStatus", newVals); | ||
dotdashpay.simulator.setResponse("RetrievedDatalinkStatus", newVals); | ||
dotdashpay.hardware.getDatalinkStatus(args) | ||
.onRetrievedDatalinkStatus(function(response) { | ||
_.each(newVals, function(val, key) { | ||
assert.deepEqual(response[key], val); | ||
}); | ||
done(); | ||
}); | ||
dotdashpay.hardware.getDatalinkStatus(args) | ||
.onRetrievedDatalinkStatus(function(response) { | ||
_.each(newVals, function(val, key) { | ||
assert.deepEqual(response[key], val); | ||
}); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); |
@@ -5,2 +5,3 @@ /** | ||
var _ = require("lodash"); | ||
@@ -16,78 +17,74 @@ var assert = require('chai').assert; | ||
describe("Hardware", function() { | ||
describe("getInternetStatus", function() { | ||
beforeEach(function() { | ||
dotdashpay._reset(); | ||
dotdashpay.setup({ | ||
simulate: true | ||
}); | ||
describe("getInternetStatus", function() { | ||
beforeEach(function() { | ||
dotdashpay._reset(); | ||
dotdashpay.setup({ simulate: true }); | ||
}); | ||
it("should have no undefined fields", function(done) { | ||
this.timeout(10000); | ||
var callbacksVisited = 0; | ||
dotdashpay.hardware.getInternetStatus(args) | ||
.onRetrievedInternetStatus(function(response) { | ||
console.log("Received onRetrievedInternetStatus response", JSON.stringify(response)); | ||
var connected = response.connected; // e.g. true | ||
assert.isDefined(connected); | ||
var info = response.info; // "Human-readable description" | ||
assert.isDefined(info); | ||
var connectedInterfaces = response.connectedInterfaces; // [[u'wifi', u'...']] | ||
assert.isDefined(connectedInterfaces); | ||
var ipAddresses = response.ipAddresses; // [[u'192.168.1.128', u'...']] | ||
assert.isDefined(ipAddresses); | ||
callbacksVisited++; | ||
assert.equal(callbacksVisited, 1, "Not all callbacks were called") | ||
done(); | ||
}) | ||
.onError(function(errorData) { | ||
console.log("Error", JSON.stringify(errorData)); | ||
fail(null, null, "This example should never return an error"); | ||
}); | ||
it("should have no undefined fields", function(done) { | ||
this.timeout(10000); | ||
var callbacksVisited = 0; | ||
}); | ||
dotdashpay.hardware.getInternetStatus(args) | ||
.onRetrievedInternetStatus(function(response) { | ||
var connected = response.connected; // connected = true | ||
assert.isDefined(connected); | ||
var info = response.info; // info = "Human-readable description" | ||
assert.isDefined(info); | ||
var connectedInterfaces = response.connectedInterfaces; // connectedInterfaces = [[u'wifi', u'...']] | ||
assert.isDefined(connectedInterfaces); | ||
var ipAddresses = response.ipAddresses; // ipAddresses = [[u'192.168.1.128', u'...']] | ||
assert.isDefined(ipAddresses); | ||
callbacksVisited++; | ||
assert.equal(callbacksVisited, 1, "Not all callbacks were called") | ||
done(); | ||
}) | ||
.onError(function(errorData) { | ||
if (errorData.errorCode == "") { | ||
console.log("Error: " + errorData.errorMessage); | ||
} | ||
fail(null, null, "This example should never return an error"); | ||
}); | ||
it("should be able to specify an error response with the simulator", function(done) { | ||
this.timeout(10000); | ||
var testErrorMessage = "Test error message"; | ||
var testErrorCode = 1; | ||
dotdashpay.simulator.setResponse("RetrievedInternetStatus", { | ||
errorMessage: testErrorMessage, | ||
errorCode: testErrorCode | ||
}, | ||
true); | ||
dotdashpay.hardware.getInternetStatus(args) | ||
.onRetrievedInternetStatus(function(response) { | ||
fail(null, null, "This example should only have an onError callback event, not RetrievedInternetStatus"); | ||
}) | ||
.onError(function(errorData) { | ||
assert.equal(testErrorMessage, errorData.errorMessage, | ||
"Simulator error message was not returned correctly"); | ||
assert.equal(testErrorCode, errorData.errorCode, | ||
"Simulator error code was not returned correctly"); | ||
dotdashpay.simulator.resetAllResponses(); | ||
done(); | ||
}); | ||
}); | ||
it("should be able to specify an error response with the simulator", function(done) { | ||
this.timeout(10000); | ||
var testErrorMessage = "Test error message"; | ||
var testErrorCode = 1; | ||
dotdashpay.simulator.setResponse("RetrievedInternetStatus", { | ||
errorMessage: testErrorMessage, | ||
errorCode: testErrorCode | ||
}, | ||
true); | ||
dotdashpay.hardware.getInternetStatus(args) | ||
.onRetrievedInternetStatus(function(response) { | ||
fail(null, null, "This example should only have an onError callback event, not RetrievedInternetStatus"); | ||
}) | ||
.onError(function(errorData) { | ||
assert.equal(testErrorMessage, errorData.errorMessage, | ||
"Simulator error message was not returned correctly"); | ||
assert.equal(testErrorCode, errorData.errorCode, | ||
"Simulator error code was not returned correctly"); | ||
dotdashpay.simulator.resetAllResponses(); | ||
done(); | ||
}); | ||
}); | ||
it("should be able to specify a particular response from the simulator", function(done) { | ||
this.timeout(10000); | ||
// need a string value that we can overwrite | ||
var newVals = { | ||
info: "Human-readable description" + "-changed", | ||
}; | ||
it("should be able to specify a particular response from the simulator", function(done) { | ||
this.timeout(10000); | ||
// need a string value that we can overwrite | ||
var newVals = { | ||
info: "Human-readable description" + "-changed", | ||
}; | ||
dotdashpay.simulator.setResponse("RetrievedInternetStatus", newVals); | ||
dotdashpay.simulator.setResponse("RetrievedInternetStatus", newVals); | ||
dotdashpay.hardware.getInternetStatus(args) | ||
.onRetrievedInternetStatus(function(response) { | ||
_.each(newVals, function(val, key) { | ||
assert.deepEqual(response[key], val); | ||
}); | ||
done(); | ||
}); | ||
dotdashpay.hardware.getInternetStatus(args) | ||
.onRetrievedInternetStatus(function(response) { | ||
_.each(newVals, function(val, key) { | ||
assert.deepEqual(response[key], val); | ||
}); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); |
@@ -5,2 +5,3 @@ /** | ||
var _ = require("lodash"); | ||
@@ -14,128 +15,125 @@ var assert = require('chai').assert; | ||
var args = { | ||
paymentDataId: "pdid-iPqy9F82v5qexbtz", | ||
cents: 128, | ||
currency: "USD", | ||
paymentDataId: "pdid-iPqy9F82v5qexbtz", | ||
cents: 128, | ||
currency: "USD", | ||
}; | ||
describe("Payment", function() { | ||
describe("preAuthorize", function() { | ||
beforeEach(function() { | ||
dotdashpay._reset(); | ||
dotdashpay.setup({ | ||
simulate: true | ||
}); | ||
describe("preAuthorize", function() { | ||
beforeEach(function() { | ||
dotdashpay._reset(); | ||
dotdashpay.setup({ simulate: true }); | ||
}); | ||
it("should have no undefined fields", function(done) { | ||
this.timeout(10000); | ||
var callbacksVisited = 0; | ||
dotdashpay.payment.preAuthorize(args) | ||
.onStartedPreAuthorizing(function(response) { | ||
console.log("Received onStartedPreAuthorizing response", JSON.stringify(response)); | ||
var paymentDataId = response.paymentDataId; // e.g. "pdid-iPqy9F82v5qexbtz" | ||
assert.isDefined(paymentDataId); | ||
var cents = response.cents; // 128 | ||
assert.isDefined(cents); | ||
var currency = response.currency; // "USD" | ||
assert.isDefined(currency); | ||
var livemode = response.livemode; // false | ||
assert.isDefined(livemode); | ||
callbacksVisited++; | ||
}) | ||
.onPreAuthorized(function(response) { | ||
console.log("Received onPreAuthorized response", JSON.stringify(response)); | ||
var status = response.status; // e.g. "SUCCESS" | ||
assert.isDefined(status); | ||
var paymentDataId = response.paymentDataId; // "pdid-iPqy9F82v5qexbtz" | ||
assert.isDefined(paymentDataId); | ||
var preauthId = response.preauthId; // "paut-Eo9YqkOTnmxt6EcL" | ||
assert.isDefined(preauthId); | ||
var info = response.info; // "Human-readable description" | ||
assert.isDefined(info); | ||
var customerId = response.customerId; // "2DAuJMBrMyaC" | ||
assert.isDefined(customerId); | ||
var merchantAccountId = response.merchantAccountId; // "merchantAccountNumber" | ||
assert.isDefined(merchantAccountId); | ||
var cardType = response.cardType; // "Visa" | ||
assert.isDefined(cardType); | ||
var last4 = response.last4; // "0000" | ||
assert.isDefined(last4); | ||
var commercial = response.commercial; // false | ||
assert.isDefined(commercial); | ||
var debit = response.debit; // false | ||
assert.isDefined(debit); | ||
var createdAt = response.createdAt; // "915148799.75" | ||
assert.isDefined(createdAt); | ||
var cents = response.cents; // 128 | ||
assert.isDefined(cents); | ||
var currency = response.currency; // "USD" | ||
assert.isDefined(currency); | ||
var livemode = response.livemode; // false | ||
assert.isDefined(livemode); | ||
var paymentType = response.paymentType; // "CARD" | ||
assert.isDefined(paymentType); | ||
callbacksVisited++; | ||
assert.equal(callbacksVisited, 2, "Not all callbacks were called") | ||
done(); | ||
}) | ||
.onError(function(errorData) { | ||
console.log("Error", JSON.stringify(errorData)); | ||
fail(null, null, "This example should never return an error"); | ||
}); | ||
it("should have no undefined fields", function(done) { | ||
this.timeout(10000); | ||
var callbacksVisited = 0; | ||
}); | ||
dotdashpay.payment.preAuthorize(args) | ||
.onStartedPreAuthorizing(function(response) { | ||
var paymentDataId = response.paymentDataId; // paymentDataId = "pdid-iPqy9F82v5qexbtz" | ||
assert.isDefined(paymentDataId); | ||
var cents = response.cents; // cents = 128 | ||
assert.isDefined(cents); | ||
var currency = response.currency; // currency = "USD" | ||
assert.isDefined(currency); | ||
var livemode = response.livemode; // livemode = false | ||
assert.isDefined(livemode); | ||
callbacksVisited++; | ||
}) | ||
.onPreAuthorized(function(response) { | ||
var status = response.status; // status = "SUCCESS" | ||
assert.isDefined(status); | ||
var paymentDataId = response.paymentDataId; // paymentDataId = "pdid-iPqy9F82v5qexbtz" | ||
assert.isDefined(paymentDataId); | ||
var preauthId = response.preauthId; // preauthId = "paut-Eo9YqkOTnmxt6EcL" | ||
assert.isDefined(preauthId); | ||
var info = response.info; // info = "Human-readable description" | ||
assert.isDefined(info); | ||
var customerId = response.customerId; // customerId = "2DAuJMBrMyaC" | ||
assert.isDefined(customerId); | ||
var merchantAccountId = response.merchantAccountId; // merchantAccountId = "merchantAccountNumber" | ||
assert.isDefined(merchantAccountId); | ||
var cardType = response.cardType; // cardType = "Visa" | ||
assert.isDefined(cardType); | ||
var last4 = response.last4; // last4 = "0000" | ||
assert.isDefined(last4); | ||
var commercial = response.commercial; // commercial = false | ||
assert.isDefined(commercial); | ||
var debit = response.debit; // debit = false | ||
assert.isDefined(debit); | ||
var createdAt = response.createdAt; // createdAt = "915148799.75" | ||
assert.isDefined(createdAt); | ||
var cents = response.cents; // cents = 128 | ||
assert.isDefined(cents); | ||
var currency = response.currency; // currency = "USD" | ||
assert.isDefined(currency); | ||
var livemode = response.livemode; // livemode = false | ||
assert.isDefined(livemode); | ||
var paymentType = response.paymentType; // paymentType = "CARD" | ||
assert.isDefined(paymentType); | ||
callbacksVisited++; | ||
assert.equal(callbacksVisited, 2, "Not all callbacks were called") | ||
done(); | ||
}) | ||
.onError(function(errorData) { | ||
if (errorData.errorCode == "") { | ||
console.log("Error: " + errorData.errorMessage); | ||
} | ||
fail(null, null, "This example should never return an error"); | ||
}); | ||
it("should be able to specify an error response with the simulator", function(done) { | ||
this.timeout(10000); | ||
var testErrorMessage = "Test error message"; | ||
var testErrorCode = 1; | ||
dotdashpay.simulator.setResponse("StartedPreAuthorizing", { | ||
errorMessage: testErrorMessage, | ||
errorCode: testErrorCode | ||
}, | ||
true); | ||
dotdashpay.payment.preAuthorize(args) | ||
.onStartedPreAuthorizing(function(response) { | ||
fail(null, null, "This example should only have an onError callback event, not StartedPreAuthorizing"); | ||
}) | ||
.onPreAuthorized(function(response) { | ||
fail(null, null, "This example should only have an onError callback event, not PreAuthorized"); | ||
}) | ||
.onError(function(errorData) { | ||
assert.equal(testErrorMessage, errorData.errorMessage, | ||
"Simulator error message was not returned correctly"); | ||
assert.equal(testErrorCode, errorData.errorCode, | ||
"Simulator error code was not returned correctly"); | ||
dotdashpay.simulator.resetAllResponses(); | ||
done(); | ||
}); | ||
}); | ||
it("should be able to specify an error response with the simulator", function(done) { | ||
this.timeout(10000); | ||
var testErrorMessage = "Test error message"; | ||
var testErrorCode = 1; | ||
dotdashpay.simulator.setResponse("StartedPreAuthorizing", { | ||
errorMessage: testErrorMessage, | ||
errorCode: testErrorCode | ||
}, | ||
true); | ||
dotdashpay.payment.preAuthorize(args) | ||
.onStartedPreAuthorizing(function(response) { | ||
fail(null, null, "This example should only have an onError callback event, not StartedPreAuthorizing"); | ||
}) | ||
.onPreAuthorized(function(response) { | ||
fail(null, null, "This example should only have an onError callback event, not PreAuthorized"); | ||
}) | ||
.onError(function(errorData) { | ||
assert.equal(testErrorMessage, errorData.errorMessage, | ||
"Simulator error message was not returned correctly"); | ||
assert.equal(testErrorCode, errorData.errorCode, | ||
"Simulator error code was not returned correctly"); | ||
dotdashpay.simulator.resetAllResponses(); | ||
done(); | ||
}); | ||
}); | ||
it("should be able to specify a particular response from the simulator", function(done) { | ||
this.timeout(10000); | ||
// need a string value that we can overwrite | ||
var newVals = { | ||
paymentDataId: "pdid-iPqy9F82v5qexbtz" + "-changed", | ||
preauthId: "paut-Eo9YqkOTnmxt6EcL" + "-changed", | ||
info: "Human-readable description" + "-changed", | ||
customerId: "2DAuJMBrMyaC" + "-changed", | ||
merchantAccountId: "merchantAccountNumber" + "-changed", | ||
cardType: "Visa" + "-changed", | ||
last4: "0000" + "-changed", | ||
createdAt: "915148799.75" + "-changed", | ||
currency: "USD" + "-changed", | ||
}; | ||
it("should be able to specify a particular response from the simulator", function(done) { | ||
this.timeout(10000); | ||
// need a string value that we can overwrite | ||
var newVals = { | ||
paymentDataId: "pdid-iPqy9F82v5qexbtz" + "-changed", | ||
preauthId: "paut-Eo9YqkOTnmxt6EcL" + "-changed", | ||
info: "Human-readable description" + "-changed", | ||
customerId: "2DAuJMBrMyaC" + "-changed", | ||
merchantAccountId: "merchantAccountNumber" + "-changed", | ||
cardType: "Visa" + "-changed", | ||
last4: "0000" + "-changed", | ||
createdAt: "915148799.75" + "-changed", | ||
currency: "USD" + "-changed", | ||
}; | ||
dotdashpay.simulator.setResponse("PreAuthorized", newVals); | ||
dotdashpay.simulator.setResponse("PreAuthorized", newVals); | ||
dotdashpay.payment.preAuthorize(args) | ||
.onPreAuthorized(function(response) { | ||
_.each(newVals, function(val, key) { | ||
assert.deepEqual(response[key], val); | ||
}); | ||
done(); | ||
}); | ||
dotdashpay.payment.preAuthorize(args) | ||
.onPreAuthorized(function(response) { | ||
_.each(newVals, function(val, key) { | ||
assert.deepEqual(response[key], val); | ||
}); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); |
@@ -5,2 +5,3 @@ /** | ||
var _ = require("lodash"); | ||
@@ -14,78 +15,74 @@ var assert = require('chai').assert; | ||
var args = { | ||
level: "DEBUG", | ||
level: "DEBUG", | ||
}; | ||
describe("Information", function() { | ||
describe("receiveLogs", function() { | ||
beforeEach(function() { | ||
dotdashpay._reset(); | ||
dotdashpay.setup({ | ||
simulate: true | ||
}); | ||
describe("receiveLogs", function() { | ||
beforeEach(function() { | ||
dotdashpay._reset(); | ||
dotdashpay.setup({ simulate: true }); | ||
}); | ||
it("should have no undefined fields", function(done) { | ||
this.timeout(10000); | ||
var callbacksVisited = 0; | ||
dotdashpay.information.receiveLogs(args) | ||
.onReceivedLogs(function(response) { | ||
console.log("Received onReceivedLogs response", JSON.stringify(response)); | ||
var logMessage = response.logMessage; // e.g. "The roof is on fire (you may need some water)." | ||
assert.isDefined(logMessage); | ||
var level = response.level; // "DEBUG" | ||
assert.isDefined(level); | ||
callbacksVisited++; | ||
assert.equal(callbacksVisited, 1, "Not all callbacks were called") | ||
done(); | ||
}) | ||
.onError(function(errorData) { | ||
console.log("Error", JSON.stringify(errorData)); | ||
fail(null, null, "This example should never return an error"); | ||
}); | ||
it("should have no undefined fields", function(done) { | ||
this.timeout(10000); | ||
var callbacksVisited = 0; | ||
}); | ||
dotdashpay.information.receiveLogs(args) | ||
.onReceivedLogs(function(response) { | ||
var logMessage = response.logMessage; // logMessage = "The roof is on fire (you may need some water)." | ||
assert.isDefined(logMessage); | ||
var level = response.level; // level = "DEBUG" | ||
assert.isDefined(level); | ||
callbacksVisited++; | ||
assert.equal(callbacksVisited, 1, "Not all callbacks were called") | ||
done(); | ||
}) | ||
.onError(function(errorData) { | ||
if (errorData.errorCode == "") { | ||
console.log("Error: " + errorData.errorMessage); | ||
} | ||
fail(null, null, "This example should never return an error"); | ||
}); | ||
it("should be able to specify an error response with the simulator", function(done) { | ||
this.timeout(10000); | ||
var testErrorMessage = "Test error message"; | ||
var testErrorCode = 1; | ||
dotdashpay.simulator.setResponse("ReceivedLogs", { | ||
errorMessage: testErrorMessage, | ||
errorCode: testErrorCode | ||
}, | ||
true); | ||
dotdashpay.information.receiveLogs(args) | ||
.onReceivedLogs(function(response) { | ||
fail(null, null, "This example should only have an onError callback event, not ReceivedLogs"); | ||
}) | ||
.onError(function(errorData) { | ||
assert.equal(testErrorMessage, errorData.errorMessage, | ||
"Simulator error message was not returned correctly"); | ||
assert.equal(testErrorCode, errorData.errorCode, | ||
"Simulator error code was not returned correctly"); | ||
dotdashpay.simulator.resetAllResponses(); | ||
done(); | ||
}); | ||
}); | ||
it("should be able to specify an error response with the simulator", function(done) { | ||
this.timeout(10000); | ||
var testErrorMessage = "Test error message"; | ||
var testErrorCode = 1; | ||
dotdashpay.simulator.setResponse("ReceivedLogs", { | ||
errorMessage: testErrorMessage, | ||
errorCode: testErrorCode | ||
}, | ||
true); | ||
dotdashpay.information.receiveLogs(args) | ||
.onReceivedLogs(function(response) { | ||
fail(null, null, "This example should only have an onError callback event, not ReceivedLogs"); | ||
}) | ||
.onError(function(errorData) { | ||
assert.equal(testErrorMessage, errorData.errorMessage, | ||
"Simulator error message was not returned correctly"); | ||
assert.equal(testErrorCode, errorData.errorCode, | ||
"Simulator error code was not returned correctly"); | ||
dotdashpay.simulator.resetAllResponses(); | ||
done(); | ||
}); | ||
}); | ||
it("should be able to specify a particular response from the simulator", function(done) { | ||
this.timeout(10000); | ||
// need a string value that we can overwrite | ||
var newVals = { | ||
logMessage: "The roof is on fire (you may need some water)." + "-changed", | ||
}; | ||
it("should be able to specify a particular response from the simulator", function(done) { | ||
this.timeout(10000); | ||
// need a string value that we can overwrite | ||
var newVals = { | ||
logMessage: "The roof is on fire (you may need some water)." + "-changed", | ||
}; | ||
dotdashpay.simulator.setResponse("ReceivedLogs", newVals); | ||
dotdashpay.simulator.setResponse("ReceivedLogs", newVals); | ||
dotdashpay.information.receiveLogs(args) | ||
.onReceivedLogs(function(response) { | ||
_.each(newVals, function(val, key) { | ||
assert.deepEqual(response[key], val); | ||
}); | ||
done(); | ||
}); | ||
dotdashpay.information.receiveLogs(args) | ||
.onReceivedLogs(function(response) { | ||
_.each(newVals, function(val, key) { | ||
assert.deepEqual(response[key], val); | ||
}); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); |
@@ -5,2 +5,3 @@ /** | ||
var _ = require("lodash"); | ||
@@ -14,91 +15,88 @@ var assert = require('chai').assert; | ||
var args = { | ||
useExistingData: false, | ||
useExistingDataSecondsWindow: 5, | ||
useExistingData: false, | ||
useExistingDataSecondsWindow: 5, | ||
}; | ||
describe("Hardware", function() { | ||
describe("receivePaymentData", function() { | ||
beforeEach(function() { | ||
dotdashpay._reset(); | ||
dotdashpay.setup({ | ||
simulate: true | ||
}); | ||
describe("receivePaymentData", function() { | ||
beforeEach(function() { | ||
dotdashpay._reset(); | ||
dotdashpay.setup({ simulate: true }); | ||
}); | ||
it("should have no undefined fields", function(done) { | ||
this.timeout(10000); | ||
var callbacksVisited = 0; | ||
dotdashpay.hardware.receivePaymentData(args) | ||
.onStartedReceivingPaymentData(function(response) { | ||
console.log("Received onStartedReceivingPaymentData response", JSON.stringify(response)); | ||
var peripheralName = response.peripheralName; // e.g. "MagTekSureSwipe21040145" | ||
assert.isDefined(peripheralName); | ||
callbacksVisited++; | ||
}) | ||
.onReceivedPaymentData(function(response) { | ||
console.log("Received onReceivedPaymentData response", JSON.stringify(response)); | ||
var paymentDataId = response.paymentDataId; // e.g. "pdid-iPqy9F82v5qexbtz" | ||
assert.isDefined(paymentDataId); | ||
var token = response.token; // "aeac1bc8f0735e4283305652ab" | ||
assert.isDefined(token); | ||
var peripheralName = response.peripheralName; // "MagTekSureSwipe21040145" | ||
assert.isDefined(peripheralName); | ||
callbacksVisited++; | ||
assert.equal(callbacksVisited, 2, "Not all callbacks were called") | ||
done(); | ||
}) | ||
.onError(function(errorData) { | ||
console.log("Error", JSON.stringify(errorData)); | ||
fail(null, null, "This example should never return an error"); | ||
}); | ||
it("should have no undefined fields", function(done) { | ||
this.timeout(10000); | ||
var callbacksVisited = 0; | ||
}); | ||
dotdashpay.hardware.receivePaymentData(args) | ||
.onStartedReceivingPaymentData(function(response) { | ||
var peripheralName = response.peripheralName; // peripheralName = "MagTekSureSwipe21040145" | ||
assert.isDefined(peripheralName); | ||
callbacksVisited++; | ||
}) | ||
.onReceivedPaymentData(function(response) { | ||
var paymentDataId = response.paymentDataId; // paymentDataId = "pdid-iPqy9F82v5qexbtz" | ||
assert.isDefined(paymentDataId); | ||
var token = response.token; // token = "aeac1bc8f0735e4283305652ab" | ||
assert.isDefined(token); | ||
var peripheralName = response.peripheralName; // peripheralName = "MagTekSureSwipe21040145" | ||
assert.isDefined(peripheralName); | ||
callbacksVisited++; | ||
assert.equal(callbacksVisited, 2, "Not all callbacks were called") | ||
done(); | ||
}) | ||
.onError(function(errorData) { | ||
if (errorData.errorCode == "") { | ||
console.log("Error: " + errorData.errorMessage); | ||
} | ||
fail(null, null, "This example should never return an error"); | ||
}); | ||
it("should be able to specify an error response with the simulator", function(done) { | ||
this.timeout(10000); | ||
var testErrorMessage = "Test error message"; | ||
var testErrorCode = 1; | ||
dotdashpay.simulator.setResponse("StartedReceivingPaymentData", { | ||
errorMessage: testErrorMessage, | ||
errorCode: testErrorCode | ||
}, | ||
true); | ||
dotdashpay.hardware.receivePaymentData(args) | ||
.onStartedReceivingPaymentData(function(response) { | ||
fail(null, null, "This example should only have an onError callback event, not StartedReceivingPaymentData"); | ||
}) | ||
.onReceivedPaymentData(function(response) { | ||
fail(null, null, "This example should only have an onError callback event, not ReceivedPaymentData"); | ||
}) | ||
.onError(function(errorData) { | ||
assert.equal(testErrorMessage, errorData.errorMessage, | ||
"Simulator error message was not returned correctly"); | ||
assert.equal(testErrorCode, errorData.errorCode, | ||
"Simulator error code was not returned correctly"); | ||
dotdashpay.simulator.resetAllResponses(); | ||
done(); | ||
}); | ||
}); | ||
it("should be able to specify an error response with the simulator", function(done) { | ||
this.timeout(10000); | ||
var testErrorMessage = "Test error message"; | ||
var testErrorCode = 1; | ||
dotdashpay.simulator.setResponse("StartedReceivingPaymentData", { | ||
errorMessage: testErrorMessage, | ||
errorCode: testErrorCode | ||
}, | ||
true); | ||
dotdashpay.hardware.receivePaymentData(args) | ||
.onStartedReceivingPaymentData(function(response) { | ||
fail(null, null, "This example should only have an onError callback event, not StartedReceivingPaymentData"); | ||
}) | ||
.onReceivedPaymentData(function(response) { | ||
fail(null, null, "This example should only have an onError callback event, not ReceivedPaymentData"); | ||
}) | ||
.onError(function(errorData) { | ||
assert.equal(testErrorMessage, errorData.errorMessage, | ||
"Simulator error message was not returned correctly"); | ||
assert.equal(testErrorCode, errorData.errorCode, | ||
"Simulator error code was not returned correctly"); | ||
dotdashpay.simulator.resetAllResponses(); | ||
done(); | ||
}); | ||
}); | ||
it("should be able to specify a particular response from the simulator", function(done) { | ||
this.timeout(10000); | ||
// need a string value that we can overwrite | ||
var newVals = { | ||
paymentDataId: "pdid-iPqy9F82v5qexbtz" + "-changed", | ||
token: "aeac1bc8f0735e4283305652ab" + "-changed", | ||
peripheralName: "MagTekSureSwipe21040145" + "-changed", | ||
}; | ||
it("should be able to specify a particular response from the simulator", function(done) { | ||
this.timeout(10000); | ||
// need a string value that we can overwrite | ||
var newVals = { | ||
paymentDataId: "pdid-iPqy9F82v5qexbtz" + "-changed", | ||
token: "aeac1bc8f0735e4283305652ab" + "-changed", | ||
peripheralName: "MagTekSureSwipe21040145" + "-changed", | ||
}; | ||
dotdashpay.simulator.setResponse("ReceivedPaymentData", newVals); | ||
dotdashpay.simulator.setResponse("ReceivedPaymentData", newVals); | ||
dotdashpay.hardware.receivePaymentData(args) | ||
.onReceivedPaymentData(function(response) { | ||
_.each(newVals, function(val, key) { | ||
assert.deepEqual(response[key], val); | ||
}); | ||
done(); | ||
}); | ||
dotdashpay.hardware.receivePaymentData(args) | ||
.onReceivedPaymentData(function(response) { | ||
_.each(newVals, function(val, key) { | ||
assert.deepEqual(response[key], val); | ||
}); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); |
@@ -5,2 +5,3 @@ /** | ||
var _ = require("lodash"); | ||
@@ -14,149 +15,148 @@ var assert = require('chai').assert; | ||
var args = { | ||
cents: 128, | ||
currency: "USD", | ||
useExistingData: false, | ||
useExistingDataSecondsWindow: 5, | ||
cents: 128, | ||
currency: "USD", | ||
useExistingData: false, | ||
useExistingDataSecondsWindow: 5, | ||
}; | ||
describe("Payment", function() { | ||
describe("receivePaymentDataThenPreAuthorize", function() { | ||
beforeEach(function() { | ||
dotdashpay._reset(); | ||
dotdashpay.setup({ | ||
simulate: true | ||
}); | ||
describe("receivePaymentDataThenPreAuthorize", function() { | ||
beforeEach(function() { | ||
dotdashpay._reset(); | ||
dotdashpay.setup({ simulate: true }); | ||
}); | ||
it("should have no undefined fields", function(done) { | ||
this.timeout(10000); | ||
var callbacksVisited = 0; | ||
dotdashpay.payment.receivePaymentDataThenPreAuthorize(args) | ||
.onStartedReceivingPaymentData(function(response) { | ||
console.log("Received onStartedReceivingPaymentData response", JSON.stringify(response)); | ||
var peripheralName = response.peripheralName; // e.g. "MagTekSureSwipe21040145" | ||
assert.isDefined(peripheralName); | ||
callbacksVisited++; | ||
}) | ||
.onReceivedPaymentData(function(response) { | ||
console.log("Received onReceivedPaymentData response", JSON.stringify(response)); | ||
var paymentDataId = response.paymentDataId; // e.g. "pdid-iPqy9F82v5qexbtz" | ||
assert.isDefined(paymentDataId); | ||
var token = response.token; // "aeac1bc8f0735e4283305652ab" | ||
assert.isDefined(token); | ||
var peripheralName = response.peripheralName; // "MagTekSureSwipe21040145" | ||
assert.isDefined(peripheralName); | ||
callbacksVisited++; | ||
}) | ||
.onStartedPreAuthorizing(function(response) { | ||
console.log("Received onStartedPreAuthorizing response", JSON.stringify(response)); | ||
var paymentDataId = response.paymentDataId; // e.g. "pdid-iPqy9F82v5qexbtz" | ||
assert.isDefined(paymentDataId); | ||
var cents = response.cents; // 128 | ||
assert.isDefined(cents); | ||
var currency = response.currency; // "USD" | ||
assert.isDefined(currency); | ||
var livemode = response.livemode; // false | ||
assert.isDefined(livemode); | ||
callbacksVisited++; | ||
}) | ||
.onPreAuthorized(function(response) { | ||
console.log("Received onPreAuthorized response", JSON.stringify(response)); | ||
var status = response.status; // e.g. "SUCCESS" | ||
assert.isDefined(status); | ||
var paymentDataId = response.paymentDataId; // "pdid-iPqy9F82v5qexbtz" | ||
assert.isDefined(paymentDataId); | ||
var preauthId = response.preauthId; // "paut-Eo9YqkOTnmxt6EcL" | ||
assert.isDefined(preauthId); | ||
var info = response.info; // "Human-readable description" | ||
assert.isDefined(info); | ||
var customerId = response.customerId; // "2DAuJMBrMyaC" | ||
assert.isDefined(customerId); | ||
var merchantAccountId = response.merchantAccountId; // "merchantAccountNumber" | ||
assert.isDefined(merchantAccountId); | ||
var cardType = response.cardType; // "Visa" | ||
assert.isDefined(cardType); | ||
var last4 = response.last4; // "0000" | ||
assert.isDefined(last4); | ||
var commercial = response.commercial; // false | ||
assert.isDefined(commercial); | ||
var debit = response.debit; // false | ||
assert.isDefined(debit); | ||
var createdAt = response.createdAt; // "915148799.75" | ||
assert.isDefined(createdAt); | ||
var cents = response.cents; // 128 | ||
assert.isDefined(cents); | ||
var currency = response.currency; // "USD" | ||
assert.isDefined(currency); | ||
var livemode = response.livemode; // false | ||
assert.isDefined(livemode); | ||
var paymentType = response.paymentType; // "CARD" | ||
assert.isDefined(paymentType); | ||
callbacksVisited++; | ||
assert.equal(callbacksVisited, 4, "Not all callbacks were called") | ||
done(); | ||
}) | ||
.onError(function(errorData) { | ||
console.log("Error", JSON.stringify(errorData)); | ||
fail(null, null, "This example should never return an error"); | ||
}); | ||
it("should have no undefined fields", function(done) { | ||
this.timeout(10000); | ||
var callbacksVisited = 0; | ||
}); | ||
dotdashpay.payment.receivePaymentDataThenPreAuthorize(args) | ||
.onStartedReceivingPaymentData(function(response) { | ||
var peripheralName = response.peripheralName; // peripheralName = "MagTekSureSwipe21040145" | ||
assert.isDefined(peripheralName); | ||
callbacksVisited++; | ||
}) | ||
.onReceivedPaymentData(function(response) { | ||
var paymentDataId = response.paymentDataId; // paymentDataId = "pdid-iPqy9F82v5qexbtz" | ||
assert.isDefined(paymentDataId); | ||
var token = response.token; // token = "aeac1bc8f0735e4283305652ab" | ||
assert.isDefined(token); | ||
var peripheralName = response.peripheralName; // peripheralName = "MagTekSureSwipe21040145" | ||
assert.isDefined(peripheralName); | ||
callbacksVisited++; | ||
}) | ||
.onStartedPreAuthorizing(function(response) { | ||
var paymentDataId = response.paymentDataId; // paymentDataId = "pdid-iPqy9F82v5qexbtz" | ||
assert.isDefined(paymentDataId); | ||
var cents = response.cents; // cents = 128 | ||
assert.isDefined(cents); | ||
var currency = response.currency; // currency = "USD" | ||
assert.isDefined(currency); | ||
var livemode = response.livemode; // livemode = false | ||
assert.isDefined(livemode); | ||
callbacksVisited++; | ||
}) | ||
.onPreAuthorized(function(response) { | ||
var status = response.status; // status = "SUCCESS" | ||
assert.isDefined(status); | ||
var paymentDataId = response.paymentDataId; // paymentDataId = "pdid-iPqy9F82v5qexbtz" | ||
assert.isDefined(paymentDataId); | ||
var preauthId = response.preauthId; // preauthId = "paut-Eo9YqkOTnmxt6EcL" | ||
assert.isDefined(preauthId); | ||
var info = response.info; // info = "Human-readable description" | ||
assert.isDefined(info); | ||
var customerId = response.customerId; // customerId = "2DAuJMBrMyaC" | ||
assert.isDefined(customerId); | ||
var merchantAccountId = response.merchantAccountId; // merchantAccountId = "merchantAccountNumber" | ||
assert.isDefined(merchantAccountId); | ||
var cardType = response.cardType; // cardType = "Visa" | ||
assert.isDefined(cardType); | ||
var last4 = response.last4; // last4 = "0000" | ||
assert.isDefined(last4); | ||
var commercial = response.commercial; // commercial = false | ||
assert.isDefined(commercial); | ||
var debit = response.debit; // debit = false | ||
assert.isDefined(debit); | ||
var createdAt = response.createdAt; // createdAt = "915148799.75" | ||
assert.isDefined(createdAt); | ||
var cents = response.cents; // cents = 128 | ||
assert.isDefined(cents); | ||
var currency = response.currency; // currency = "USD" | ||
assert.isDefined(currency); | ||
var livemode = response.livemode; // livemode = false | ||
assert.isDefined(livemode); | ||
var paymentType = response.paymentType; // paymentType = "CARD" | ||
assert.isDefined(paymentType); | ||
callbacksVisited++; | ||
assert.equal(callbacksVisited, 4, "Not all callbacks were called") | ||
done(); | ||
}) | ||
.onError(function(errorData) { | ||
if (errorData.errorCode == "") { | ||
console.log("Error: " + errorData.errorMessage); | ||
} | ||
fail(null, null, "This example should never return an error"); | ||
}); | ||
it("should be able to specify an error response with the simulator", function(done) { | ||
this.timeout(10000); | ||
var testErrorMessage = "Test error message"; | ||
var testErrorCode = 1; | ||
dotdashpay.simulator.setResponse("StartedReceivingPaymentData", { | ||
errorMessage: testErrorMessage, | ||
errorCode: testErrorCode | ||
}, | ||
true); | ||
dotdashpay.payment.receivePaymentDataThenPreAuthorize(args) | ||
.onStartedReceivingPaymentData(function(response) { | ||
fail(null, null, "This example should only have an onError callback event, not StartedReceivingPaymentData"); | ||
}) | ||
.onReceivedPaymentData(function(response) { | ||
fail(null, null, "This example should only have an onError callback event, not ReceivedPaymentData"); | ||
}) | ||
.onStartedPreAuthorizing(function(response) { | ||
fail(null, null, "This example should only have an onError callback event, not StartedPreAuthorizing"); | ||
}) | ||
.onPreAuthorized(function(response) { | ||
fail(null, null, "This example should only have an onError callback event, not PreAuthorized"); | ||
}) | ||
.onError(function(errorData) { | ||
assert.equal(testErrorMessage, errorData.errorMessage, | ||
"Simulator error message was not returned correctly"); | ||
assert.equal(testErrorCode, errorData.errorCode, | ||
"Simulator error code was not returned correctly"); | ||
dotdashpay.simulator.resetAllResponses(); | ||
done(); | ||
}); | ||
}); | ||
it("should be able to specify an error response with the simulator", function(done) { | ||
this.timeout(10000); | ||
var testErrorMessage = "Test error message"; | ||
var testErrorCode = 1; | ||
dotdashpay.simulator.setResponse("StartedReceivingPaymentData", { | ||
errorMessage: testErrorMessage, | ||
errorCode: testErrorCode | ||
}, | ||
true); | ||
dotdashpay.payment.receivePaymentDataThenPreAuthorize(args) | ||
.onStartedReceivingPaymentData(function(response) { | ||
fail(null, null, "This example should only have an onError callback event, not StartedReceivingPaymentData"); | ||
}) | ||
.onReceivedPaymentData(function(response) { | ||
fail(null, null, "This example should only have an onError callback event, not ReceivedPaymentData"); | ||
}) | ||
.onStartedPreAuthorizing(function(response) { | ||
fail(null, null, "This example should only have an onError callback event, not StartedPreAuthorizing"); | ||
}) | ||
.onPreAuthorized(function(response) { | ||
fail(null, null, "This example should only have an onError callback event, not PreAuthorized"); | ||
}) | ||
.onError(function(errorData) { | ||
assert.equal(testErrorMessage, errorData.errorMessage, | ||
"Simulator error message was not returned correctly"); | ||
assert.equal(testErrorCode, errorData.errorCode, | ||
"Simulator error code was not returned correctly"); | ||
dotdashpay.simulator.resetAllResponses(); | ||
done(); | ||
}); | ||
}); | ||
it("should be able to specify a particular response from the simulator", function(done) { | ||
this.timeout(10000); | ||
// need a string value that we can overwrite | ||
var newVals = { | ||
paymentDataId: "pdid-iPqy9F82v5qexbtz" + "-changed", | ||
preauthId: "paut-Eo9YqkOTnmxt6EcL" + "-changed", | ||
info: "Human-readable description" + "-changed", | ||
customerId: "2DAuJMBrMyaC" + "-changed", | ||
merchantAccountId: "merchantAccountNumber" + "-changed", | ||
cardType: "Visa" + "-changed", | ||
last4: "0000" + "-changed", | ||
createdAt: "915148799.75" + "-changed", | ||
currency: "USD" + "-changed", | ||
}; | ||
it("should be able to specify a particular response from the simulator", function(done) { | ||
this.timeout(10000); | ||
// need a string value that we can overwrite | ||
var newVals = { | ||
paymentDataId: "pdid-iPqy9F82v5qexbtz" + "-changed", | ||
preauthId: "paut-Eo9YqkOTnmxt6EcL" + "-changed", | ||
info: "Human-readable description" + "-changed", | ||
customerId: "2DAuJMBrMyaC" + "-changed", | ||
merchantAccountId: "merchantAccountNumber" + "-changed", | ||
cardType: "Visa" + "-changed", | ||
last4: "0000" + "-changed", | ||
createdAt: "915148799.75" + "-changed", | ||
currency: "USD" + "-changed", | ||
}; | ||
dotdashpay.simulator.setResponse("PreAuthorized", newVals); | ||
dotdashpay.simulator.setResponse("PreAuthorized", newVals); | ||
dotdashpay.payment.receivePaymentDataThenPreAuthorize(args) | ||
.onPreAuthorized(function(response) { | ||
_.each(newVals, function(val, key) { | ||
assert.deepEqual(response[key], val); | ||
}); | ||
done(); | ||
}); | ||
dotdashpay.payment.receivePaymentDataThenPreAuthorize(args) | ||
.onPreAuthorized(function(response) { | ||
_.each(newVals, function(val, key) { | ||
assert.deepEqual(response[key], val); | ||
}); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); |
@@ -5,2 +5,3 @@ /** | ||
var _ = require("lodash"); | ||
@@ -14,154 +15,153 @@ var assert = require('chai').assert; | ||
var args = { | ||
cents: 128, | ||
currency: "USD", | ||
useExistingData: false, | ||
useExistingDataSecondsWindow: 5, | ||
cents: 128, | ||
currency: "USD", | ||
useExistingData: false, | ||
useExistingDataSecondsWindow: 5, | ||
}; | ||
describe("Payment", function() { | ||
describe("receivePaymentDataThenSettle", function() { | ||
beforeEach(function() { | ||
dotdashpay._reset(); | ||
dotdashpay.setup({ | ||
simulate: true | ||
}); | ||
describe("receivePaymentDataThenSettle", function() { | ||
beforeEach(function() { | ||
dotdashpay._reset(); | ||
dotdashpay.setup({ simulate: true }); | ||
}); | ||
it("should have no undefined fields", function(done) { | ||
this.timeout(10000); | ||
var callbacksVisited = 0; | ||
dotdashpay.payment.receivePaymentDataThenSettle(args) | ||
.onStartedReceivingPaymentData(function(response) { | ||
console.log("Received onStartedReceivingPaymentData response", JSON.stringify(response)); | ||
var peripheralName = response.peripheralName; // e.g. "MagTekSureSwipe21040145" | ||
assert.isDefined(peripheralName); | ||
callbacksVisited++; | ||
}) | ||
.onReceivedPaymentData(function(response) { | ||
console.log("Received onReceivedPaymentData response", JSON.stringify(response)); | ||
var paymentDataId = response.paymentDataId; // e.g. "pdid-iPqy9F82v5qexbtz" | ||
assert.isDefined(paymentDataId); | ||
var token = response.token; // "aeac1bc8f0735e4283305652ab" | ||
assert.isDefined(token); | ||
var peripheralName = response.peripheralName; // "MagTekSureSwipe21040145" | ||
assert.isDefined(peripheralName); | ||
callbacksVisited++; | ||
}) | ||
.onStartedSettling(function(response) { | ||
console.log("Received onStartedSettling response", JSON.stringify(response)); | ||
var paymentDataId = response.paymentDataId; // e.g. "pdid-iPqy9F82v5qexbtz" | ||
assert.isDefined(paymentDataId); | ||
var preauthId = response.preauthId; // "paut-Eo9YqkOTnmxt6EcL" | ||
assert.isDefined(preauthId); | ||
var cents = response.cents; // 128 | ||
assert.isDefined(cents); | ||
var currency = response.currency; // "USD" | ||
assert.isDefined(currency); | ||
var livemode = response.livemode; // false | ||
assert.isDefined(livemode); | ||
callbacksVisited++; | ||
}) | ||
.onSettled(function(response) { | ||
console.log("Received onSettled response", JSON.stringify(response)); | ||
var status = response.status; // e.g. "SUCCESS" | ||
assert.isDefined(status); | ||
var paymentDataId = response.paymentDataId; // "pdid-iPqy9F82v5qexbtz" | ||
assert.isDefined(paymentDataId); | ||
var preauthId = response.preauthId; // "paut-Eo9YqkOTnmxt6EcL" | ||
assert.isDefined(preauthId); | ||
var settleId = response.settleId; // "txn-NG9jR86SC3hjzQHA8h5X3pwz" | ||
assert.isDefined(settleId); | ||
var info = response.info; // "Human-readable description" | ||
assert.isDefined(info); | ||
var customerId = response.customerId; // "2DAuJMBrMyaC" | ||
assert.isDefined(customerId); | ||
var merchantAccountId = response.merchantAccountId; // "merchantAccountNumber" | ||
assert.isDefined(merchantAccountId); | ||
var cardType = response.cardType; // "Visa" | ||
assert.isDefined(cardType); | ||
var last4 = response.last4; // "0000" | ||
assert.isDefined(last4); | ||
var commercial = response.commercial; // false | ||
assert.isDefined(commercial); | ||
var debit = response.debit; // false | ||
assert.isDefined(debit); | ||
var createdAt = response.createdAt; // "915148799.75" | ||
assert.isDefined(createdAt); | ||
var cents = response.cents; // 128 | ||
assert.isDefined(cents); | ||
var currency = response.currency; // "USD" | ||
assert.isDefined(currency); | ||
var livemode = response.livemode; // false | ||
assert.isDefined(livemode); | ||
var paymentType = response.paymentType; // "CARD" | ||
assert.isDefined(paymentType); | ||
callbacksVisited++; | ||
assert.equal(callbacksVisited, 4, "Not all callbacks were called") | ||
done(); | ||
}) | ||
.onError(function(errorData) { | ||
console.log("Error", JSON.stringify(errorData)); | ||
fail(null, null, "This example should never return an error"); | ||
}); | ||
it("should have no undefined fields", function(done) { | ||
this.timeout(10000); | ||
var callbacksVisited = 0; | ||
}); | ||
dotdashpay.payment.receivePaymentDataThenSettle(args) | ||
.onStartedReceivingPaymentData(function(response) { | ||
var peripheralName = response.peripheralName; // peripheralName = "MagTekSureSwipe21040145" | ||
assert.isDefined(peripheralName); | ||
callbacksVisited++; | ||
}) | ||
.onReceivedPaymentData(function(response) { | ||
var paymentDataId = response.paymentDataId; // paymentDataId = "pdid-iPqy9F82v5qexbtz" | ||
assert.isDefined(paymentDataId); | ||
var token = response.token; // token = "aeac1bc8f0735e4283305652ab" | ||
assert.isDefined(token); | ||
var peripheralName = response.peripheralName; // peripheralName = "MagTekSureSwipe21040145" | ||
assert.isDefined(peripheralName); | ||
callbacksVisited++; | ||
}) | ||
.onStartedSettling(function(response) { | ||
var paymentDataId = response.paymentDataId; // paymentDataId = "pdid-iPqy9F82v5qexbtz" | ||
assert.isDefined(paymentDataId); | ||
var preauthId = response.preauthId; // preauthId = "paut-Eo9YqkOTnmxt6EcL" | ||
assert.isDefined(preauthId); | ||
var cents = response.cents; // cents = 128 | ||
assert.isDefined(cents); | ||
var currency = response.currency; // currency = "USD" | ||
assert.isDefined(currency); | ||
var livemode = response.livemode; // livemode = false | ||
assert.isDefined(livemode); | ||
callbacksVisited++; | ||
}) | ||
.onSettled(function(response) { | ||
var status = response.status; // status = "SUCCESS" | ||
assert.isDefined(status); | ||
var paymentDataId = response.paymentDataId; // paymentDataId = "pdid-iPqy9F82v5qexbtz" | ||
assert.isDefined(paymentDataId); | ||
var preauthId = response.preauthId; // preauthId = "paut-Eo9YqkOTnmxt6EcL" | ||
assert.isDefined(preauthId); | ||
var settleId = response.settleId; // settleId = "txn-NG9jR86SC3hjzQHA8h5X3pwz" | ||
assert.isDefined(settleId); | ||
var info = response.info; // info = "Human-readable description" | ||
assert.isDefined(info); | ||
var customerId = response.customerId; // customerId = "2DAuJMBrMyaC" | ||
assert.isDefined(customerId); | ||
var merchantAccountId = response.merchantAccountId; // merchantAccountId = "merchantAccountNumber" | ||
assert.isDefined(merchantAccountId); | ||
var cardType = response.cardType; // cardType = "Visa" | ||
assert.isDefined(cardType); | ||
var last4 = response.last4; // last4 = "0000" | ||
assert.isDefined(last4); | ||
var commercial = response.commercial; // commercial = false | ||
assert.isDefined(commercial); | ||
var debit = response.debit; // debit = false | ||
assert.isDefined(debit); | ||
var createdAt = response.createdAt; // createdAt = "915148799.75" | ||
assert.isDefined(createdAt); | ||
var cents = response.cents; // cents = 128 | ||
assert.isDefined(cents); | ||
var currency = response.currency; // currency = "USD" | ||
assert.isDefined(currency); | ||
var livemode = response.livemode; // livemode = false | ||
assert.isDefined(livemode); | ||
var paymentType = response.paymentType; // paymentType = "CARD" | ||
assert.isDefined(paymentType); | ||
callbacksVisited++; | ||
assert.equal(callbacksVisited, 4, "Not all callbacks were called") | ||
done(); | ||
}) | ||
.onError(function(errorData) { | ||
if (errorData.errorCode == "") { | ||
console.log("Error: " + errorData.errorMessage); | ||
} | ||
fail(null, null, "This example should never return an error"); | ||
}); | ||
it("should be able to specify an error response with the simulator", function(done) { | ||
this.timeout(10000); | ||
var testErrorMessage = "Test error message"; | ||
var testErrorCode = 1; | ||
dotdashpay.simulator.setResponse("StartedReceivingPaymentData", { | ||
errorMessage: testErrorMessage, | ||
errorCode: testErrorCode | ||
}, | ||
true); | ||
dotdashpay.payment.receivePaymentDataThenSettle(args) | ||
.onStartedReceivingPaymentData(function(response) { | ||
fail(null, null, "This example should only have an onError callback event, not StartedReceivingPaymentData"); | ||
}) | ||
.onReceivedPaymentData(function(response) { | ||
fail(null, null, "This example should only have an onError callback event, not ReceivedPaymentData"); | ||
}) | ||
.onStartedSettling(function(response) { | ||
fail(null, null, "This example should only have an onError callback event, not StartedSettling"); | ||
}) | ||
.onSettled(function(response) { | ||
fail(null, null, "This example should only have an onError callback event, not Settled"); | ||
}) | ||
.onError(function(errorData) { | ||
assert.equal(testErrorMessage, errorData.errorMessage, | ||
"Simulator error message was not returned correctly"); | ||
assert.equal(testErrorCode, errorData.errorCode, | ||
"Simulator error code was not returned correctly"); | ||
dotdashpay.simulator.resetAllResponses(); | ||
done(); | ||
}); | ||
}); | ||
it("should be able to specify an error response with the simulator", function(done) { | ||
this.timeout(10000); | ||
var testErrorMessage = "Test error message"; | ||
var testErrorCode = 1; | ||
dotdashpay.simulator.setResponse("StartedReceivingPaymentData", { | ||
errorMessage: testErrorMessage, | ||
errorCode: testErrorCode | ||
}, | ||
true); | ||
dotdashpay.payment.receivePaymentDataThenSettle(args) | ||
.onStartedReceivingPaymentData(function(response) { | ||
fail(null, null, "This example should only have an onError callback event, not StartedReceivingPaymentData"); | ||
}) | ||
.onReceivedPaymentData(function(response) { | ||
fail(null, null, "This example should only have an onError callback event, not ReceivedPaymentData"); | ||
}) | ||
.onStartedSettling(function(response) { | ||
fail(null, null, "This example should only have an onError callback event, not StartedSettling"); | ||
}) | ||
.onSettled(function(response) { | ||
fail(null, null, "This example should only have an onError callback event, not Settled"); | ||
}) | ||
.onError(function(errorData) { | ||
assert.equal(testErrorMessage, errorData.errorMessage, | ||
"Simulator error message was not returned correctly"); | ||
assert.equal(testErrorCode, errorData.errorCode, | ||
"Simulator error code was not returned correctly"); | ||
dotdashpay.simulator.resetAllResponses(); | ||
done(); | ||
}); | ||
}); | ||
it("should be able to specify a particular response from the simulator", function(done) { | ||
this.timeout(10000); | ||
// need a string value that we can overwrite | ||
var newVals = { | ||
paymentDataId: "pdid-iPqy9F82v5qexbtz" + "-changed", | ||
preauthId: "paut-Eo9YqkOTnmxt6EcL" + "-changed", | ||
settleId: "txn-NG9jR86SC3hjzQHA8h5X3pwz" + "-changed", | ||
info: "Human-readable description" + "-changed", | ||
customerId: "2DAuJMBrMyaC" + "-changed", | ||
merchantAccountId: "merchantAccountNumber" + "-changed", | ||
cardType: "Visa" + "-changed", | ||
last4: "0000" + "-changed", | ||
createdAt: "915148799.75" + "-changed", | ||
currency: "USD" + "-changed", | ||
}; | ||
it("should be able to specify a particular response from the simulator", function(done) { | ||
this.timeout(10000); | ||
// need a string value that we can overwrite | ||
var newVals = { | ||
paymentDataId: "pdid-iPqy9F82v5qexbtz" + "-changed", | ||
preauthId: "paut-Eo9YqkOTnmxt6EcL" + "-changed", | ||
settleId: "txn-NG9jR86SC3hjzQHA8h5X3pwz" + "-changed", | ||
info: "Human-readable description" + "-changed", | ||
customerId: "2DAuJMBrMyaC" + "-changed", | ||
merchantAccountId: "merchantAccountNumber" + "-changed", | ||
cardType: "Visa" + "-changed", | ||
last4: "0000" + "-changed", | ||
createdAt: "915148799.75" + "-changed", | ||
currency: "USD" + "-changed", | ||
}; | ||
dotdashpay.simulator.setResponse("Settled", newVals); | ||
dotdashpay.simulator.setResponse("Settled", newVals); | ||
dotdashpay.payment.receivePaymentDataThenSettle(args) | ||
.onSettled(function(response) { | ||
_.each(newVals, function(val, key) { | ||
assert.deepEqual(response[key], val); | ||
}); | ||
done(); | ||
}); | ||
dotdashpay.payment.receivePaymentDataThenSettle(args) | ||
.onSettled(function(response) { | ||
_.each(newVals, function(val, key) { | ||
assert.deepEqual(response[key], val); | ||
}); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); |
@@ -5,2 +5,3 @@ /** | ||
var _ = require("lodash"); | ||
@@ -14,109 +15,105 @@ var assert = require('chai').assert; | ||
var args = { | ||
settleId: "txn-NG9jR86SC3hjzQHA8h5X3pwz", | ||
settleId: "txn-NG9jR86SC3hjzQHA8h5X3pwz", | ||
}; | ||
describe("Payment", function() { | ||
describe("refund", function() { | ||
beforeEach(function() { | ||
dotdashpay._reset(); | ||
dotdashpay.setup({ | ||
simulate: true | ||
}); | ||
describe("refund", function() { | ||
beforeEach(function() { | ||
dotdashpay._reset(); | ||
dotdashpay.setup({ simulate: true }); | ||
}); | ||
it("should have no undefined fields", function(done) { | ||
this.timeout(10000); | ||
var callbacksVisited = 0; | ||
dotdashpay.payment.refund(args) | ||
.onRefunded(function(response) { | ||
console.log("Received onRefunded response", JSON.stringify(response)); | ||
var status = response.status; // e.g. "SUCCESS" | ||
assert.isDefined(status); | ||
var refundId = response.refundId; // "rfnd-PFuJxu7hpWKcMsgs" | ||
assert.isDefined(refundId); | ||
var info = response.info; // "Human-readable description" | ||
assert.isDefined(info); | ||
var customerId = response.customerId; // "2DAuJMBrMyaC" | ||
assert.isDefined(customerId); | ||
var merchantAccountId = response.merchantAccountId; // "merchantAccountNumber" | ||
assert.isDefined(merchantAccountId); | ||
var cardType = response.cardType; // "Visa" | ||
assert.isDefined(cardType); | ||
var last4 = response.last4; // "0000" | ||
assert.isDefined(last4); | ||
var commercial = response.commercial; // false | ||
assert.isDefined(commercial); | ||
var debit = response.debit; // false | ||
assert.isDefined(debit); | ||
var createdAt = response.createdAt; // "915148799.75" | ||
assert.isDefined(createdAt); | ||
var cents = response.cents; // 128 | ||
assert.isDefined(cents); | ||
var currency = response.currency; // "USD" | ||
assert.isDefined(currency); | ||
var livemode = response.livemode; // false | ||
assert.isDefined(livemode); | ||
var paymentType = response.paymentType; // "CARD" | ||
assert.isDefined(paymentType); | ||
callbacksVisited++; | ||
assert.equal(callbacksVisited, 1, "Not all callbacks were called") | ||
done(); | ||
}) | ||
.onError(function(errorData) { | ||
console.log("Error", JSON.stringify(errorData)); | ||
fail(null, null, "This example should never return an error"); | ||
}); | ||
it("should have no undefined fields", function(done) { | ||
this.timeout(10000); | ||
var callbacksVisited = 0; | ||
}); | ||
dotdashpay.payment.refund(args) | ||
.onRefunded(function(response) { | ||
var status = response.status; // status = "SUCCESS" | ||
assert.isDefined(status); | ||
var refundId = response.refundId; // refundId = "rfnd-PFuJxu7hpWKcMsgs" | ||
assert.isDefined(refundId); | ||
var info = response.info; // info = "Human-readable description" | ||
assert.isDefined(info); | ||
var customerId = response.customerId; // customerId = "2DAuJMBrMyaC" | ||
assert.isDefined(customerId); | ||
var merchantAccountId = response.merchantAccountId; // merchantAccountId = "merchantAccountNumber" | ||
assert.isDefined(merchantAccountId); | ||
var cardType = response.cardType; // cardType = "Visa" | ||
assert.isDefined(cardType); | ||
var last4 = response.last4; // last4 = "0000" | ||
assert.isDefined(last4); | ||
var commercial = response.commercial; // commercial = false | ||
assert.isDefined(commercial); | ||
var debit = response.debit; // debit = false | ||
assert.isDefined(debit); | ||
var createdAt = response.createdAt; // createdAt = "915148799.75" | ||
assert.isDefined(createdAt); | ||
var cents = response.cents; // cents = 128 | ||
assert.isDefined(cents); | ||
var currency = response.currency; // currency = "USD" | ||
assert.isDefined(currency); | ||
var livemode = response.livemode; // livemode = false | ||
assert.isDefined(livemode); | ||
var paymentType = response.paymentType; // paymentType = "CARD" | ||
assert.isDefined(paymentType); | ||
callbacksVisited++; | ||
assert.equal(callbacksVisited, 1, "Not all callbacks were called") | ||
done(); | ||
}) | ||
.onError(function(errorData) { | ||
if (errorData.errorCode == "") { | ||
console.log("Error: " + errorData.errorMessage); | ||
} | ||
fail(null, null, "This example should never return an error"); | ||
}); | ||
it("should be able to specify an error response with the simulator", function(done) { | ||
this.timeout(10000); | ||
var testErrorMessage = "Test error message"; | ||
var testErrorCode = 1; | ||
dotdashpay.simulator.setResponse("Refunded", { | ||
errorMessage: testErrorMessage, | ||
errorCode: testErrorCode | ||
}, | ||
true); | ||
dotdashpay.payment.refund(args) | ||
.onRefunded(function(response) { | ||
fail(null, null, "This example should only have an onError callback event, not Refunded"); | ||
}) | ||
.onError(function(errorData) { | ||
assert.equal(testErrorMessage, errorData.errorMessage, | ||
"Simulator error message was not returned correctly"); | ||
assert.equal(testErrorCode, errorData.errorCode, | ||
"Simulator error code was not returned correctly"); | ||
dotdashpay.simulator.resetAllResponses(); | ||
done(); | ||
}); | ||
}); | ||
it("should be able to specify an error response with the simulator", function(done) { | ||
this.timeout(10000); | ||
var testErrorMessage = "Test error message"; | ||
var testErrorCode = 1; | ||
dotdashpay.simulator.setResponse("Refunded", { | ||
errorMessage: testErrorMessage, | ||
errorCode: testErrorCode | ||
}, | ||
true); | ||
dotdashpay.payment.refund(args) | ||
.onRefunded(function(response) { | ||
fail(null, null, "This example should only have an onError callback event, not Refunded"); | ||
}) | ||
.onError(function(errorData) { | ||
assert.equal(testErrorMessage, errorData.errorMessage, | ||
"Simulator error message was not returned correctly"); | ||
assert.equal(testErrorCode, errorData.errorCode, | ||
"Simulator error code was not returned correctly"); | ||
dotdashpay.simulator.resetAllResponses(); | ||
done(); | ||
}); | ||
}); | ||
it("should be able to specify a particular response from the simulator", function(done) { | ||
this.timeout(10000); | ||
// need a string value that we can overwrite | ||
var newVals = { | ||
refundId: "rfnd-PFuJxu7hpWKcMsgs" + "-changed", | ||
info: "Human-readable description" + "-changed", | ||
customerId: "2DAuJMBrMyaC" + "-changed", | ||
merchantAccountId: "merchantAccountNumber" + "-changed", | ||
cardType: "Visa" + "-changed", | ||
last4: "0000" + "-changed", | ||
createdAt: "915148799.75" + "-changed", | ||
currency: "USD" + "-changed", | ||
}; | ||
it("should be able to specify a particular response from the simulator", function(done) { | ||
this.timeout(10000); | ||
// need a string value that we can overwrite | ||
var newVals = { | ||
refundId: "rfnd-PFuJxu7hpWKcMsgs" + "-changed", | ||
info: "Human-readable description" + "-changed", | ||
customerId: "2DAuJMBrMyaC" + "-changed", | ||
merchantAccountId: "merchantAccountNumber" + "-changed", | ||
cardType: "Visa" + "-changed", | ||
last4: "0000" + "-changed", | ||
createdAt: "915148799.75" + "-changed", | ||
currency: "USD" + "-changed", | ||
}; | ||
dotdashpay.simulator.setResponse("Refunded", newVals); | ||
dotdashpay.simulator.setResponse("Refunded", newVals); | ||
dotdashpay.payment.refund(args) | ||
.onRefunded(function(response) { | ||
_.each(newVals, function(val, key) { | ||
assert.deepEqual(response[key], val); | ||
}); | ||
done(); | ||
}); | ||
dotdashpay.payment.refund(args) | ||
.onRefunded(function(response) { | ||
_.each(newVals, function(val, key) { | ||
assert.deepEqual(response[key], val); | ||
}); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); |
@@ -5,2 +5,3 @@ /** | ||
var _ = require("lodash"); | ||
@@ -14,134 +15,131 @@ var assert = require('chai').assert; | ||
var args = { | ||
paymentDataId: "pdid-iPqy9F82v5qexbtz", | ||
preauthId: "paut-Eo9YqkOTnmxt6EcL", | ||
cents: 128, | ||
currency: "USD", | ||
paymentDataId: "pdid-iPqy9F82v5qexbtz", | ||
preauthId: "paut-Eo9YqkOTnmxt6EcL", | ||
cents: 128, | ||
currency: "USD", | ||
}; | ||
describe("Payment", function() { | ||
describe("settle", function() { | ||
beforeEach(function() { | ||
dotdashpay._reset(); | ||
dotdashpay.setup({ | ||
simulate: true | ||
}); | ||
describe("settle", function() { | ||
beforeEach(function() { | ||
dotdashpay._reset(); | ||
dotdashpay.setup({ simulate: true }); | ||
}); | ||
it("should have no undefined fields", function(done) { | ||
this.timeout(10000); | ||
var callbacksVisited = 0; | ||
dotdashpay.payment.settle(args) | ||
.onStartedSettling(function(response) { | ||
console.log("Received onStartedSettling response", JSON.stringify(response)); | ||
var paymentDataId = response.paymentDataId; // e.g. "pdid-iPqy9F82v5qexbtz" | ||
assert.isDefined(paymentDataId); | ||
var preauthId = response.preauthId; // "paut-Eo9YqkOTnmxt6EcL" | ||
assert.isDefined(preauthId); | ||
var cents = response.cents; // 128 | ||
assert.isDefined(cents); | ||
var currency = response.currency; // "USD" | ||
assert.isDefined(currency); | ||
var livemode = response.livemode; // false | ||
assert.isDefined(livemode); | ||
callbacksVisited++; | ||
}) | ||
.onSettled(function(response) { | ||
console.log("Received onSettled response", JSON.stringify(response)); | ||
var status = response.status; // e.g. "SUCCESS" | ||
assert.isDefined(status); | ||
var paymentDataId = response.paymentDataId; // "pdid-iPqy9F82v5qexbtz" | ||
assert.isDefined(paymentDataId); | ||
var preauthId = response.preauthId; // "paut-Eo9YqkOTnmxt6EcL" | ||
assert.isDefined(preauthId); | ||
var settleId = response.settleId; // "txn-NG9jR86SC3hjzQHA8h5X3pwz" | ||
assert.isDefined(settleId); | ||
var info = response.info; // "Human-readable description" | ||
assert.isDefined(info); | ||
var customerId = response.customerId; // "2DAuJMBrMyaC" | ||
assert.isDefined(customerId); | ||
var merchantAccountId = response.merchantAccountId; // "merchantAccountNumber" | ||
assert.isDefined(merchantAccountId); | ||
var cardType = response.cardType; // "Visa" | ||
assert.isDefined(cardType); | ||
var last4 = response.last4; // "0000" | ||
assert.isDefined(last4); | ||
var commercial = response.commercial; // false | ||
assert.isDefined(commercial); | ||
var debit = response.debit; // false | ||
assert.isDefined(debit); | ||
var createdAt = response.createdAt; // "915148799.75" | ||
assert.isDefined(createdAt); | ||
var cents = response.cents; // 128 | ||
assert.isDefined(cents); | ||
var currency = response.currency; // "USD" | ||
assert.isDefined(currency); | ||
var livemode = response.livemode; // false | ||
assert.isDefined(livemode); | ||
var paymentType = response.paymentType; // "CARD" | ||
assert.isDefined(paymentType); | ||
callbacksVisited++; | ||
assert.equal(callbacksVisited, 2, "Not all callbacks were called") | ||
done(); | ||
}) | ||
.onError(function(errorData) { | ||
console.log("Error", JSON.stringify(errorData)); | ||
fail(null, null, "This example should never return an error"); | ||
}); | ||
it("should have no undefined fields", function(done) { | ||
this.timeout(10000); | ||
var callbacksVisited = 0; | ||
}); | ||
dotdashpay.payment.settle(args) | ||
.onStartedSettling(function(response) { | ||
var paymentDataId = response.paymentDataId; // paymentDataId = "pdid-iPqy9F82v5qexbtz" | ||
assert.isDefined(paymentDataId); | ||
var preauthId = response.preauthId; // preauthId = "paut-Eo9YqkOTnmxt6EcL" | ||
assert.isDefined(preauthId); | ||
var cents = response.cents; // cents = 128 | ||
assert.isDefined(cents); | ||
var currency = response.currency; // currency = "USD" | ||
assert.isDefined(currency); | ||
var livemode = response.livemode; // livemode = false | ||
assert.isDefined(livemode); | ||
callbacksVisited++; | ||
}) | ||
.onSettled(function(response) { | ||
var status = response.status; // status = "SUCCESS" | ||
assert.isDefined(status); | ||
var paymentDataId = response.paymentDataId; // paymentDataId = "pdid-iPqy9F82v5qexbtz" | ||
assert.isDefined(paymentDataId); | ||
var preauthId = response.preauthId; // preauthId = "paut-Eo9YqkOTnmxt6EcL" | ||
assert.isDefined(preauthId); | ||
var settleId = response.settleId; // settleId = "txn-NG9jR86SC3hjzQHA8h5X3pwz" | ||
assert.isDefined(settleId); | ||
var info = response.info; // info = "Human-readable description" | ||
assert.isDefined(info); | ||
var customerId = response.customerId; // customerId = "2DAuJMBrMyaC" | ||
assert.isDefined(customerId); | ||
var merchantAccountId = response.merchantAccountId; // merchantAccountId = "merchantAccountNumber" | ||
assert.isDefined(merchantAccountId); | ||
var cardType = response.cardType; // cardType = "Visa" | ||
assert.isDefined(cardType); | ||
var last4 = response.last4; // last4 = "0000" | ||
assert.isDefined(last4); | ||
var commercial = response.commercial; // commercial = false | ||
assert.isDefined(commercial); | ||
var debit = response.debit; // debit = false | ||
assert.isDefined(debit); | ||
var createdAt = response.createdAt; // createdAt = "915148799.75" | ||
assert.isDefined(createdAt); | ||
var cents = response.cents; // cents = 128 | ||
assert.isDefined(cents); | ||
var currency = response.currency; // currency = "USD" | ||
assert.isDefined(currency); | ||
var livemode = response.livemode; // livemode = false | ||
assert.isDefined(livemode); | ||
var paymentType = response.paymentType; // paymentType = "CARD" | ||
assert.isDefined(paymentType); | ||
callbacksVisited++; | ||
assert.equal(callbacksVisited, 2, "Not all callbacks were called") | ||
done(); | ||
}) | ||
.onError(function(errorData) { | ||
if (errorData.errorCode == "") { | ||
console.log("Error: " + errorData.errorMessage); | ||
} | ||
fail(null, null, "This example should never return an error"); | ||
}); | ||
it("should be able to specify an error response with the simulator", function(done) { | ||
this.timeout(10000); | ||
var testErrorMessage = "Test error message"; | ||
var testErrorCode = 1; | ||
dotdashpay.simulator.setResponse("StartedSettling", { | ||
errorMessage: testErrorMessage, | ||
errorCode: testErrorCode | ||
}, | ||
true); | ||
dotdashpay.payment.settle(args) | ||
.onStartedSettling(function(response) { | ||
fail(null, null, "This example should only have an onError callback event, not StartedSettling"); | ||
}) | ||
.onSettled(function(response) { | ||
fail(null, null, "This example should only have an onError callback event, not Settled"); | ||
}) | ||
.onError(function(errorData) { | ||
assert.equal(testErrorMessage, errorData.errorMessage, | ||
"Simulator error message was not returned correctly"); | ||
assert.equal(testErrorCode, errorData.errorCode, | ||
"Simulator error code was not returned correctly"); | ||
dotdashpay.simulator.resetAllResponses(); | ||
done(); | ||
}); | ||
}); | ||
it("should be able to specify an error response with the simulator", function(done) { | ||
this.timeout(10000); | ||
var testErrorMessage = "Test error message"; | ||
var testErrorCode = 1; | ||
dotdashpay.simulator.setResponse("StartedSettling", { | ||
errorMessage: testErrorMessage, | ||
errorCode: testErrorCode | ||
}, | ||
true); | ||
dotdashpay.payment.settle(args) | ||
.onStartedSettling(function(response) { | ||
fail(null, null, "This example should only have an onError callback event, not StartedSettling"); | ||
}) | ||
.onSettled(function(response) { | ||
fail(null, null, "This example should only have an onError callback event, not Settled"); | ||
}) | ||
.onError(function(errorData) { | ||
assert.equal(testErrorMessage, errorData.errorMessage, | ||
"Simulator error message was not returned correctly"); | ||
assert.equal(testErrorCode, errorData.errorCode, | ||
"Simulator error code was not returned correctly"); | ||
dotdashpay.simulator.resetAllResponses(); | ||
done(); | ||
}); | ||
}); | ||
it("should be able to specify a particular response from the simulator", function(done) { | ||
this.timeout(10000); | ||
// need a string value that we can overwrite | ||
var newVals = { | ||
paymentDataId: "pdid-iPqy9F82v5qexbtz" + "-changed", | ||
preauthId: "paut-Eo9YqkOTnmxt6EcL" + "-changed", | ||
settleId: "txn-NG9jR86SC3hjzQHA8h5X3pwz" + "-changed", | ||
info: "Human-readable description" + "-changed", | ||
customerId: "2DAuJMBrMyaC" + "-changed", | ||
merchantAccountId: "merchantAccountNumber" + "-changed", | ||
cardType: "Visa" + "-changed", | ||
last4: "0000" + "-changed", | ||
createdAt: "915148799.75" + "-changed", | ||
currency: "USD" + "-changed", | ||
}; | ||
it("should be able to specify a particular response from the simulator", function(done) { | ||
this.timeout(10000); | ||
// need a string value that we can overwrite | ||
var newVals = { | ||
paymentDataId: "pdid-iPqy9F82v5qexbtz" + "-changed", | ||
preauthId: "paut-Eo9YqkOTnmxt6EcL" + "-changed", | ||
settleId: "txn-NG9jR86SC3hjzQHA8h5X3pwz" + "-changed", | ||
info: "Human-readable description" + "-changed", | ||
customerId: "2DAuJMBrMyaC" + "-changed", | ||
merchantAccountId: "merchantAccountNumber" + "-changed", | ||
cardType: "Visa" + "-changed", | ||
last4: "0000" + "-changed", | ||
createdAt: "915148799.75" + "-changed", | ||
currency: "USD" + "-changed", | ||
}; | ||
dotdashpay.simulator.setResponse("Settled", newVals); | ||
dotdashpay.simulator.setResponse("Settled", newVals); | ||
dotdashpay.payment.settle(args) | ||
.onSettled(function(response) { | ||
_.each(newVals, function(val, key) { | ||
assert.deepEqual(response[key], val); | ||
}); | ||
done(); | ||
}); | ||
dotdashpay.payment.settle(args) | ||
.onSettled(function(response) { | ||
_.each(newVals, function(val, key) { | ||
assert.deepEqual(response[key], val); | ||
}); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); |
@@ -5,2 +5,3 @@ /** | ||
var _ = require("lodash"); | ||
@@ -14,109 +15,105 @@ var assert = require('chai').assert; | ||
var args = { | ||
preauthId: "paut-Eo9YqkOTnmxt6EcL", | ||
preauthId: "paut-Eo9YqkOTnmxt6EcL", | ||
}; | ||
describe("Payment", function() { | ||
describe("voidPreAuthorize", function() { | ||
beforeEach(function() { | ||
dotdashpay._reset(); | ||
dotdashpay.setup({ | ||
simulate: true | ||
}); | ||
describe("voidPreAuthorize", function() { | ||
beforeEach(function() { | ||
dotdashpay._reset(); | ||
dotdashpay.setup({ simulate: true }); | ||
}); | ||
it("should have no undefined fields", function(done) { | ||
this.timeout(10000); | ||
var callbacksVisited = 0; | ||
dotdashpay.payment.voidPreAuthorize(args) | ||
.onVoidedPreAuthorize(function(response) { | ||
console.log("Received onVoidedPreAuthorize response", JSON.stringify(response)); | ||
var status = response.status; // e.g. "SUCCESS" | ||
assert.isDefined(status); | ||
var voidId = response.voidId; // "void-QTKL0uLZuO1gFaFm" | ||
assert.isDefined(voidId); | ||
var info = response.info; // "Human-readable description" | ||
assert.isDefined(info); | ||
var customerId = response.customerId; // "2DAuJMBrMyaC" | ||
assert.isDefined(customerId); | ||
var merchantAccountId = response.merchantAccountId; // "merchantAccountNumber" | ||
assert.isDefined(merchantAccountId); | ||
var cardType = response.cardType; // "Visa" | ||
assert.isDefined(cardType); | ||
var last4 = response.last4; // "0000" | ||
assert.isDefined(last4); | ||
var commercial = response.commercial; // false | ||
assert.isDefined(commercial); | ||
var debit = response.debit; // false | ||
assert.isDefined(debit); | ||
var createdAt = response.createdAt; // "915148799.75" | ||
assert.isDefined(createdAt); | ||
var cents = response.cents; // 128 | ||
assert.isDefined(cents); | ||
var currency = response.currency; // "USD" | ||
assert.isDefined(currency); | ||
var livemode = response.livemode; // false | ||
assert.isDefined(livemode); | ||
var paymentType = response.paymentType; // "CARD" | ||
assert.isDefined(paymentType); | ||
callbacksVisited++; | ||
assert.equal(callbacksVisited, 1, "Not all callbacks were called") | ||
done(); | ||
}) | ||
.onError(function(errorData) { | ||
console.log("Error", JSON.stringify(errorData)); | ||
fail(null, null, "This example should never return an error"); | ||
}); | ||
it("should have no undefined fields", function(done) { | ||
this.timeout(10000); | ||
var callbacksVisited = 0; | ||
}); | ||
dotdashpay.payment.voidPreAuthorize(args) | ||
.onVoidedPreAuthorize(function(response) { | ||
var status = response.status; // status = "SUCCESS" | ||
assert.isDefined(status); | ||
var voidId = response.voidId; // voidId = "void-QTKL0uLZuO1gFaFm" | ||
assert.isDefined(voidId); | ||
var info = response.info; // info = "Human-readable description" | ||
assert.isDefined(info); | ||
var customerId = response.customerId; // customerId = "2DAuJMBrMyaC" | ||
assert.isDefined(customerId); | ||
var merchantAccountId = response.merchantAccountId; // merchantAccountId = "merchantAccountNumber" | ||
assert.isDefined(merchantAccountId); | ||
var cardType = response.cardType; // cardType = "Visa" | ||
assert.isDefined(cardType); | ||
var last4 = response.last4; // last4 = "0000" | ||
assert.isDefined(last4); | ||
var commercial = response.commercial; // commercial = false | ||
assert.isDefined(commercial); | ||
var debit = response.debit; // debit = false | ||
assert.isDefined(debit); | ||
var createdAt = response.createdAt; // createdAt = "915148799.75" | ||
assert.isDefined(createdAt); | ||
var cents = response.cents; // cents = 128 | ||
assert.isDefined(cents); | ||
var currency = response.currency; // currency = "USD" | ||
assert.isDefined(currency); | ||
var livemode = response.livemode; // livemode = false | ||
assert.isDefined(livemode); | ||
var paymentType = response.paymentType; // paymentType = "CARD" | ||
assert.isDefined(paymentType); | ||
callbacksVisited++; | ||
assert.equal(callbacksVisited, 1, "Not all callbacks were called") | ||
done(); | ||
}) | ||
.onError(function(errorData) { | ||
if (errorData.errorCode == "") { | ||
console.log("Error: " + errorData.errorMessage); | ||
} | ||
fail(null, null, "This example should never return an error"); | ||
}); | ||
it("should be able to specify an error response with the simulator", function(done) { | ||
this.timeout(10000); | ||
var testErrorMessage = "Test error message"; | ||
var testErrorCode = 1; | ||
dotdashpay.simulator.setResponse("VoidedPreAuthorize", { | ||
errorMessage: testErrorMessage, | ||
errorCode: testErrorCode | ||
}, | ||
true); | ||
dotdashpay.payment.voidPreAuthorize(args) | ||
.onVoidedPreAuthorize(function(response) { | ||
fail(null, null, "This example should only have an onError callback event, not VoidedPreAuthorize"); | ||
}) | ||
.onError(function(errorData) { | ||
assert.equal(testErrorMessage, errorData.errorMessage, | ||
"Simulator error message was not returned correctly"); | ||
assert.equal(testErrorCode, errorData.errorCode, | ||
"Simulator error code was not returned correctly"); | ||
dotdashpay.simulator.resetAllResponses(); | ||
done(); | ||
}); | ||
}); | ||
it("should be able to specify an error response with the simulator", function(done) { | ||
this.timeout(10000); | ||
var testErrorMessage = "Test error message"; | ||
var testErrorCode = 1; | ||
dotdashpay.simulator.setResponse("VoidedPreAuthorize", { | ||
errorMessage: testErrorMessage, | ||
errorCode: testErrorCode | ||
}, | ||
true); | ||
dotdashpay.payment.voidPreAuthorize(args) | ||
.onVoidedPreAuthorize(function(response) { | ||
fail(null, null, "This example should only have an onError callback event, not VoidedPreAuthorize"); | ||
}) | ||
.onError(function(errorData) { | ||
assert.equal(testErrorMessage, errorData.errorMessage, | ||
"Simulator error message was not returned correctly"); | ||
assert.equal(testErrorCode, errorData.errorCode, | ||
"Simulator error code was not returned correctly"); | ||
dotdashpay.simulator.resetAllResponses(); | ||
done(); | ||
}); | ||
}); | ||
it("should be able to specify a particular response from the simulator", function(done) { | ||
this.timeout(10000); | ||
// need a string value that we can overwrite | ||
var newVals = { | ||
voidId: "void-QTKL0uLZuO1gFaFm" + "-changed", | ||
info: "Human-readable description" + "-changed", | ||
customerId: "2DAuJMBrMyaC" + "-changed", | ||
merchantAccountId: "merchantAccountNumber" + "-changed", | ||
cardType: "Visa" + "-changed", | ||
last4: "0000" + "-changed", | ||
createdAt: "915148799.75" + "-changed", | ||
currency: "USD" + "-changed", | ||
}; | ||
it("should be able to specify a particular response from the simulator", function(done) { | ||
this.timeout(10000); | ||
// need a string value that we can overwrite | ||
var newVals = { | ||
voidId: "void-QTKL0uLZuO1gFaFm" + "-changed", | ||
info: "Human-readable description" + "-changed", | ||
customerId: "2DAuJMBrMyaC" + "-changed", | ||
merchantAccountId: "merchantAccountNumber" + "-changed", | ||
cardType: "Visa" + "-changed", | ||
last4: "0000" + "-changed", | ||
createdAt: "915148799.75" + "-changed", | ||
currency: "USD" + "-changed", | ||
}; | ||
dotdashpay.simulator.setResponse("VoidedPreAuthorize", newVals); | ||
dotdashpay.simulator.setResponse("VoidedPreAuthorize", newVals); | ||
dotdashpay.payment.voidPreAuthorize(args) | ||
.onVoidedPreAuthorize(function(response) { | ||
_.each(newVals, function(val, key) { | ||
assert.deepEqual(response[key], val); | ||
}); | ||
done(); | ||
}); | ||
dotdashpay.payment.voidPreAuthorize(args) | ||
.onVoidedPreAuthorize(function(response) { | ||
_.each(newVals, function(val, key) { | ||
assert.deepEqual(response[key], val); | ||
}); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14
665414
5119