Coverage for functions \ flipdare \ message \ error_message.py: 96%

135 statements  

« prev     ^ index     » next       coverage.py v7.13.0, created at 2026-05-08 12:22 +1000

1#!/usr/bin/env python 

2# Copyright (c) 2026 Flipdare Pty Ltd. All rights reserved. 

3# 

4# This file is part of Flipdare's proprietary software and contains 

5# confidential and copyrighted material. Unauthorised copying, 

6# modification, distribution, or use of this file is strictly 

7# prohibited without prior written permission from Flipdare Pty Ltd. 

8# 

9# This software includes third-party components licensed under MIT, 

10# BSD, and Apache 2.0 licences. See THIRD_PARTY_NOTICES for details. 

11# 

12 

13from __future__ import annotations 

14 

15from enum import StrEnum 

16from typing import Any, Self 

17from collections.abc import Mapping 

18 

19from flipdare.app_log import LOG 

20from flipdare.generated import ( 

21 ErrorCodeSchema, 

22 ErrorEmailSchema, 

23 ErrorFieldSchema, 

24 ErrorMethodSchema, 

25 ErrorPledgeSchema, 

26 ErrorStripeSchema, 

27 AppPaymentErrorCode, 

28) 

29from flipdare.generated.schema.error.error_object_schema import ErrorObjectSchema 

30 

31__all__ = ["ErrorMessage"] 

32 

33 

34ErrorSchemaType = ( 

35 ErrorEmailSchema 

36 | ErrorCodeSchema 

37 | ErrorMethodSchema 

38 | ErrorFieldSchema 

39 | ErrorEmailSchema 

40 | ErrorStripeSchema 

41 | ErrorPledgeSchema 

42 | ErrorObjectSchema 

43) 

44 

45 

46class ErrorMessage(StrEnum): 

47 message: str 

48 schema_class: type[ErrorSchemaType] | None 

49 

50 def __new__( 

51 cls, 

52 code: str, 

53 message: str, 

54 schema_class: type[ErrorSchemaType] | None = None, 

55 ) -> Self: 

56 # Create the string-valued enum member 

57 obj = str.__new__(cls, code) 

58 obj._value_ = code 

59 

60 # Attach the extra metadata to the member instance 

61 obj.message = message 

62 obj.schema_class = schema_class 

63 return obj 

64 

65 def required_fields(self) -> list[str] | None: 

66 schema_cls = self.schema_class 

67 

68 if schema_cls is None: 

69 return None 

70 

71 return list(schema_cls.__annotations__.keys()) 

72 

73 def formatted(self, data: Mapping[str, Any] | None = None) -> str: 

74 # Handle emails with no data 

75 if self.schema_class is None: 

76 return self.message.format() 

77 

78 if data is None: 

79 raise ValueError(f"Data is required to format this error message: {self.name}") 

80 

81 # Format the rest safely 

82 upper_context = {k.upper(): v for k, v in data.items()} 

83 

84 return self.message.format(**upper_context) 

85 

86 def formatted_payment_error( 

87 self, pledge_id: str | None = None, intent_id: str | None = None 

88 ) -> str: 

89 keys = self.required_fields() 

90 if keys is not None: 

91 missing_keys = [key for key in keys if key not in {"pledge_id", "intent_id"}] 

92 if missing_keys: 

93 # rather than raise a ValueError, just sent to unknown .. 

94 msg = ( 

95 f"ErrorMessage for code {self.name} is missing required fields: {missing_keys}" 

96 ) 

97 LOG().warning(msg) 

98 

99 error_data = {} 

100 error_data["pledge_id"] = pledge_id or "UNKNOWN" 

101 error_data["intent_id"] = intent_id or "UNKNOWN" 

102 

103 return self.message.format(**error_data) 

104 

105 @staticmethod 

106 def for_payment(error_code: AppPaymentErrorCode) -> ErrorMessage | None: 

