Skip to content
This repository has been archived by the owner on Apr 3, 2019. It is now read-only.

Commit

Permalink
Merge pull request #132 from cmgustavo/bug/handler-error-paypro
Browse files Browse the repository at this point in the history
PayPro: Verification errors
  • Loading branch information
matiu committed Sep 15, 2015
2 parents b342e6d + 1306b8d commit 856bc85
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,16 @@ db/*

docs

# VIM ignore
[._]*.s[a-w][a-z]
[._]s[a-w][a-z]
*.un~
Session.vim
.netrwhist
*~

# OSX
.DS_Store
.AppleDouble
.LSOverride

14 changes: 6 additions & 8 deletions lib/paypro.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,20 +93,18 @@ PayPro.get = function(opts, cb) {

http(opts, function(err, dataBuffer) {
if (err) return cb(err);
var request;
var request, verified, signature, serializedDetails;
try {
var body = BitcorePayPro.PaymentRequest.decode(dataBuffer);
request = (new BitcorePayPro()).makePaymentRequest(body);
signature = request.get('signature');
serializedDetails = request.get('serialized_payment_details');
// Verify the signature
verified = request.verify(true);
} catch (e) {
return cb('Could not parse payment protocol:' + e)
return cb('Could not parse payment protocol: ' + e)
}

var signature = request.get('signature');
var serializedDetails = request.get('serialized_payment_details');

// Verify the signature
var verified = request.verify(true);

// Get the payment details
var decodedDetails = BitcorePayPro.PaymentDetails.decode(serializedDetails);
var pd = new BitcorePayPro();
Expand Down

0 comments on commit 856bc85

Please sign in to comment.