serialize payment request for signature
This commit is contained in:
parent
e48561302b
commit
71e226b782
|
@ -167,6 +167,15 @@ PayPro.prototype.setObj = function(obj) {
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
PayPro.prototype.serializeForSig = function() {
|
||||||
|
if (this.messageType !== 'PaymentRequest')
|
||||||
|
throw new Error('serializeForSig is only for PaymentRequest');
|
||||||
|
|
||||||
|
this.message.set('signature', new Buffer([]));
|
||||||
|
var buf = this.serialize();
|
||||||
|
return buf;
|
||||||
|
};
|
||||||
|
|
||||||
PayPro.prototype.serialize = function() {
|
PayPro.prototype.serialize = function() {
|
||||||
//protobufjs returns either a Buffer or an ArrayBuffer
|
//protobufjs returns either a Buffer or an ArrayBuffer
|
||||||
//but we always want a Buffer (which browserify understands, browser or no)
|
//but we always want a Buffer (which browserify understands, browser or no)
|
||||||
|
|
|
@ -177,6 +177,22 @@ describe('PayPro', function() {
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('#serializeForSig', function() {
|
||||||
|
|
||||||
|
it('should serialize a PaymentRequest and not fail', function() {
|
||||||
|
var pd = new PayPro.PaymentDetails();
|
||||||
|
pd.set('time', 0);
|
||||||
|
var pdbuf = pd.toBuffer();
|
||||||
|
|
||||||
|
var paypro = new PayPro();
|
||||||
|
paypro.makePaymentRequest();
|
||||||
|
paypro.set('serialized_payment_details', pdbuf);
|
||||||
|
var buf = paypro.serializeForSig();
|
||||||
|
buf.length.should.be.greaterThan(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
describe('#serialize', function() {
|
describe('#serialize', function() {
|
||||||
|
|
||||||
it('should serialize', function() {
|
it('should serialize', function() {
|
||||||
|
|
Loading…
Reference in New Issue