paypro: 12 tests passing.
This commit is contained in:
parent
919681633a
commit
31719e62dd
1 changed files with 70 additions and 8 deletions
|
|
@ -665,19 +665,53 @@ describe('PayPro (in Wallet) model', function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('#send a payment request', function(done) {
|
it('#send a payment request using payment api', function(done) {
|
||||||
var w = createWallet();
|
var w = createWallet();
|
||||||
should.exist(w);
|
should.exist(w);
|
||||||
var address = 'bitcoin:mq7se9wy2egettFxPbmn99cK8v5AFq55Lx?amount=0.11&r=' + server.uri + '/request';
|
var uri = 'bitcoin:2NBzZdFBoQymDgfzH2Pmnthser1E71MmU47?amount=0.00003&r=' + server.uri + '/request';
|
||||||
var commentText = 'Hello, server. I\'d like to make a payment.';
|
var memo = 'Hello, server. I\'d like to make a payment.';
|
||||||
w.createTx(address, commentText, function(ntxid, merchantData) {
|
w.createPaymentTx({
|
||||||
|
uri: uri,
|
||||||
|
memo: memo
|
||||||
|
}, function(ntxid, merchantData) {
|
||||||
if (w.totalCopayers > 1) {
|
if (w.totalCopayers > 1) {
|
||||||
should.exist(ntxid);
|
should.exist(ntxid);
|
||||||
console.log('Sent TX proposal to other copayers:');
|
console.log('Sent TX proposal to other copayers:');
|
||||||
console.log([ntxid, merchantData]);
|
console.log([ntxid, merchantData]);
|
||||||
server.close(function() {
|
return done();
|
||||||
done();
|
} else {
|
||||||
|
console.log('Sending TX to merchant server:');
|
||||||
|
console.log(ntxid);
|
||||||
|
w.sendPaymentTx(ntxid, { memo: memo }, function(txid, merchantData) {
|
||||||
|
should.exist(txid);
|
||||||
|
console.log('TX sent:');
|
||||||
|
console.log([ntxid, merchantData]);
|
||||||
|
return done();
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('#send a payment request with merchant prefix', function(done) {
|
||||||
|
var w = createWallet();
|
||||||
|
should.exist(w);
|
||||||
|
var address = 'Merchant: ' + server.uri + '/request\nMemo: foo';
|
||||||
|
var commentText = 'Hello, server. I\'d like to make a payment.';
|
||||||
|
var uri;
|
||||||
|
|
||||||
|
// Replicates code in controllers/send.js:
|
||||||
|
if (address.indexOf('bitcoin:') === 0) {
|
||||||
|
uri = copay.HDPath.parseBitcoinURI(address);
|
||||||
|
} else if (address.indexOf('Merchant: ') === 0) {
|
||||||
|
uri = address.split(/\s+/)[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
w.createTx(uri, commentText, function(ntxid, merchantData) {
|
||||||
|
if (w.totalCopayers > 1) {
|
||||||
|
should.exist(ntxid);
|
||||||
|
console.log('Sent TX proposal to other copayers:');
|
||||||
|
console.log([ntxid, merchantData]);
|
||||||
|
return done();
|
||||||
} else {
|
} else {
|
||||||
console.log('Sending TX to merchant server:');
|
console.log('Sending TX to merchant server:');
|
||||||
console.log(ntxid);
|
console.log(ntxid);
|
||||||
|
|
@ -685,11 +719,39 @@ describe('PayPro (in Wallet) model', function() {
|
||||||
should.exist(txid);
|
should.exist(txid);
|
||||||
console.log('TX sent:');
|
console.log('TX sent:');
|
||||||
console.log([ntxid, merchantData]);
|
console.log([ntxid, merchantData]);
|
||||||
server.close(function() {
|
return done();
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('#send a payment request with bitcoin uri', function(done) {
|
||||||
|
var w = createWallet();
|
||||||
|
should.exist(w);
|
||||||
|
var address = 'bitcoin:2NBzZdFBoQymDgfzH2Pmnthser1E71MmU47?amount=0.00003&r=' + server.uri + '/request';
|
||||||
|
var commentText = 'Hello, server. I\'d like to make a payment.';
|
||||||
|
w.createTx(address, commentText, function(ntxid, merchantData) {
|
||||||
|
if (w.totalCopayers > 1) {
|
||||||
|
should.exist(ntxid);
|
||||||
|
console.log('Sent TX proposal to other copayers:');
|
||||||
|
console.log([ntxid, merchantData]);
|
||||||
|
return done();
|
||||||
|
} else {
|
||||||
|
console.log('Sending TX to merchant server:');
|
||||||
|
console.log(ntxid);
|
||||||
|
w.sendTx(ntxid, function(txid, merchantData) {
|
||||||
|
should.exist(txid);
|
||||||
|
console.log('TX sent:');
|
||||||
|
console.log([ntxid, merchantData]);
|
||||||
|
return done();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('#close payment server', function(done) {
|
||||||
|
server.close(function() {
|
||||||
|
return done();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue