Skip to content
Draft
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## Next Release

- Sends card details in the request body instead of the URL query string when `ReferralCustomer.addCreditCard` creates a Stripe token

## v9.0.0-rc.1 (2026-09-08)

- Breaking: Node 18+ is now required (built-in `fetch`)
Expand Down
7 changes: 5 additions & 2 deletions src/services/referral_customer_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,15 @@
expirationYear: string,
cvc: string,
): Promise<string> {
const searchParams = new URLSearchParams({
// Card details must travel in the form-encoded request body, never in the URL,
// so they cannot end up in access logs, proxy logs, or Referer headers.
const formBody = new URLSearchParams({
'card[number]': number,
'card[exp_month]': expirationMonth,
'card[exp_year]': expirationYear,
'card[cvc]': cvc,
});
const url = `https://api.stripe.com/v1/tokens?${searchParams.toString()}`;
const url = 'https://api.stripe.com/v1/tokens';

try {
const response = await fetch(url, {
Expand All @@ -85,6 +87,7 @@
Authorization: `Bearer ${stripeKey}`,
'Content-Type': 'application/x-www-form-urlencoded',
},
body: formBody.toString(),
});

if (!response.ok) {
Expand All @@ -95,7 +98,7 @@

return body.id as string;
} catch (error) {
throw new ExternalApiError({

Check failure on line 101 in src/services/referral_customer_service.ts

View workflow job for this annotation

GitHub Actions / build

test/services/referral_customer.test.ts > ReferralCustomer Service > add a referral user credit card

Error: Communication with Stripe failed, please try again later ❯ _sendCardDetailsToStripe src/services/referral_customer_service.ts:101:11 ❯ ReferralCustomerService.addCreditCard src/services/referral_customer_service.ts:193:34 ❯ test/services/referral_customer.test.ts:100:27 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { code: undefined, errors: undefined, statusCode: undefined }

Check failure on line 101 in src/services/referral_customer_service.ts

View workflow job for this annotation

GitHub Actions / coverage

test/services/referral_customer.test.ts > ReferralCustomer Service > add a referral user credit card

Error: Communication with Stripe failed, please try again later ❯ _sendCardDetailsToStripe src/services/referral_customer_service.ts:101:11 ❯ ReferralCustomerService.addCreditCard src/services/referral_customer_service.ts:193:34 ❯ test/services/referral_customer.test.ts:100:27 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { code: undefined, errors: undefined, statusCode: undefined }
message: util.format(Constants.EXTERNAL_API_CALL_FAILED, 'Stripe'),
code: undefined,
statusCode: undefined,
Expand Down
Loading