107 mapping: dict[AppPaymentErrorCode, ErrorMessage] = { 

108 AppPaymentErrorCode.CODE_PATH_ERROR: ErrorMessage.CODE_PATH_ERROR, 

109 AppPaymentErrorCode.API_ERROR: ErrorMessage.APP_ERROR, 

110 AppPaymentErrorCode.UNKNOWN_ERROR: ErrorMessage.UNKNOWN_ERROR, 

111 # exception 

112 AppPaymentErrorCode.CARD_ERROR: ErrorMessage.STR_FX_CARD_ERROR, 

113 AppPaymentErrorCode.RATE_LIMIT_ERROR: ErrorMessage.STR_FX_RATE_LIMIT_ERROR, 

114 AppPaymentErrorCode.INVALID_REQUEST: ErrorMessage.STR_FX_INVALID_REQUEST, 

115 AppPaymentErrorCode.AUTH_ERROR: ErrorMessage.STR_FX_AUTH_ERROR, 

116 AppPaymentErrorCode.API_CONNECTION_ERROR: ErrorMessage.STR_FX_API_CONNECTION_ERROR, 

117 # fx 

118 AppPaymentErrorCode.FX_ACCOUNT_ESTIMATE_ERROR: ErrorMessage.STR_FX_ACCOUNT_ESTIMATE_ERROR, 

119 AppPaymentErrorCode.FX_ESTIMATE_ERROR: ErrorMessage.STR_FX_ESTIMATE_ERROR, 

120 AppPaymentErrorCode.LINK_CREATE_FAILED: ErrorMessage.STR_ACC_LINK_CREATE_FAILED, 

121 AppPaymentErrorCode.ACCOUNT_CREATE_FAILED: ErrorMessage.STR_ACC_CREATE_FAILED, 

122 # onboard 

123 AppPaymentErrorCode.INVALID_USER: ErrorMessage.STR_ACC_INVALID_USER, 

124 AppPaymentErrorCode.ACCOUNT_NOT_FOUND: ErrorMessage.STR_ACC_NOT_FOUND, 

125 AppPaymentErrorCode.INVALID_SETTINGS: ErrorMessage.STR_ACC_INVALID_SETTINGS, 

126 AppPaymentErrorCode.ACCOUNT_UPDATE_FAILED: ErrorMessage.STR_ACC_UPDATE_FAILED, 

127 AppPaymentErrorCode.ACCOUNT_UPGRADE_EXISTING: ErrorMessage.STR_UPGRADE_EXISTING_ACCOUNT, 

128 AppPaymentErrorCode.ACCOUNT_UPGRADE_FAILED: ErrorMessage.STR_ACCOUNT_UPGRADE_FAILED, 

129 # intent 

130 AppPaymentErrorCode.CANCEL_INTENT_FAILED: ErrorMessage.STR_INT_CANCEL_FAILED, 

131 AppPaymentErrorCode.LOOSING_MONEY: ErrorMessage.STR_INT_LOOSE_MONEY, 

132 AppPaymentErrorCode.AMOUNT_TOO_SMALL: ErrorMessage.STR_INT_AMOUNT_TOO_SMALL, 

133 AppPaymentErrorCode.FEE_REFUND_FAILED: ErrorMessage.STR_INT_FEE_REFUND_FAILED, 

134 AppPaymentErrorCode.REFUND_FAILED: ErrorMessage.STR_INT_REFUND_FAILED, 

135 # intent - charge 

136 AppPaymentErrorCode.PAYMENT_CREATE_FAILED: ErrorMessage.STR_INT_CHARGE_CREATE_FAILED, 

137 AppPaymentErrorCode.PAYMENT_UPDATE_FAILED: ErrorMessage.STR_INT_CHARGE_UPDATE_FAILED, 

138 AppPaymentErrorCode.PAYMENT_MISSING: ErrorMessage.STR_INT_CHARGE_MISSING, 

139 AppPaymentErrorCode.PAYMENT_CAPTURE_FAILED: ErrorMessage.STR_INT_CHARGE_CAPTURE_FAILED, 

140 AppPaymentErrorCode.MALFORMED_INTENT: ErrorMessage.STR_INT_CHARGE_MALFORMED, 

141 AppPaymentErrorCode.INTENT_NOT_CONFIRMED: ErrorMessage.STR_INT_NOT_CONFIRMED, 

142 AppPaymentErrorCode.INTENT_PENDING: ErrorMessage.STR_INT_INTENT_PENDING, 

143 # intent - charge processing 

144 AppPaymentErrorCode.INSUFFICIENT_FUNDS: ErrorMessage.STR_INT_INSUFFICIENT_FUNDS, 

145 AppPaymentErrorCode.ALREADY_CAPTURED: ErrorMessage.STR_INT_ALREADY_CAPTURED, 

146 AppPaymentErrorCode.DUPLICATE: ErrorMessage.STR_INT_DUPLICATE, 

147 AppPaymentErrorCode.FRAUDULENT: ErrorMessage.STR_INT_FRAUDULENT, 

148 AppPaymentErrorCode.CHARGE_CANCELED: ErrorMessage.STR_INT_CHARGE_CANCELED, 

149 AppPaymentErrorCode.CHARGE_DISPUTED: ErrorMessage.STR_INT_CHARGE_DISPUTED, 

150 AppPaymentErrorCode.CHARGE_FAILED: ErrorMessage.STR_INT_CHARGE_FAILED, 

151 AppPaymentErrorCode.CHARGE_REQUIRES_CAPTURE: ErrorMessage.STR_INT_CHARGE_REQUIRES_CAPTURE, 

152 AppPaymentErrorCode.CHARGE_AUTHORIZE_FAILED: ErrorMessage.STR_INT_CHARGE_AUTHORIZE_FAILED, 

153 AppPaymentErrorCode.CHARGE_REQUIRES_REAUTH: ErrorMessage.STR_INT_CHARGE_REQUIRES_REAUTH, 

154 AppPaymentErrorCode.CHARGE_REQUIRES_3D_SECURE: ErrorMessage.STR_INT_CHARGE_REQUIRES_3D_SECURE, 

155 AppPaymentErrorCode.CHARGE_REQUIRES_NEW_PAYMENT_METHOD: ErrorMessage.STR_INT_CHARGE_REQUIRES_NEW_PAYMENT_METHOD, 

156 # misc 

157 AppPaymentErrorCode.INTENT_TIMEOUT: ErrorMessage.STR_INT_TIMEOUT, 

158 } 

