flamingo.me/flamingo-commerce/v3@v3.11.0/payment/domain/payment.go (about) 1 package domain 2 3 import "net/url" 4 5 type ( 6 // Method contains information about a general payment method 7 Method struct { 8 //A speaking title 9 Title string 10 //A unique Code 11 Code string 12 } 13 14 // FlowResult contains information about a newly started flow 15 FlowResult struct { 16 // EarlyPlaceOrder indicates if the order should be placed with the beginning of the payment flow 17 EarlyPlaceOrder bool 18 // Status contains the current payment status 19 Status FlowStatus 20 } 21 22 // FlowStatus contains information about the current payment status 23 FlowStatus struct { 24 // Status of the payment flow. E.g. "payment_completed", "payment_waiting_for_customer" or "payment_failed" 25 Status string 26 // Action to perform to proceed in the payment flow. If status is "payment_waiting_for_customer" this field contains information about what to do - e.g. "redirect" or "show_iframe" 27 Action string 28 // Data contains additional information related to the action / flow 29 Data interface{} 30 ActionData FlowActionData 31 // Error contains additional information in case of an error (e.g. payment failed) 32 Error *Error 33 } 34 35 // FlowActionData contains additional data for the current action 36 FlowActionData struct { 37 // URL is used to pass URL data to the user if the current state needs some 38 URL *url.URL `swaggertype:"string"` 39 // DisplayData holds data, normally HTML to be displayed to the user 40 DisplayData string 41 FormParameter map[string]FormField 42 WalletDetails *WalletDetails 43 } 44 45 // WalletDetails for handling wallet payments in the frontend 46 WalletDetails struct { 47 UsedPaymentMethod string 48 PaymentRequestAPI PaymentRequestAPI 49 } 50 51 // PaymentRequestAPI parameters 52 PaymentRequestAPI struct { 53 Methods string 54 Details string 55 Options string 56 MerchantValidationURL *url.URL `swaggertype:"string"` 57 CompleteURL *url.URL `swaggertype:"string"` 58 } 59 60 // FormField contains form fields 61 FormField struct { 62 Value []string 63 } 64 65 // Error should be used by PaymentGateway to indicate that payment failed (so that the customer can see a speaking message) 66 Error struct { 67 ErrorMessage string 68 ErrorCode string 69 } 70 ) 71 72 const ( 73 // PaymentErrorCodeFailed error will be returned when a general error occurred 74 PaymentErrorCodeFailed = "failed" 75 // PaymentErrorCodeAuthorizeFailed error will be returned when the authorization failed 76 PaymentErrorCodeAuthorizeFailed = "authorization_failed" 77 // PaymentErrorCodeCaptureFailed error will be returned when capturing failed 78 PaymentErrorCodeCaptureFailed = "capture_failed" 79 // PaymentErrorAbortedByCustomer error will be returned when the payment will be aborted by the customer 80 PaymentErrorAbortedByCustomer = "aborted_by_customer" 81 // PaymentErrorCodeCancelled error will be returned when the payment will be canceled 82 PaymentErrorCodeCancelled = "cancelled" 83 // PaymentErrorDuplicateIdempotencyKey error will be returned when idempotency key already in use 84 PaymentErrorDuplicateIdempotencyKey = "duplicate_idempotency_key" 85 86 // PaymentFlowStatusUnapproved payment started 87 PaymentFlowStatusUnapproved = "payment_unapproved" 88 // PaymentFlowStatusFailed payment failed 89 PaymentFlowStatusFailed = "payment_failed" 90 // PaymentFlowStatusAborted payment aborted by user 91 PaymentFlowStatusAborted = "payment_aborted" 92 // PaymentFlowStatusApproved payment approved by payment adapter 93 PaymentFlowStatusApproved = "payment_approved" 94 // PaymentFlowStatusCompleted payment approved and confirmed by customer 95 PaymentFlowStatusCompleted = "payment_completed" 96 // PaymentFlowWaitingForCustomer payment waiting for customer 97 PaymentFlowWaitingForCustomer = "payment_waiting_for_customer" 98 // PaymentFlowStatusCancelled payment cancelled by provider 99 PaymentFlowStatusCancelled = "payment_cancelled" 100 101 // PaymentFlowActionShowIframe signals the frontend to show an iframe 102 PaymentFlowActionShowIframe = "show_iframe" 103 // PaymentFlowActionShowHTML signals the frontend to show HTML 104 PaymentFlowActionShowHTML = "show_html" 105 // PaymentFlowActionRedirect signals the frontend to do a redirect to a hosted payment page 106 PaymentFlowActionRedirect = "redirect" 107 // PaymentFlowActionPostRedirect signals the frontend to do a post redirect to a hosted payment page 108 PaymentFlowActionPostRedirect = "post_redirect" 109 // PaymentFlowActionShowWalletPayment signals the frontend to start a wallet payment 110 PaymentFlowActionShowWalletPayment = "show_wallet_payment" 111 // PaymentFlowActionTriggerClientSDK signals the frontend to trigger a special client sdk implementation 112 PaymentFlowActionTriggerClientSDK = "trigger_client_sdk" 113 ) 114 115 // Error getter 116 func (pe *Error) Error() string { 117 return pe.ErrorMessage 118 }