fix: remove and/or resolve fixmes & todos in stripe compatibility (#218)

This commit is contained in:
Nishant Joshi
2022-12-23 00:56:41 +05:30
committed by GitHub
parent 87cedc296e
commit 9e0deac3c5
3 changed files with 138 additions and 136 deletions

View File

@ -157,138 +157,142 @@ pub enum StripeErrorCode {
}, },
#[error(error_type = StripeErrorType::InvalidRequestError, code = "", message = "The mandate information is invalid. {message}")] #[error(error_type = StripeErrorType::InvalidRequestError, code = "", message = "The mandate information is invalid. {message}")]
PaymentIntentMandateInvalid { message: String }, PaymentIntentMandateInvalid { message: String },
// TODO: Some day implement all stripe error codes https://stripe.com/docs/error-codes // [#216]: https://github.com/juspay/orca/issues/216
// AccountCountryInvalidAddress, // Implement the remaining stripe error codes
// AccountErrorCountryChangeRequiresAdditionalSteps,
// AccountInformationMismatch, /*
// AccountInvalid, AccountCountryInvalidAddress,
// AccountNumberInvalid, AccountErrorCountryChangeRequiresAdditionalSteps,
// AcssDebitSessionIncomplete, AccountInformationMismatch,
// AlipayUpgradeRequired, AccountInvalid,
// AmountTooLarge, AccountNumberInvalid,
// AmountTooSmall, AcssDebitSessionIncomplete,
// ApiKeyExpired, AlipayUpgradeRequired,
// AuthenticationRequired, AmountTooLarge,
// BalanceInsufficient, AmountTooSmall,
// BankAccountBadRoutingNumbers, ApiKeyExpired,
// BankAccountDeclined, AuthenticationRequired,
// BankAccountExists, BalanceInsufficient,
// BankAccountUnusable, BankAccountBadRoutingNumbers,
// BankAccountUnverified, BankAccountDeclined,
// BankAccountVerificationFailed, BankAccountExists,
// BillingInvalidMandate, BankAccountUnusable,
// BitcoinUpgradeRequired, BankAccountUnverified,
// CardDeclineRateLimitExceeded, BankAccountVerificationFailed,
// CardDeclined, BillingInvalidMandate,
// CardholderPhoneNumberRequired, BitcoinUpgradeRequired,
// ChargeAlreadyCaptured, CardDeclineRateLimitExceeded,
// ChargeAlreadyRefunded, CardDeclined,
// ChargeDisputed, CardholderPhoneNumberRequired,
// ChargeExceedsSourceLimit, ChargeAlreadyCaptured,
// ChargeExpiredForCapture, ChargeAlreadyRefunded,
// ChargeInvalidParameter, ChargeDisputed,
// ClearingCodeUnsupported, ChargeExceedsSourceLimit,
// CountryCodeInvalid, ChargeExpiredForCapture,
// CountryUnsupported, ChargeInvalidParameter,
// CouponExpired, ClearingCodeUnsupported,
// CustomerMaxPaymentMethods, CountryCodeInvalid,
// CustomerMaxSubscriptions, CountryUnsupported,
// DebitNotAuthorized, CouponExpired,
// EmailInvalid, CustomerMaxPaymentMethods,
// ExpiredCard, CustomerMaxSubscriptions,
// IdempotencyKeyInUse, DebitNotAuthorized,
// IncorrectAddress, EmailInvalid,
// IncorrectCvc, ExpiredCard,
// IncorrectNumber, IdempotencyKeyInUse,
// IncorrectZip, IncorrectAddress,
// InstantPayoutsConfigDisabled, IncorrectCvc,
// InstantPayoutsCurrencyDisabled, IncorrectNumber,
// InstantPayoutsLimitExceeded, IncorrectZip,
// InstantPayoutsUnsupported, InstantPayoutsConfigDisabled,
// InsufficientFunds, InstantPayoutsCurrencyDisabled,
// IntentInvalidState, InstantPayoutsLimitExceeded,
// IntentVerificationMethodMissing, InstantPayoutsUnsupported,
// InvalidCardType, InsufficientFunds,
// InvalidCharacters, IntentInvalidState,
// InvalidChargeAmount, IntentVerificationMethodMissing,
// InvalidCvc, InvalidCardType,
// InvalidExpiryMonth, InvalidCharacters,
// InvalidExpiryYear, InvalidChargeAmount,
// InvalidNumber, InvalidCvc,
// InvalidSourceUsage, InvalidExpiryMonth,
// InvoiceNoCustomerLineItems, InvalidExpiryYear,
// InvoiceNoPaymentMethodTypes, InvalidNumber,
// InvoiceNoSubscriptionLineItems, InvalidSourceUsage,
// InvoiceNotEditable, InvoiceNoCustomerLineItems,
// InvoiceOnBehalfOfNotEditable, InvoiceNoPaymentMethodTypes,
// InvoicePaymentIntentRequiresAction, InvoiceNoSubscriptionLineItems,
// InvoiceUpcomingNone, InvoiceNotEditable,
// LivemodeMismatch, InvoiceOnBehalfOfNotEditable,
// LockTimeout, InvoicePaymentIntentRequiresAction,
// Missing, InvoiceUpcomingNone,
// NoAccount, LivemodeMismatch,
// NotAllowedOnStandardAccount, LockTimeout,
// OutOfInventory, Missing,
// ParameterInvalidEmpty, NoAccount,
// ParameterInvalidInteger, NotAllowedOnStandardAccount,
// ParameterInvalidStringBlank, OutOfInventory,
// ParameterInvalidStringEmpty, ParameterInvalidEmpty,
// ParametersExclusive, ParameterInvalidInteger,
// PaymentIntentActionRequired, ParameterInvalidStringBlank,
// PaymentIntentIncompatiblePaymentMethod, ParameterInvalidStringEmpty,
// PaymentIntentInvalidParameter, ParametersExclusive,
// PaymentIntentKonbiniRejectedConfirmationNumber, PaymentIntentActionRequired,
// PaymentIntentPaymentAttemptExpired, PaymentIntentIncompatiblePaymentMethod,
// PaymentIntentUnexpectedState, PaymentIntentInvalidParameter,
// PaymentMethodBankAccountAlreadyVerified, PaymentIntentKonbiniRejectedConfirmationNumber,
// PaymentMethodBankAccountBlocked, PaymentIntentPaymentAttemptExpired,
// PaymentMethodBillingDetailsAddressMissing, PaymentIntentUnexpectedState,
// PaymentMethodCurrencyMismatch, PaymentMethodBankAccountAlreadyVerified,
// PaymentMethodInvalidParameter, PaymentMethodBankAccountBlocked,
// PaymentMethodInvalidParameterTestmode, PaymentMethodBillingDetailsAddressMissing,
// PaymentMethodMicrodepositFailed, PaymentMethodCurrencyMismatch,
// PaymentMethodMicrodepositVerificationAmountsInvalid, PaymentMethodInvalidParameter,
// PaymentMethodMicrodepositVerificationAmountsMismatch, PaymentMethodInvalidParameterTestmode,
// PaymentMethodMicrodepositVerificationAttemptsExceeded, PaymentMethodMicrodepositFailed,
// PaymentMethodMicrodepositVerificationDescriptorCodeMismatch, PaymentMethodMicrodepositVerificationAmountsInvalid,
// PaymentMethodMicrodepositVerificationTimeout, PaymentMethodMicrodepositVerificationAmountsMismatch,
// PaymentMethodProviderDecline, PaymentMethodMicrodepositVerificationAttemptsExceeded,
// PaymentMethodProviderTimeout, PaymentMethodMicrodepositVerificationDescriptorCodeMismatch,
// PaymentMethodUnactivated, PaymentMethodMicrodepositVerificationTimeout,
// PaymentMethodUnexpectedState, PaymentMethodProviderDecline,
// PaymentMethodUnsupportedType, PaymentMethodProviderTimeout,
// PayoutsNotAllowed, PaymentMethodUnactivated,
// PlatformAccountRequired, PaymentMethodUnexpectedState,
// PlatformApiKeyExpired, PaymentMethodUnsupportedType,
// PostalCodeInvalid, PayoutsNotAllowed,
// ProcessingError, PlatformAccountRequired,
// ProductInactive, PlatformApiKeyExpired,
// RateLimit, PostalCodeInvalid,
// ReferToCustomer, ProcessingError,
// RefundDisputedPayment, ProductInactive,
// ResourceAlreadyExists, RateLimit,
// ResourceMissing, ReferToCustomer,
// ReturnIntentAlreadyProcessed, RefundDisputedPayment,
// RoutingNumberInvalid, ResourceAlreadyExists,
// SecretKeyRequired, ResourceMissing,
// SepaUnsupportedAccount, ReturnIntentAlreadyProcessed,
// SetupAttemptFailed, RoutingNumberInvalid,
// SetupIntentAuthenticationFailure, SecretKeyRequired,
// SetupIntentInvalidParameter, SepaUnsupportedAccount,
// SetupIntentSetupAttemptExpired, SetupAttemptFailed,
// SetupIntentUnexpectedState, SetupIntentAuthenticationFailure,
// ShippingCalculationFailed, SetupIntentInvalidParameter,
// SkuInactive, SetupIntentSetupAttemptExpired,
// StateUnsupported, SetupIntentUnexpectedState,
// StatusTransitionInvalid, ShippingCalculationFailed,
// TaxIdInvalid, SkuInactive,
// TaxesCalculationFailed, StateUnsupported,
// TerminalLocationCountryUnsupported, StatusTransitionInvalid,
// TestmodeChargesOnly, TaxIdInvalid,
// TlsVersionUnsupported, TaxesCalculationFailed,
// TokenInUse, TerminalLocationCountryUnsupported,
// TransferSourceBalanceParametersMismatch, TestmodeChargesOnly,
// TransfersNotAllowed, TlsVersionUnsupported,
TokenInUse,
TransferSourceBalanceParametersMismatch,
TransfersNotAllowed,
*/
} }
impl ::core::fmt::Display for StripeErrorCode { impl ::core::fmt::Display for StripeErrorCode {

View File

@ -188,12 +188,11 @@ pub enum StripePaymentStatus {
RequiresCapture, RequiresCapture,
} }
// TODO: Verigy if the status are correct
impl From<api_enums::IntentStatus> for StripePaymentStatus { impl From<api_enums::IntentStatus> for StripePaymentStatus {
fn from(item: api_enums::IntentStatus) -> Self { fn from(item: api_enums::IntentStatus) -> Self {
match item { match item {
api_enums::IntentStatus::Succeeded => Self::Succeeded, api_enums::IntentStatus::Succeeded => Self::Succeeded,
api_enums::IntentStatus::Failed => Self::Canceled, // TODO: should we show canceled or processing api_enums::IntentStatus::Failed => Self::Canceled,
api_enums::IntentStatus::Processing => Self::Processing, api_enums::IntentStatus::Processing => Self::Processing,
api_enums::IntentStatus::RequiresCustomerAction => Self::RequiresAction, api_enums::IntentStatus::RequiresCustomerAction => Self::RequiresAction,
api_enums::IntentStatus::RequiresPaymentMethod => Self::RequiresPaymentMethod, api_enums::IntentStatus::RequiresPaymentMethod => Self::RequiresPaymentMethod,

View File

@ -181,12 +181,11 @@ pub enum StripeSetupStatus {
RequiresConfirmation, RequiresConfirmation,
} }
// TODO: Verify if the status are correct
impl From<api_enums::IntentStatus> for StripeSetupStatus { impl From<api_enums::IntentStatus> for StripeSetupStatus {
fn from(item: api_enums::IntentStatus) -> Self { fn from(item: api_enums::IntentStatus) -> Self {
match item { match item {
api_enums::IntentStatus::Succeeded => Self::Succeeded, api_enums::IntentStatus::Succeeded => Self::Succeeded,
api_enums::IntentStatus::Failed => Self::Canceled, // TODO: should we show canceled or processing api_enums::IntentStatus::Failed => Self::Canceled,
api_enums::IntentStatus::Processing => Self::Processing, api_enums::IntentStatus::Processing => Self::Processing,
api_enums::IntentStatus::RequiresCustomerAction => Self::RequiresAction, api_enums::IntentStatus::RequiresCustomerAction => Self::RequiresAction,
api_enums::IntentStatus::RequiresPaymentMethod => Self::RequiresPaymentMethod, api_enums::IntentStatus::RequiresPaymentMethod => Self::RequiresPaymentMethod,