nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: gcanti/fp-ts
Pull request #475 (2018-06-07 11:13:01)

added foldr and foldrL
Add foldr and foldrL function for Array, see the issue #469


Patch:
diff --git a/src/Array.ts b/src/Array.ts
index 8ac2f539..05806b36 100644
--- a/src/Array.ts
+++ b/src/Array.ts
@@ -242,6 +242,24 @@ export const foldL = <A, B>(as: Array<A>, nil: () => B, cons: (head: A, tail: Ar
   return isEmpty(as) ? nil() : cons(as[0], as.slice(1))
 }
 
+/**
+ * Break an array into its initial elements and the last element
+ * @param as
+ * @param b
+ * @param cons
+ */
+export const foldr = <A, B>(as: Array<A>, b: B, cons: (init: Array<A>, last: A) => B): B =>
+  isEmpty(as) ? b : cons(as.slice(0, as.length - 1), as[as.length - 1])
+
+/**
+ * Lazy version of `foldr`
+ * @param as
+ * @param nil
+ * @param cons
+ */
+export const foldrL = <A, B>(as: Array<A>, nil: () => B, cons: (init: Array<A>, last: A) => B): B =>
+  isEmpty(as) ? nil() : cons(as.slice(0, as.length - 1), as[as.length - 1])
+
 /**
  * Same as `reduce` but it carries over the intermediate steps
  *


Test patch:
diff --git a/test/Array.ts b/test/Array.ts
index 88d1f700..ab4c13d6 100644
--- a/test/Array.ts
+++ b/test/Array.ts
@@ -43,7 +43,9 @@ import {
   takeWhile,
   uniq,
   updateAt,
-  zip
+  zip,
+  foldrL,
+  foldr
 } from '../src/Array'
 import { left, right } from '../src/Either'
 import { fold as foldMonoid, monoidSum } from '../src/Monoid'
@@ -328,6 +330,16 @@ describe('Array', () => {
     assert.strictEqual(len([1, 2, 3]), 3)
   })
 
+  it('foldr', () => {
+    const len = <A>(as: Array<A>): number => foldr(as, 0, (init, _) => 1 + len(init))
+    assert.strictEqual(len([1, 2, 3]), 3)
+  })
+
+  it('foldrL', () => {
+    const len = <A>(as: Array<A>): number => foldrL(as, () => 0, (init, _) => 1 + len(init))
+    assert.strictEqual(len([1, 2, 3]), 3)
+  })
+
   it('scanLeft', () => {
     const f = (b: number, a: number) => b - a
     assert.deepEqual(scanLeft([1, 2, 3], 10, f), [10, 9, 7, 4])
Repository: gcanti/fp-ts
Pull request #637 (2018-11-20 11:49:57)

Fix taskify with immutable arguments.
`taskify` mutates the `args` adding a callback every time the task runs, causing the wrapping promise not being resolved. This PR fixes this behaviour.



Patch:
diff --git a/src/TaskEither.ts b/src/TaskEither.ts
index b0584877..33204f67 100644
--- a/src/TaskEither.ts
+++ b/src/TaskEither.ts
@@ -331,8 +331,9 @@ export function taskify<L, R>(f: Function): () => TaskEither<L, R> {
       new Task(
         () =>
           new Promise(resolve => {
-            args.push((e: L, r: R) => (e != null ? resolve(eitherLeft<L, R>(e)) : resolve(eitherRight<L, R>(r))))
-            f.apply(null, args)
+            const cbResolver = (e: L, r: R) =>
+              e != null ? resolve(eitherLeft<L, R>(e)) : resolve(eitherRight<L, R>(r))
+            f.apply(null, args.concat(cbResolver))
           })
       )
     )


Test patch:
diff --git a/test/TaskEither.ts b/test/TaskEither.ts
index 489ab808..057dbd83 100644
--- a/test/TaskEither.ts
+++ b/test/TaskEither.ts
@@ -255,6 +255,18 @@ describe('TaskEither', () => {
     )
   })
 
+  it('composed taskify', () => {
+    const api = (callback: (err: Error | null | undefined, result?: string) => void): void => {
+      callback(null, 'ok')
+    }
+    const taskApi = taskify(api)()
+
+    return Promise.all([taskApi.run(), taskApi.run()]).then(([e1, e2]) => {
+      assert.deepEqual(e1, eitherRight('ok'))
+      assert.deepEqual(e2, eitherRight('ok'))
+    })
+  })
+
   it('alt', () => {
     const l1 = fromLeft<string, number>('foo')
     const l2 = fromLeft<string, number>('bar')
Repository: stripe/stripe-node
Pull request #1800 (2023-05-25 23:43:07)

Update cloudflare-pages test project build
The test has started leaving around a `_worker.bundle` file for me locally. Update the build script to remove all build artifacts after testing.


Patch:
diff --git a/.gitignore b/.gitignore
index 449e6235..b0cb00fb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,3 +8,4 @@ coverage
 .idea
 testProjects/**/node_modules
 testProjects/**/package-lock.json
+testProjects/**/_worker.*


Test patch:
diff --git a/testProjects/cloudflare-pages/package.json b/testProjects/cloudflare-pages/package.json
index 82183707..8870a472 100644
--- a/testProjects/cloudflare-pages/package.json
+++ b/testProjects/cloudflare-pages/package.json
@@ -3,7 +3,7 @@
   "version": "1.0.0",
   "description": "",
   "scripts": {
-    "build": "wrangler pages functions build && rm _worker.js"
+    "build": "wrangler pages functions build"
   },
   "keywords": [],
   "author": "",
Repository: stripe/stripe-node
Pull request #632 (2019-05-23 23:19:46)

Add support for radar.early_fraud_warning resource
r? @brandur-stripe 
cc @stripe/api-libraries 

Add support for `radar.early_fraud_warning` resource


Patch:
diff --git a/lib/resources.js b/lib/resources.js
index a0dc8515..c491e28b 100644
--- a/lib/resources.js
+++ b/lib/resources.js
@@ -61,6 +61,7 @@ module.exports = {
     Transactions: require('./resources/Issuing/Transactions'),
   }),
   Radar: resourceNamespace('radar', {
+    EarlyFraudWarnings: require('./resources/Radar/EarlyFraudWarnings'),
     ValueLists: require('./resources/Radar/ValueLists'),
     ValueListItems: require('./resources/Radar/ValueListItems'),
   }),
diff --git a/lib/resources/Radar/EarlyFraudWarnings.js b/lib/resources/Radar/EarlyFraudWarnings.js
new file mode 100644
index 00000000..f24ad19d
--- /dev/null
+++ b/lib/resources/Radar/EarlyFraudWarnings.js
@@ -0,0 +1,9 @@
+'use strict';
+
+const StripeResource = require('../../StripeResource');
+
+module.exports = StripeResource.extend({
+  path: 'radar/early_fraud_warnings',
+
+  includeBasic: ['list', 'retrieve'],
+});


Test patch:
diff --git a/test/resources/Radar/EarlyFraudWarnings.spec.js b/test/resources/Radar/EarlyFraudWarnings.spec.js
new file mode 100644
index 00000000..e443ef08
--- /dev/null
+++ b/test/resources/Radar/EarlyFraudWarnings.spec.js
@@ -0,0 +1,32 @@
+'use strict';
+
+const stripe = require('../../../testUtils').getSpyableStripe();
+const expect = require('chai').expect;
+
+describe('Radar', () => {
+  describe('EarlyFraudWarnings Resource', () => {
+    describe('retrieve', () => {
+      it('Sends the correct request', () => {
+        stripe.radar.earlyFraudWarnings.retrieve('issfr_123');
+        expect(stripe.LAST_REQUEST).to.deep.equal({
+          method: 'GET',
+          url: '/v1/radar/early_fraud_warnings/issfr_123',
+          data: {},
+          headers: {},
+        });
+      });
+    });
+
+    describe('list', () => {
+      it('Sends the correct request', () => {
+        stripe.radar.earlyFraudWarnings.list();
+        expect(stripe.LAST_REQUEST).to.deep.equal({
+          method: 'GET',
+          url: '/v1/radar/early_fraud_warnings',
+          data: {},
+          headers: {},
+        });
+      });
+    });
+  });
+});
Repository: stripe/stripe-node
Pull request #660 (2019-07-24 21:38:29)

Interpret any string in options as an API Key instead of using a regex
r? @ob-stripe 
cc @stripe/api-libraries @jlomas-stripe @paulasjes-stripe @remi-stripe 

`isAuthKey` relies on a regex which assumes a fixed length of a secret key token. This assumption recently broke. 

