Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions 1 examples/webhook-signing/nextjs/next-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />
/// <reference types="next/navigation-types/compat/navigation" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
4 changes: 4 additions & 0 deletions 4 src/stripe.core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import {createWebhooks} from './Webhooks.js';
import {ApiVersion} from './apiVersion.js';
import {CryptoProvider} from './crypto/CryptoProvider.js';
import {Decimal} from './Decimal.js';
import {HttpClient, HttpClientResponse} from './net/HttpClient.js';
import {PlatformFunctions} from './platform/PlatformFunctions.js';
import * as resources from './resources.js';
Expand Down Expand Up @@ -82,6 +83,7 @@
Stripe.HttpClientResponse = HttpClientResponse;
Stripe.CryptoProvider = CryptoProvider;
Stripe.webhooks = createWebhooks(platformFunctions);
Stripe.Decimal = Decimal;
Comment thread
prathmesh-stripe marked this conversation as resolved.

function Stripe(
this: StripeObject,
Expand Down Expand Up @@ -162,6 +164,8 @@
// Expose StripeResource on the instance too
// @ts-ignore
this.StripeResource = Stripe.StripeResource;
// @ts-ignore
this.Decimal = Stripe.Decimal;
}

Stripe.errors = _Error;
Expand Down Expand Up @@ -196,9 +200,9 @@

Stripe.prototype = {
// Properties are set in the constructor above
_appInfo: undefined!,

Check warning on line 203 in src/stripe.core.ts

View workflow job for this annotation

GitHub Actions / Static Checks

Forbidden non-null assertion
on: null!,

Check warning on line 204 in src/stripe.core.ts

View workflow job for this annotation

GitHub Actions / Static Checks

Forbidden non-null assertion
off: null!,

Check warning on line 205 in src/stripe.core.ts

View workflow job for this annotation

GitHub Actions / Static Checks

Forbidden non-null assertion
once: null!,
VERSION: null!,
StripeResource: null!,
Expand Down
6 changes: 4 additions & 2 deletions 6 testProjects/cjs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ try {
});
} catch (e) {
if (e instanceof stripe.errors.StripeError) {
console.log("Caught StripeError");
console.log('Caught StripeError');
} else {
throw e;
}
Expand All @@ -22,7 +22,7 @@ async function exampleFunction(args) {
await stripe.paymentIntents.create(args);
} catch (e) {
if (e instanceof stripe.errors.StripeInvalidRequestError) {
console.log("Caught StripeInvalidRequestError");
console.log('Caught StripeInvalidRequestError');
} else {
throw e;
}
Expand All @@ -35,3 +35,5 @@ exampleFunction({
confirm: true,
payment_method: 'pm_card_visa',
});

stripe.Decimal.from('1.1');
2 changes: 2 additions & 0 deletions 2 testProjects/esbuild/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ const stripe = new Stripe("i'm not a real key", {
protocol: 'http',
});

Stripe.Decimal.from('1.9');

try {
throw new stripe.errors.StripeAPIError({
charge: 'foo',
Expand Down
2 changes: 2 additions & 0 deletions 2 testProjects/mjs-ts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,5 @@ exampleFunction({
confirm: true,
payment_method: 'pm_card_visa',
});

Stripe.Decimal.from('1.0');
3 changes: 3 additions & 0 deletions 3 testProjects/mjs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ assert(Stripe.StripeResource.MAX_BUFFERED_REQUEST_METRICS);

assert(Stripe.webhooks);
assert(Stripe.resources);
assert(Stripe.Decimal);

const stripe = new Stripe(process.argv[2], {
host: process.env.STRIPE_MOCK_HOST || 'localhost',
Expand All @@ -75,6 +76,8 @@ assert(stripe.on);
assert(stripe.off);
assert(stripe.once);

Stripe.Decimal.from('1.1');

try {
throw new stripe.errors.StripeError({
charge: 'foo',
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.