159 

160 return mapping.get(error_code) 

161 

162 # ======================================================================== 

163 # REQUEST ERRORS 

164 # ======================================================================== 

165 

166 INVALID_REQUEST = ( 

167 "invalid-request", 

168 """We couldn't process your request due to invalid or missing information. 

169Please double check and try again. If the problem persists, please contact support with the code '{CODE}'""", 

170 ErrorCodeSchema, 

171 ) 

172 

173 INVALID_METHOD = ( 

174 "invalid-method", 

175 """The method '{METHOD}' is not allowed for a '{FN_NAME}' request. 

176Please try again. If the problem persists, please contact support.""", 

177 ErrorMethodSchema, 

178 ) 

179 

180 # ======================================================================== 

181 # GENERIC ERRORS 

182 # ======================================================================== 

183 

184 APP_ERROR = ( 

185 "app", 

186 """We screwed up. Please try again. 

187If the problem persists, please contact support with any error messages you receive and we investigate ASAP.""", 

188 ) 

189 

190 INTERNAL_ERROR = ( 

191 "internal", 

192 """Something screwy happened on the backend, please try again. 

193If the problem persists, please contact support.""", 

194 ) 

195 

196 EMAIL_DOWN_ERROR = ( 

197 "email-down", 

198 """Our email service is currently down. Please try again later. 

199If the problem persists, please contact support.""", 

200 ) 

201 

202 FIRESTORE_GET_ERROR = ( 

203 "firestore_get", 

204 """Not us. Google internal databases are down! 

205Please try again soon. If the problem persists, please contact support.""", 

206 ) 

207 

208 MISSING_USER = ( 

209 "missing-user", 

210 """Glitch in the matrix! We coundn't find your account. 

211Please try signing out and back in again. If the problem persists, please contact support.""", 

212 ) 

213 

214 MISSING_DATA = ( 

215 "missing-data", 

216 """We are missing some required information to process your request. 

217Please double check and try again. If the problem persists, please contact support.""", 

218 ) 

219 

220 INVALID_CONTEXT = ( 

221 "invalid-context", 

222 """We had an issue gathering all the information for the '{OBJECT}' 

223Please try again. If the problem please contact support with the code 'invalid-context-{OBJECT}'""", 

224 ErrorObjectSchema, 

225 ) 

226 

227 MISSING_ID = ( 

228 "missing-id", 

229 """We had a problem getting the ID for your request. 

230Hopefully it's just a temporary glitch, so it should automatically resolve. 

231If the problem persists, please contact support with the error message you received.""", 

232 ) 

233 

234 MISSING_EMAIL_ERROR = ( 

235 "missing-email", 

236 """Something screwy happened, we couldn't find the email address in your request. 

237Please double check and try again. If the problem persists, please contact support.""", 

238 ) 

239 

240 DB_EXCEPTION = ( 

241 "db-exception", 

242 """We had a problem accessing our databases. 

243Please try again. If the problem persists, please contact support.""", 

244 ) 

245 

246 CODE_PATH_ERROR = ( 

247 "code-path", 

248 """We had a problem processing your request. 

249Please try again. If the problem persists, please contact support with the error message you received.""", 

250 ) 

251 

252 UNKNOWN_ERROR = ( 

253 "unknown", 

254 """Hmm. This is embarrassing. We dont known wtf happened! 

255Please try again. If the problem persists, please contact support with the error message you received.""", 

256 ) 

257 

258 # ======================================================================== 

259 # EMAIL ERRORS 

260 # ======================================================================== 

261 

262 INVALID_EMAIL = ( 

263 "invalid-email", 

264 """Please try again, we could not process the email address you provided: '{EMAIL}'. 

265 If the problem persists, please contact support.""", 

266 ErrorEmailSchema, 

267 ) 

268 

269 NO_ACCOUNT_FOR_EMAIL = ( 

270 "no-account-for-email", 

271 """We couldn't find an account with the email address: '{EMAIL}'. 

272Please double check and try again. If the problem persists, please contact support.""", 

273 ErrorEmailSchema, 

274 ) 

275 

276 NO_DOC_ID_FOR_EMAIL = ( 

277 "no-doc-id-for-email", 

278 """We had a problem getting the user ID for the account associated with: '{EMAIL}'. 

279Hopefully it's just a temporary glitch, so it should automatically resolve., 

280If the problem persists, please contact support with the error message you received.""", 

281 ErrorEmailSchema, 

282 ) 

283 

284 # ======================================================================== 

285 # DOC ERRORS 

286 # ======================================================================== 

287 

288 MISSING_DOC = ( 

289 "missing-doc", 

290 """Our bad. We couldn't find the {LABEL} with {FIELD_NAME}={FIELD_VALUE}. 

291Please try Signing Out/In. If the problem persists, please contact support with the error message you 

292received.""", 

293 ErrorFieldSchema, 

294 ) 

295 

296 DATA_LOAD_ERROR = ( 

297 "data-load", 

298 """Hmm. We had a problem loading some data. Please try again. 

299If the problem persists, please contact support with the code: '{CODE}'""", 

300 ErrorCodeSchema, 

301 ) 

302 

303 # ======================================================================== 

304 # AUTH ERRORS 

305 # ======================================================================== 

306 

307 MISSING_REQUEST_PIN_CODE = ( 

308 "missing-request-pin-code", 

309 """We are missing the pin code to verify your request. 

310Please try again. If the problem persists, please contact support.""", 

311 ) 

312 

313 MISSING_SERVER_PIN_CODE = ( 

314 "missing-server-pin-code", 

315 """We are missing the pin code to verify your request. 

316Please click on the resend code button to get a new pin code and try again. 

317If the problem persists, please contact support.""", 

318 ) 

319 

320 PIN_CODE_MISMATCH = ( 

321 "pin-code-mismatch", 

322 """The pin code you provided is invalid. 

323Please double check and try again. If the problem persists, please contact support.""", 

324 ) 

325 

326 FIREBASE_AUTH_ERROR = ( 

327 "firebase-auth-error", 

328 """We had a problem verifying your account information. 

329Please try again. If the problem persists, please contact support.""", 

330 ) 

331 

332 UNSUBSCRIBE_ERROR = ( 

333 "unsubscribe-error", 

334 """We couldn't process your unsubscribe request. 

335Please try again later. If the problem persists, please contact support.""", 

336 ) 

337 

338 DELETE_ACCOUNT_ERROR = ( 

339 "delete-account-error", 

340 """We couldn't process your account deletion request. 

341Please try again later. If the problem persists, please contact support.""", 

342 ) 

343 

344 UNAUTHORIZED_ERROR = ( 

345 "unauthorized-error", 

346 """We couldn't double check it was you. Might just be a glitch. 

347Please try again. If the problem persists, try restarting the app.""", 

348 ) 

349 

350 INVALID_TOKEN = ( 

351 "invalid-token", 

352 """Hmm. Something screwy happened with your authentication token. 

353Please try signing out and back in again. If the problem persists, please contact support.""", 

354 ) 

355 

356 AUTH_ERROR = ( 

357 "auth", 

358 """Not us. Google authentication seems to be down! 

359Please try again soon. If the problem persists, please contact support.""", 

360 ) 

361 

362 # ======================================================================== 

363 # SEARCH ERRORS 

364 # ======================================================================== 

365 

