Socket
Socket
Sign inDemoInstall

ghost-payment-service

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ghost-payment-service - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

15

lib/authorizeNet/authorizeNetService.js
'use strict';
const Promise = require('bluebird');
const _ = require('lodash');

@@ -121,2 +122,7 @@ const AbstractGhostPaymentService = require('../AbstractGhostPaymentService');

)
.then(result => {
if (!result._original || result._original.errors) reject(this._buildChargeError(result._original.errors));
resolve(_.mapValues(result._original, (val) => _.head(val))); // auth net returns an object where each value is an array, map to normal object
})
.catch(err => reject('Unable to process transaction, please try again or contact support.'));
})

@@ -195,2 +201,11 @@ }

}
/**
* @param {[object]} errors
* @return {String}
*/
static _buildChargeError(errors) {
if (!Array.isArray(errors) || !errors.length || !errors[0].error[0].errorText) return 'Unable to complete transaction.';
return errors[0].error[0].errorText;
}

@@ -197,0 +212,0 @@ _validateBillingAddress (data = {}) {

2

lib/authorizeNet/authorizeNetServiceFactory.js

@@ -9,3 +9,3 @@ 'use strict';

* @param {GhostPaymentService_AuthorizeNetConfig} options
* @return {StripeService}
* @return {AuthorizeNetService}
*/

@@ -12,0 +12,0 @@ static create (options = {}) {

{
"name": "ghost-payment-service",
"version": "1.0.0",
"version": "1.0.1",
"description": "nodejs client to interact with the authorize.net & stripe apis",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -206,4 +206,50 @@ const Chai = require('chai');

it('should create a charge', () => {
return service.createCharge({
amount: Chance.integer({ min: 100, max: 1000000 }),
customerId: customer.customerProfileId,
cardId: customer.paymentProfiles.customerPaymentProfileId
})
.then(charge => {
expect(charge).to.exist;
expect(charge.transId).to.exist;
})
});
it('should return an error when an incorrect customerId is provided', () => {
return service.createCharge({
amount: Chance.integer({ min: 100, max: 1000000 }),
customerId: 'fakecustomerid',
cardId: customer.paymentProfiles.customerPaymentProfileId
})
.then(charge => expect(charge).to.not.exist)
.catch(err => expect(err).to.exist)
});
it('should return an error when an incorrect amount is provided', () => {
return service.createCharge({
amount: -10000,
customerId: customer.customerProfileId,
cardId: customer.paymentProfiles.customerPaymentProfileId
})
.then(charge => expect(charge).to.not.exist)
.catch(err => expect(err).to.exist)
});
it('should return an error when an incorrect cardId is provided', () => {
return service.createCharge({
amount: 10000,
customerId: customer.customerProfileId,
cardId: 'nocard'
})
.then(charge => expect(charge).to.not.exist)
.catch(err => expect(err).to.exist)
});

@@ -210,0 +256,0 @@ });

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc