Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix delete/update by customer ref.

  • Loading branch information...
commit 1cba77200e44aacb1037a13f4fa1501732e52464 1 parent fa5f801
@chjj authored
Showing with 10 additions and 4 deletions.
  1. +10 −4 lib/charged.js
View
14 lib/charged.js
@@ -86,8 +86,11 @@ Charged.prototype.deleteCustomerById = function(name, callback) {
};
Charged.prototype.deleteCustomerByRef = function(ref, callback) {
- var path = '/customers/lookup?reference=' + escape(ref);
- return this.delete(path, callback, 'customer');
+ var self = this;
+ return this.getCustomerByRef(ref, function(err, customer) {
+ if (err) return callback(err);
+ return self.deleteCustomer(customer.id, options, callback);
+ });
};
Charged.prototype.createCustomer = function(options, callback) {
@@ -103,8 +106,11 @@ Charged.prototype.updateCustomerById = function(name, options, callback) {
};
Charged.prototype.updateCustomerByRef = function(ref, options, callback) {
- var path = '/customers/lookup?reference=' + escape(ref);
- return this.put(path, options, callback, 'customer');
+ var self = this;
+ return this.getCustomerByRef(ref, function(err, customer) {
+ if (err) return callback(err);
+ return self.updateCustomer(customer.id, options, callback);
+ });
};
/**
Please sign in to comment.
Something went wrong with that request. Please try again.