Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add onBehalfOf type to PaymentRequest #592

Merged
merged 2 commits into from
Apr 5, 2024
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
15 changes: 15 additions & 0 deletions tests/types/src/invalid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -416,3 +416,18 @@ stripe
// @ts-expect-error mandate_data is not a valid parameter
result.confirmationToken.mandate_data;
});

const paymentRequest = stripe.paymentRequest({
country: 'US',
currency: 'usd',
total: {
label: 'Demo total',
amount: 1000,
},
// @ts-expect-error Type 'number' is not assignable to type 'string'.
onBehalfOf: 123,
});
paymentRequest.update({
// @ts-expect-error Object literal may only specify known properties, and 'onBehalfOf' does not exist in type 'PaymentRequestUpdateOptions'.
onBehalfOf: 'acct_123',
});
7 changes: 7 additions & 0 deletions tests/types/src/valid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3184,6 +3184,13 @@ const paymentRequest: PaymentRequest = stripe.paymentRequest({
},
});

const paymentRequestOBO: PaymentRequest = stripe.paymentRequest({
country: 'US',
currency: 'usd',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also add a test in invalid.ts that checks that you cannot update onBehalfOf?

total: {label: 'Demo total', amount: 1000},
onBehalfOf: 'acct_123',
});

paymentRequest.canMakePayment().then((result) => {
if (result) {
const {applePay}: CanMakePaymentResult = result;
Expand Down
5 changes: 5 additions & 0 deletions types/stripe-js/payment-request.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,11 @@ export interface PaymentRequestOptions {
*/
applePay?: ApplePayOption;

/**
* The Stripe account ID which is the business of record.
*/
onBehalfOf?: string;

/**
* @deprecated
* Use disableWallets instead.
Expand Down
Loading