366 SEARCH_ERROR = ( 

367 "search", 

368 """Our bad. We couldn't search for your awesome query. 

369Please try again. If the problem persists, please contact support.""", 

370 ) 

371 

372 SEARCH_KNOWN_NO_UID = ( 

373 "search-known-no-uid", 

374 """We had a problem verifying your account information for this search. 

375Please try again. If the problem persists, please contact support.""", 

376 ) 

377 

378 SEARCH_DOWN = ( 

379 "search-down", 

380 """Well this is embarrassing. Our search is down.. 

381Please try again soon. If the problem persists, please contact support.""", 

382 ) 

383 

384 SEARCH_QUERY_PREPARE_ERROR = ( 

385 "search-query-prepare", 

386 """We had a problem running your awesome search! 

387Please try again. If the problem persists, please contact support.""", 

388 ) 

389 

390 SEARCH_RESULT_PROCESS_ERROR = ( 

391 "search-result-process", 

392 """Our bad! We had a problem retrieving the gold. 

393Please try again. If the problem persists, please contact support.""", 

394 ) 

395 

396 DB_SEARCH_ERROR = ( 

397 "db-search", 

398 """Well this is embarrassing. Google's internal databases appear to be down! 

399Please try again soon. If the problem persists, please contact support.""", 

400 ) 

401 

402 BAD_SEARCH_DATA = ( 

403 "bad-search-data", 

404 """We found some bad search data. Please try again. 

405If the problem persists, please contact support.""", 

406 ) 

407 

408 # ======================================================================== 

409 # CONTENT PROCESSING ERRORS 

410 # ======================================================================== 

411 

412 DARE_MISSING_VIDEO = ( 

413 "dare-missing-video", 

414 """We couldn't find the video for your dare. 

415Please try again soon. If the problem persists, you might need to recreate the dare or 

416contact support if this is not possible.""", 

417 ) 

418 

419 DELETE_PARTIAL_FAILED = ( 

420 "delete-partial-failed", 

421 """Your account deletion request was partially successful. 

422Please contact support to complete the process.""", 

423 ) 

424 

425 FLAGGED = ( 

426 "flagged", 

427 """To check the status of the flag report, please sign-in to your account and click 

428on he 'Issues' screen in the `Admin` section. 

429Depending on the severity of the issue, some functionality may be restricted until the issue is resolved.""", 

430 ) 

431 

432 # ======================================================================== 

433 # STRIPE ERRORS 

434 # ======================================================================== 

435 

436 STR_CODE_PATH_ERROR = ( 

437 "stripe-code-path", 

438 """We had a problem talking on the backend with Stripe. 

439Please try again. If the problem persists, please contact support with the error message you received.""", 

440 ) 

441 

442 STR_UNKNOWN_ERROR = ( 

443 "stripe-unknown", 

444 """Stripe is not playing nice! Please try again later. 

445If the problem persists, please contact support with the error message you received.""", 

446 ) 

447 

448 STR_API_ERROR = ( 

449 "stripe-api", 

450 """Hmm, Stripe is having some issues. Please try again later. 

451If the problem persists, please contact support with the error message you received.""", 

452 ) 

453 

454 STR_UPGRADE_EXISTING_ACCOUNT = ( 

455 "stripe-upgrade-existing-account", 

456 """You already have a Stripe account. If you wish to change accounts, please contact support.""", 

457 ) 

458 

459 STR_ACCOUNT_UPGRADE_FAILED = ( 

460 "stripe-account-upgrade-failed", 

461 """We had a problem upgrading your Stripe account. 

462Please try again. If the problem persists, please contact support with the error message you received.""", 

463 ) 

464 

465 # ======================================================================== 

466 # STRIPE EXCEPTION ERRORS 

467 # ======================================================================== 

468 

469 STR_FX_CARD_ERROR = ( 

470 "stripe-card", 

471 """A card error occurred. 

472Please check the card details and try again. 

473If the problem persists, please contact support with the error message you received.""", 

474 ) 

475 

476 STR_FX_RATE_LIMIT_ERROR = ( 

477 "stripe-rate-limit", 

478 """Too many requests made to the Stripe API too quickly. 

479Please wait and try again. 

480If the problem persists, please contact support with the error message you received.""", 

481 ) 

482 

483 STR_FX_INVALID_REQUEST = ( 

484 "stripe-invalid-request", 

485 """Hmm, there was an error with the information you provided for your Stripe account. 

486Please double check and try again. If the problem persists, please contact support with the error message you received.""", 

487 ) 

