billing - PM billing details - handle no adresses
MODIFY
src/integration/billing/stripe/StripeBillingIntegration.ts
src/integration/billing/stripe/StripeBillingIntegration.ts
@@ -556,12 +556,14 @@ export default class StripeBillingIntegration extends BillingIntegration {
customer: customerID
});
// Add billing_details to the payment method
- // Stripe expects a Two-letter country code (ISO 3166-1 alpha-2) in the address
- await this.stripe.paymentMethods.update(
- paymentMethodId, {
- billing_details: StripeHelpers.buildBillingDetails(user)
+ const billingDetails: Stripe.PaymentMethodUpdateParams.BillingDetails = StripeHelpers.buildBillingDetails(user);
+ let paymentMethodUpdateParams: Stripe.PaymentMethodUpdateParams;
+ if (billingDetails) {
+ paymentMethodUpdateParams = {
+ billing_details: billingDetails
+ };
}
- );
+ await this.stripe.paymentMethods.update(paymentMethodId, paymentMethodUpdateParams);
await Logging.logInfo({
tenantID: this.tenantID,
source: Constants.CENTRAL_SERVER,

MODIFY
src/integration/billing/stripe/StripeHelpers.ts
src/integration/billing/stripe/StripeHelpers.ts
@@ -143,15 +143,16 @@ export default class StripeHelpers {
}
public static buildBillingDetails(user: User): Stripe.PaymentMethodUpdateParams.BillingDetails {
- if (!user.address) {
- return null;
- }
- return {
+ const billingDetails: Stripe.PaymentMethodUpdateParams.BillingDetails = {
name: Utils.buildUserFullName(user, false, false),
email: user.email,
/* phone: user.phone, */
- address: StripeHelpers.buildStripeAddress(user)
};
+ const address = StripeHelpers.buildStripeAddress(user);
+ if (address) {
+ billingDetails.address = address;
+ }
+ return billingDetails;
}
public static buildStripeAddress(user: User): Stripe.Address {

billing - PM billing details - handle no adresses