Skip to content

Commit

Permalink
Merge pull request #134 from stripe/mlm-add-fraud-reporting-methods
Browse files Browse the repository at this point in the history
Add fraud reporting methods
  • Loading branch information
mlm-stripe committed Dec 17, 2014
2 parents e45a802 + dc2567b commit 33a14a2
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -74,6 +74,8 @@ stripe.customers.create({
* `setMetadata(chargeId, metadataObject)` ([metadata info](https://stripe.com/docs/api/node#metadata))
* `setMetadata(chargeId, key, value)`
* `getMetadata(chargeId)`
* `markAsSafe(chargeId)`
* `markAsFraudulent(chargeId)`
* coupons
* [`create(params)`](https://stripe.com/docs/api/node#create_coupon)
* [`list([params])`](https://stripe.com/docs/api/node#list_coupons)
Expand Down
9 changes: 8 additions & 1 deletion lib/resources/Charges.js
Expand Up @@ -62,6 +62,13 @@ module.exports = StripeResource.extend({
method: 'POST',
path: '/{chargeId}/refunds/{refundId}',
urlParams: ['chargeId', 'refundId']
})
}),

markAsSafe: function(chargeId) {
return this.update(chargeId, {'fraud_details': {'user_report': 'safe'}})
},

markAsFraudulent: function(chargeId) {
return this.update(chargeId, {'fraud_details': {'user_report': 'fraudulent'}})
}
});
29 changes: 29 additions & 0 deletions test/resources/Charges.spec.js
Expand Up @@ -202,4 +202,33 @@ describe('Charge Resource', function() {

});

describe('markAsFraudulent', function() {

it('Sends the correct request', function() {

stripe.charges.markAsFraudulent('chargeIdExample3242');
expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'POST',
url: '/v1/charges/chargeIdExample3242',
data: { 'fraud_details': {'user_report': 'fraudulent' }}
});

});

});

describe('markAsSafe', function() {

it('Sends the correct request', function() {

stripe.charges.markAsSafe('chargeIdExample3242');
expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'POST',
url: '/v1/charges/chargeIdExample3242',
data: { 'fraud_details': {'user_report': 'safe' }}
});

});

});
});

0 comments on commit 33a14a2

Please sign in to comment.