488 

489 STR_FX_AUTH_ERROR = ( 

490 "stripe-auth", 

491 """Authentication with Stripe's API failed. Please try again later. 

492If the problem persists, please contact support with the error message you received.""", 

493 ) 

494 

495 STR_FX_API_CONNECTION_ERROR = ( 

496 "stripe-api-connection", 

497 """Stripe maybe down. Please try again later. 

498If the problem persists, please contact support with the error message you received.""", 

499 ) 

500 

501 # ======================================================================== 

502 # STRIPE FX ERRORS 

503 # ======================================================================== 

504 

505 STR_FX_ACCOUNT_ESTIMATE_ERROR = ( 

506 "stripe-acc-estimate", 

507 """We had a problem estimating the FX conversion for your payment. 

508Please try again. If the problem persists, please contact support with the error message you received.""", 

509 ) 

510 

511 STR_FX_ESTIMATE_ERROR = ( 

512 "stripe-estimate", 

513 """We had a problem estimating the FX conversion for your payment. 

514Please try again. If the problem persists, please contact support with the error message you received.""", 

515 ) 

516 

517 # ======================================================================== 

518 # STRIPE ACCOUNT ERRORS 

519 # ======================================================================== 

520 

521 STR_ACC_LINK_CREATE_FAILED = ( 

522 "stripe-link-create-failed", 

523 """Hmm, there was an error creating your Stripe account link. 

524Please try again. If the problem persists, please contact support with the error message you received.""", 

525 ) 

526 

527 STR_ACC_CREATE_FAILED = ( 

528 "stripe-acc-create-failed", 

529 """Hmm, there was an error creating your Stripe account. 

530Please try again. If the problem persists, please contact support with the error message you received.""", 

531 ) 

532 

533 STR_ACC_INVALID_USER = ( 

534 "stripe-invalid-user", 

535 """Not us. Google internal databases are down! Please try again soon. 

536If the problem persists, please contact support with the error message you received.""", 

537 ) 

538 

539 STR_ACC_NOT_FOUND = ( 

540 "stripe-not-found", 

541 """Hmm, we couldn't find your Stripe account. 

542Please try again. If the problem persists, please contact support with the error message you received.""", 

543 ) 

544 

545 STR_ACC_INVALID_SETTINGS = ( 

546 "stripe-invalid-settings", 

547 """Hmm, there was an error with your Stripe account settings. 

548Try Signing Out/In to refresh your account information. 

549If the problem persists, please contact support with the error message you received.""", 

550 ) 

551 

552 STR_ACC_UPDATE_FAILED = ( 

553 "stripe-update-failed", 

554 """Hmm, there was an error updating your Stripe account. 

555Please try again. If the problem persists, please contact support with the error message you received.""", 

556 ) 

557 

558 # ======================================================================== 

559 # STRIPE INTENT ERRORS 

560 # ======================================================================== 

561 # !! 

562 # !! CRITICAL 

563 # !! 

564 STR_INVALID_API_RESPONSE = ( 

565 "stripe-invalid-api-response", 

566 """Hmm, we got an invalid response from Stripe's API that we weren't prepared to handle. 

567Please try again. If the problem persists, please contact support with the error message you {INVALID_CODE}.""", 

568 ) 

569 

570 STR_CHARGE_NOT_FOUND = ( 

571 "stripe-charge-not-found", 

572 """Hmm, we couldn't find the charge for your payment. You were not charged. 

573Please try again. If the problem persists, please contact support with the error message you received.""", 

574 ) 

575 

576 STR_INT_LOOSE_MONEY = ( 

577 "stripe-inconsistent-money", 

578 """Hmm, there was an error processing your payment with Stripe that may result in inconsistent charges. 

579The admin team has been notified and will investigate. 

580If a charge is still applied, please contact support. You will be refunded. We apologize for the inconvenience.""", 

581 ) 

582 

583 STR_INT_CANCEL_FAILED = ( 

584 "stripe-cancel-failed", 

585 """Hmm, there was an error processing your payment with Stripe. 

586The admin team has been notified and will investigate. 

587If a charge is still applied, please contact support. You will be refunded. We apologize for the inconvenience.""", 

588 ) 

589 

590 STR_INT_AMOUNT_TOO_SMALL = ( 

591 "stripe-amount-too-small", 

592 """The fee amount is too small to refund. 

593Please try again with a higher amount. 

594If the problem persists, please contact support with the error message you received.""", 

595 ) 