Looking at the code, passing a string which does not fit the regex currently noops completely, so I chose to simply check whether it is a non-empty string and if so, assume it is an auth key. 

Note that you could maybe interpret this to be a breaking change, because you could have previously written this: 

```js
stripe.customers.retrieve('cus_123', 'garbage');
```
which would have been equivalent to `stripe.customers.retrieve('cus_123')` and worked fine, but with this change would fail with a bad secret key. 

I think that's fine, but not sure and want to check with others. 

Relatedly, I moved `isAuthKey` from `utils` but that didn't seem to be publicly exported so I think that's fine. 


Patch:
diff --git a/lib/utils.js b/lib/utils.js
index d2aeb370..4bbccd90 100644
--- a/lib/utils.js
+++ b/lib/utils.js
@@ -17,10 +17,6 @@ const OPTIONS_KEYS = [
 ];
 
 const utils = (module.exports = {
-  isAuthKey: (key) => {
-    return typeof key == 'string' && /^(?:[a-z]{2}_)?[A-z0-9]{32}$/.test(key);
-  },
-
   isOptionsHash: (o) => {
     return isPlainObject(o) && OPTIONS_KEYS.some((key) => hasOwn.call(o, key));
   },
@@ -121,7 +117,7 @@ const utils = (module.exports = {
     };
     if (args.length > 0) {
       const arg = args[args.length - 1];
-      if (utils.isAuthKey(arg)) {
+      if (typeof arg === 'string') {
         opts.auth = args.pop();
       } else if (utils.isOptionsHash(arg)) {
         const params = args.pop();


Test patch:
diff --git a/test/utils.spec.js b/test/utils.spec.js
index 861998fc..8f8fd8ab 100644
--- a/test/utils.spec.js
+++ b/test/utils.spec.js
@@ -211,6 +211,14 @@ describe('utils', () => {
       });
       expect(args.length).to.equal(0);
     });
+    it('assumes any string is an api key', () => {
+      const args = ['yolo'];
+      expect(utils.getOptionsFromArgs(args)).to.deep.equal({
+        auth: 'yolo',
+        headers: {},
+      });
+      expect(args.length).to.equal(0);
+    });
     it('parses an idempotency key', () => {
       const args = [{foo: 'bar'}, {idempotency_key: 'foo'}];
       expect(utils.getOptionsFromArgs(args)).to.deep.equal({
Repository: stripe/stripe-node
Pull request #668 (2019-07-30 05:27:11)

Move Balance History to /v1/balance_transactions
r? @ob-stripe @rattrayalex-stripe 
cc @stripe/api-libraries 


Patch:
diff --git a/lib/resources/BalanceTransactions.js b/lib/resources/BalanceTransactions.js
index 3e3a6c7d..cad69117 100644
--- a/lib/resources/BalanceTransactions.js
+++ b/lib/resources/BalanceTransactions.js
@@ -3,7 +3,7 @@
 const StripeResource = require('../StripeResource');
 
 module.exports = StripeResource.extend({
-  path: 'balance/history',
+  path: 'balance_transactions',
 
   includeBasic: ['list', 'retrieve'],
 });


Test patch:
diff --git a/test/resources/BalanceTransactions.spec.js b/test/resources/BalanceTransactions.spec.js
index 72ede8cc..05b569ba 100644
--- a/test/resources/BalanceTransactions.spec.js
+++ b/test/resources/BalanceTransactions.spec.js
@@ -9,7 +9,7 @@ describe('BalanceTransactions Resource', function() {
       stripe.balanceTransactions.retrieve('txn_123');
       expect(stripe.LAST_REQUEST).to.deep.equal({
         method: 'GET',
-        url: '/v1/balance/history/txn_123',
+        url: '/v1/balance_transactions/txn_123',
         headers: {},
         data: {},
       });
@@ -21,7 +21,7 @@ describe('BalanceTransactions Resource', function() {
       stripe.balanceTransactions.list();
       expect(stripe.LAST_REQUEST).to.deep.equal({
         method: 'GET',
-        url: '/v1/balance/history',
+        url: '/v1/balance_transactions',
         headers: {},
         data: {},
       });
Repository: stripe/stripe-node
Pull request #671 (2019-07-31 22:21:11)

Remove uuid dep, include a prefix in generated idempotency keys
r? @richardm-stripe
cc @stripe/api-libraries @paulasjes-stripe @ob-stripe @brandur-stripe 

I checked and this should be well within our idempotency key length limits. 

brandur-stripe: You have my vote! Was surprised to find out that the `uuid` package was that big.

Patch:
diff --git a/lib/StripeResource.js b/lib/StripeResource.js
index cb25c7ea..1cf9e993 100644
--- a/lib/StripeResource.js
+++ b/lib/StripeResource.js
@@ -3,7 +3,6 @@
 const http = require('http');
 const https = require('https');
 const path = require('path');
-const uuid = require('uuid/v4');
 
 const utils = require('./utils');
 const Error = require('./Error');
@@ -265,7 +264,7 @@ StripeResource.prototype = {
   _defaultIdempotencyKey(method) {
     // If this is a POST and we allow multiple retries, ensure an idempotency key.
     if (method === 'POST' && this._stripe.getMaxNetworkRetries() > 0) {
-      return uuid();
+      return `stripe-node-retry-${utils.uuid4()}`;
     }
     return null;
   },
diff --git a/lib/utils.js b/lib/utils.js
index f62c7e83..4489ef15 100644
--- a/lib/utils.js
+++ b/lib/utils.js
@@ -341,6 +341,17 @@ const utils = (module.exports = {
 
     return result;
   },
+
+  /**
+   * https://stackoverflow.com/a/2117523
+   */
+  uuid4: () => {
+    return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
+      const r = (Math.random() * 16) | 0;
+      const v = c === 'x' ? r : (r & 0x3) | 0x8;
+      return v.toString(16);
+    });
+  },
 });
 
 function emitWarning(warning) {
diff --git a/package.json b/package.json
index b7a4c612..89559056 100644
--- a/package.json
+++ b/package.json
@@ -42,8 +42,7 @@
   },
   "dependencies": {
     "lodash.isplainobject": "^4.0.6",
-    "qs": "^6.6.0",
-    "uuid": "^3.3.2"
+    "qs": "^6.6.0"
   },
   "license": "MIT",
   "scripts": {


Test patch:
diff --git a/test/StripeResource.spec.js b/test/StripeResource.spec.js
index 94dadc86..6aea57b8 100644
--- a/test/StripeResource.spec.js
+++ b/test/StripeResource.spec.js
@@ -1,7 +1,6 @@
 'use strict';
 
 const utils = require('../testUtils');
-const uuid = require('uuid/v4');
 
 const nock = require('nock');
 
@@ -357,7 +356,7 @@ describe('StripeResource', () => {
       });
 
       it('should reuse the given idempotency key provided for retries', (done) => {
-        const key = uuid();
+        const key = 'i-am-a-key';
         let headers;
 
         nock(`https://${options.host}`)
Repository: stripe/stripe-node
Pull request #675 (2019-08-09 22:10:05)

[codegen] Remove subscription schedule revisions 
r? @ob-stripe 
cc @stripe/api-libraries 


Patch:
diff --git a/lib/resources/SubscriptionSchedules.js b/lib/resources/SubscriptionSchedules.js
index 73689a96..9409315d 100644
--- a/lib/resources/SubscriptionSchedules.js
+++ b/lib/resources/SubscriptionSchedules.js
@@ -17,15 +17,4 @@ module.exports = StripeResource.extend({
     method: 'POST',
     path: '/{schedule}/release',
   }),
-
-  listRevisions: stripeMethod({
-    method: 'GET',
-    path: '/{schedule}/revisions',
-    methodType: 'list',
-  }),
-
-  retrieveRevision: stripeMethod({
-    method: 'GET',
-    path: '/{schedule}/revisions/{revision}',
-  }),
 });


Test patch:
diff --git a/test/resources/SubscriptionSchedule.spec.js b/test/resources/SubscriptionSchedule.spec.js
index 68107b33..1eebd70a 100644
--- a/test/resources/SubscriptionSchedule.spec.js
+++ b/test/resources/SubscriptionSchedule.spec.js
@@ -4,7 +4,6 @@ const stripe = require('../../testUtils').getSpyableStripe();
 const expect = require('chai').expect;
 
 const SCHEDULE_TEST_ID = 'sub_sched_123';
-const REVISION_TEST_ID = 'sub_sched_rev_123';
 
 describe('Subscription Schedule Resource', () => {
   describe('cancel', () => {
@@ -88,33 +87,4 @@ describe('Subscription Schedule Resource', () => {
       });
     });
   });
-
-  describe('Revision methods', () => {
-    describe('retrieveRevision', () => {
-      it('Sends the correct request', () => {
-        stripe.subscriptionSchedules.retrieveRevision(
-          SCHEDULE_TEST_ID,
-          REVISION_TEST_ID
-        );
-        expect(stripe.LAST_REQUEST).to.deep.equal({
-          method: 'GET',
-          url: `/v1/subscription_schedules/${SCHEDULE_TEST_ID}/revisions/${REVISION_TEST_ID}`,
-          headers: {},
-          data: {},
-        });
-      });
-    });
-
-    describe('listRevisions', () => {
-      it('Sends the correct request', () => {
-        stripe.subscriptionSchedules.listRevisions(SCHEDULE_TEST_ID);
-        expect(stripe.LAST_REQUEST).to.deep.equal({
-          method: 'GET',
-          url: `/v1/subscription_schedules/${SCHEDULE_TEST_ID}/revisions`,
-          headers: {},
-          data: {},
-        });
-      });
-    });
-  });
 });
Repository: stripe/stripe-node
Pull request #678 (2019-08-13 00:05:23)

[codegen] Add `subscriptionItems.createUsageRecord()` method
r? @rattrayalex-stripe (feel free to change reviewer)
cc @stripe/api-libraries

- [x] Sanity check for correctness.
- [x] Ensure appropriate test coverage (ie; write tests).



Patch:
diff --git a/lib/resources/SubscriptionItems.js b/lib/resources/SubscriptionItems.js
index 13f25916..4ff4eb8e 100644
--- a/lib/resources/SubscriptionItems.js
+++ b/lib/resources/SubscriptionItems.js
@@ -1,9 +1,15 @@
 'use strict';
 
 const StripeResource = require('../StripeResource');
+const stripeMethod = StripeResource.method;
 
 module.exports = StripeResource.extend({
   path: 'subscription_items',
 
   includeBasic: ['create', 'del', 'list', 'retrieve', 'update'],
+
+  createUsageRecord: stripeMethod({
+    method: 'POST',
+    path: '/{subscriptionItem}/usage_records',
+  }),
 });


Test patch:
diff --git a/test/resources/SubscriptionItems.spec.js b/test/resources/SubscriptionItems.spec.js
index 73e59d58..56ba399e 100644
--- a/test/resources/SubscriptionItems.spec.js
+++ b/test/resources/SubscriptionItems.spec.js
@@ -80,4 +80,21 @@ describe('SubscriptionItems Resource', () => {
       });
     });
   });
+
+  describe('createUsageRecord', () => {
+    it('Sends the correct request', () => {
+      const data = {
+        quantity: 123,
+        timestamp: 123321,
+        action: 'increment',
+      };
+      stripe.subscriptionItems.createUsageRecord('si_123', data);
+      expect(stripe.LAST_REQUEST).to.deep.equal({
+        method: 'POST',
+        url: '/v1/subscription_items/si_123/usage_records',
+        headers: {},
+        data,
+      });
+    });
+  });
 });
Repository: stripe/stripe-node
Pull request #724 (2019-11-06 03:25:04)

Add support for `Mandate`
r? @ob-stripe 
cc @stripe/api-libraries 


Patch:
diff --git a/lib/resources.js b/lib/resources.js
index 890f5f68..ebfbb107 100644
--- a/lib/resources.js
+++ b/lib/resources.js
@@ -26,6 +26,7 @@ module.exports = {
   Invoices: require('./resources/Invoices'),
   InvoiceItems: require('./resources/InvoiceItems'),
   IssuerFraudRecords: require('./resources/IssuerFraudRecords'),
+  Mandates: require('./resources/Mandates'),
   OAuth: require('./resources/OAuth'),
   Orders: require('./resources/Orders'),
   OrderReturns: require('./resources/OrderReturns'),
diff --git a/lib/resources/Mandates.js b/lib/resources/Mandates.js
new file mode 100644
index 00000000..20f808d3
--- /dev/null
+++ b/lib/resources/Mandates.js
@@ -0,0 +1,9 @@
+'use strict';
+
+const StripeResource = require('../StripeResource');
+
+module.exports = StripeResource.extend({
+  path: 'mandates',
+
+  includeBasic: ['retrieve'],
+});


Test patch:
diff --git a/test/resources/Mandates.spec.js b/test/resources/Mandates.spec.js
new file mode 100644
index 00000000..08e31a3c
--- /dev/null
+++ b/test/resources/Mandates.spec.js
@@ -0,0 +1,20 @@
+'use strict';
+
+const stripe = require('../../testUtils').getSpyableStripe();
+const expect = require('chai').expect;
+
+const MANDATE_TEST_ID = 'mandate_123';
+
+describe('Mandate Resource', () => {
+  describe('retrieve', () => {
+    it('Sends the correct request', () => {
+      stripe.mandates.retrieve(MANDATE_TEST_ID);
+      expect(stripe.LAST_REQUEST).to.deep.equal({
+        method: 'GET',
+        url: `/v1/mandates/${MANDATE_TEST_ID}`,
+        data: {},
+        headers: {},
+      });
+    });
+  });
+});
Repository: stripe/stripe-node
Pull request #732 (2019-11-26 20:56:01)

Add support for CreditNote preview
Codegen for openapi ab6898a

r? @ob-stripe 
cc @stripe/api-libraries 


Patch:
diff --git a/lib/resources/CreditNotes.js b/lib/resources/CreditNotes.js
index e38dd295..b11f8069 100644
--- a/lib/resources/CreditNotes.js
+++ b/lib/resources/CreditNotes.js
@@ -8,6 +8,11 @@ module.exports = StripeResource.extend({
 
   includeBasic: ['create', 'list', 'retrieve', 'update'],
 
+  preview: stripeMethod({
+    method: 'GET',
+    path: '/preview',
+  }),
+
   voidCreditNote: stripeMethod({
     method: 'POST',
     path: '/{id}/void',


Test patch:
diff --git a/test/resources/CreditNotes.spec.js b/test/resources/CreditNotes.spec.js
index ad0a2c74..914c8e31 100644
--- a/test/resources/CreditNotes.spec.js
+++ b/test/resources/CreditNotes.spec.js
@@ -61,6 +61,23 @@ describe('CreditNotes Resource', () => {
     });
   });
 
+  describe('preview', () => {
+    it('Sends the correct request', () => {
+      const data = {
+        amount: 100,
+        invoice: 'in_123',
+      };
+      stripe.creditNotes.preview(data);
+      expect(stripe.LAST_REQUEST).to.deep.equal({
+        method: 'GET',
+        url: '/v1/credit_notes/preview?amount=100&invoice=in_123',
+        headers: {},
+        data: {},
+        settings: {},
+      });
+    });
+  });
+
   describe('voidCreditNote', () => {
     it('Sends the correct request', () => {
       stripe.creditNotes.voidCreditNote('cn_123');
Repository: stripe/stripe-node
Pull request #785 (2020-01-30 07:04:56)

Fix file uploads with nested params
Previously we were getting our keys from a flattened object, but then using the flattened key to access the original object, so 💥.

Now with 100% less 💥.

r? @brandur-stripe 
cc @stripe/api-libraries


Patch:
diff --git a/lib/multipart.js b/lib/multipart.js
index f4d429b1..90682aed 100644
--- a/lib/multipart.js
+++ b/lib/multipart.js
@@ -28,8 +28,10 @@ const multipartDataGenerator = (method, data, headers) => {
     return `"${s.replace(/"|"/g, '%22').replace(/\r\n|\r|\n/g, ' ')}"`;
   }
 
-  for (const k in utils.flattenAndStringify(data)) {
-    const v = data[k];
+  const flattenedData = utils.flattenAndStringify(data);
+
+  for (const k in flattenedData) {
+    const v = flattenedData[k];
     push(`--${segno}`);
     if (v.hasOwnProperty('data')) {
       push(


Test patch:
diff --git a/testUtils/index.js b/testUtils/index.js
index fdca4687..78a86938 100644
--- a/testUtils/index.js
+++ b/testUtils/index.js
@@ -56,8 +56,22 @@ const utils = (module.exports = {
         if (host) {
           req.host = host;
         }
-        stripeInstance.REQUESTS.push(req);
-        cb.call(this, null, {});
+
+        const handleMockRequest = (err, req) => {
+          stripeInstance.REQUESTS.push(req);
+          cb.call(this, err, {});
+        };
+
+        if (this.requestDataProcessor) {
+          this.requestDataProcessor(
+            method,
+            data,
+            options.headers,
+            handleMockRequest
+          );
+        } else {
+          handleMockRequest(null, req);
+        }
       };
     }