596 

597 STR_INT_PLEDGE_MISS_CHARGE = ( 

598 "stripe-miss-charge", 

599 """We had a problem processing your payment for pledge {PLEDGE_ID}. 

600Hopefully it's just a temporary glitch, so it should automatically resolve. 

601If the problem persists, please contact support with the error message you received.""", 

602 ErrorPledgeSchema, 

603 ) 

604 

605 STR_INT_PLEDGE_REQUIRES_REAUTH = ( 

606 "stripe-requires-reauth", 

607 """Your payment for pledge {PLEDGE_ID} requires reauthorization. 

608Please follow the instructions to reauthorize your payment. If the problem persists, please contact support.""", 

609 ErrorPledgeSchema, 

610 ) 

611 

612 STR_INT_PLEDGE_REQUIRES_3D_SECURE = ( 

613 "stripe-requires-3d-secure", 

614 """Your payment for pledge {PLEDGE_ID} requires 3D secure authorization. 

615Please follow the instructions to authorize with 3D secure. If the problem persists, please contact support.""", 

616 ErrorPledgeSchema, 

617 ) 

618 

619 STR_INT_REFUND_FAILED = ( 

620 "stripe-refund-failed", 

621 """Hmm, there was an error processing your refund ({PLEDGE_ID}) with Stripe. 

622The admin team has been notified and will investigate. 

623If a refund is still applied, please contact support. We apologize for the inconvenience.""", 

624 ErrorPledgeSchema, 

625 ) 

626 

627 STR_INT_FEE_REFUND_FAILED = ( 

628 "stripe-fee-refund-failed", 

629 """Hmm. there was an error processing your refund ({PLEDGE_ID}) with Stripe. 

630Will keep trying, and will notify of any changes.. 

631If you dont hear back within a few days, please contact support with the error message you received.""", 

632 ErrorPledgeSchema, 

633 ) 

634 

635 STR_PAYMENT_WEBHOOK_ERROR = ( 

636 "stripe-payment-webhook-error", 

637 """We had a problem processing the payment webhook from Stripe. You were not charged. 

638Please try again. If the problem persists, please contact support with the error message you received.""", 

639 ) 

640 

641 STR_PAYMENT_WEBHOOK_MISSING_METHOD = ( 

642 "stripe-payment-webhook-missing-method", 

643 """We had a problem processing the payment webhook from Stripe due to missing payment method information. You were not charged. 

644Please try again. If the problem persists, please contact support with the error message you received.""", 

645 ) 

646 

647 STR_PAYMENT_WEBHOOK_UPDATE_FAILED = ( 

648 "stripe-payment-webhook-update-failed", 

649 """We had a problem processing the payment webhook from Stripe. You were not charged. 

650Please try again. If the problem persists, please contact support with the error message you received.""", 

651 ) 

652 

653 # ======================================================================== 

654 # STRIPE INTENT ERRORS (OTHER) 

655 # ======================================================================== 

656 

657 STR_INT_CHARGE_CREATE_FAILED = ( 

658 "stripe-create-failed", 

659 """Hmm, there was an error creating your payment. 

660Please try again. If the problem persists, please contact support with the error message you received.""", 

661 ) 

662 

663 STR_INT_CHARGE_UPDATE_FAILED = ( 

664 "stripe-update-failed", 

665 """Hmm, there was an error updating your payment. 

666Please try again. If the problem persists, please contact support with the error message you received.""", 

667 ) 

668 

669 STR_INT_CHARGE_MISSING = ( 

670 "stripe-missing", 

671 """Hmm, we couldn't find the charge for your payment. 

672Please try again. If the problem persists, please contact support with the error message you received.""", 

673 ) 

674 

675 STR_INT_NOT_CONFIRMED = ( 

676 "stripe-not-confirmed", 

677 """Hmm. there was an error confirming your payment with Stripe. You were not charged. 

678Please try again. If the problem persists, please contact support with the error message you received.""", 

679 ) 

680 

681 STR_INT_CHARGE_CAPTURE_FAILED = ( 

682 "stripe-capture-failed", 

683 """Hmm. there was an error capturing your payment with Stripe. You were not charged. 

684Please try again. If the problem persists, please contact support with the error message you received.""", 

685 ) 

686 

687 STR_INT_CHARGE_MALFORMED = ( 

688 "stripe-malformed-payment", 

689 """Hmm. there was an error processing your payment with Stripe. 

690Please try again. If the problem persists, please contact support with the error message you received.""", 

691 ) 

692 

693 STR_INT_ALREADY_CAPTURED = ( 

694 "stripe-already-captured", 

695 """Hmm, this is embarrassing. Stripe might be drunk! Dont worry, 

696our support team has been notified and will contact you if any action is needed on your part. 

697We apologize for the inconvenience.""", 

698 ) 

699 

700 STR_INT_DUPLICATE = ( 

701 "stripe-duplicate", 

702 """Hmm, this is embarrassing. Stripe is smoking something it shouldn't be! Dont worry, 

703our support team has been notified and will contact you if any action is needed on your part. 

704We apologize for the inconvenience.""", 

705 ) 

706 

707 STR_INT_FRAUDULENT = ( 

708 "stripe-fraudulent", 

709 """Hmm, Stripe thinks your card is fraudulent, You might want to contact Stripe. 

710You will need to enter new payment information to complete your pledge. We apologize for the inconvenience.""", 

711 ) 

712 

713 STR_INT_CHARGE_CANCELED = ( 

714 "stripe-canceled", 

715 """Your charge was canceled. Please try again with a different payment method. 

716The admin team has been notified and will investigate. 

717If a charge is still applied, please contact support. We apologize for the inconvenience.""", 

718 ) 

719 

720 STR_INT_CHARGE_DISPUTED = ( 

721 "stripe-disputed", 

722 """We are away of your charge dispute and our support team is gathering evidence. 

723We will update you if any action is needed on your part. We apologize for the inconvenience.""", 

724 ) 

725 

726 STR_INT_CHARGE_FAILED = ( 

727 "stripe-failed", 

728 """Hmm, there was an error processing your payment with Stripe. 

729The admin team has been notified and will investigate. 

730If a charge is still applied, please contact support. We apologize for the inconvenience.""", 

731 ) 

732 

733 STR_INT_INTENT_NOT_CONFIRMED = ( 

734 "stripe-intent-not-confirmed", 

735 """Hmm. there was an error confirming your payment with Stripe. 

736Please try again. If the problem persists, please contact support with the error message you received.""", 

737 ) 

738 

739 STR_INT_INSUFFICIENT_FUNDS = ( 

740 "stripe-insufficient-funds", 

741 """Your card has insufficient funds to complete this transaction. 

742Please try again with a different payment method. If the problem persists, please contact support with the 

743error message you received.""", 

744 ) 

745 

746 STR_INT_TIMEOUT = ( 

747 "stripe-timeout", 

748 """We have given up! For some reason, we couldn't process your payment with Stripe 

749within the expected time frame. 

750Please contact support if you would like us to investigate further.""", 

751 ) 

752 

753 STR_INT_INTENT_PENDING = ( 

754 "stripe-intent-pending", 

755 """Your payment is still pending. 

756This can happen when the card issuer or payment network needs to process the payment, 

757or if additional verification steps are required. 

758Please wait a few moments and try again. 

759If the problem persists, please contact support with the error message you received.""", 

760 ) 

761 

762 STR_INT_CHARGE_REQUIRES_CAPTURE = ( 

763 "stripe-requires-capture", 

764 """Your payment was authorized but requires capture to complete. 

765Please try again. If the problem persists, please contact support with the error message you received.""", 

766 ) 

767 

768 STR_INT_CHARGE_AUTHORIZE_FAILED = ( 

769 "stripe-authorize-failed", 

770 """Hmm. there was an error authorizing your payment method with Stripe. 

771Please try again. If the problem persists, please contact support with the error message you received.""", 

772 ) 

773 

774 STR_INT_CHARGE_REQUIRES_REAUTH = ( 

775 "stripe-requires-reauth", 

776 """Your payment requires reauthorization. 

777Please follow the instructions to reauthorize your payment. If the problem persists, please contact support with 

778the error message you received.""", 

779 ) 

780 

781 STR_INT_CHARGE_REQUIRES_3D_SECURE = ( 

782 "stripe-requires-3d-secure", 

783 """Your payment requires 3D secure authorization. 

784Please follow the instructions to authorize with 3D secure. If the problem persists, please contact 

785support with the error message you received.""", 

786 ) 

787 

788 STR_INT_CHARGE_REQUIRES_NEW_PAYMENT_METHOD = ( 

789 "stripe_requires_new_payment_method", 

790 """Your payment requires a new payment method. 

791Please try again with a different payment method. If the problem persists, please contact support with the 

792error message you received.""", 

793 )