| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace Greenlyst\BaseCommerce; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use Exception; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | class LogicException extends Exception | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |     public static function noCustomFieldPrefixDefined(): self | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |         return new static('The prefix for the Custom Field is not mentioned on the class'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |     public static function only10CustomFieldsAreAllowed(): self | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |         return new static('Only 10 custom fields are allowed in the class'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |     public static function requiredFieldDoesntExist($requiredField): self | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |         return new static(self::mapFieldNames($requiredField) . ' is a mandatory field and is not set.'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |     public static function pendingImplementation($message): self | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |         return new static('This section still needs to be implemented for ' . $message); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 28 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 29 |  |  |     public static function methodCallNotSupported($message): self | 
            
                                                                        
                            
            
                                    
            
            
                | 30 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 31 |  |  |         return new static('This method call is not supported for' . $message); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |     private static function mapFieldNames($field) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |         $fieldMappings = [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |             'bank_card_name' => 'Name on Credit Card', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |             'bank_card_number' => 'Credit Card Number', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |             'bank_card_expiration_month' => 'Credit Card Expiry Month', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |             'bank_card_expiration_year' => 'Credit Card Expiry Year', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |             'bank_card_transaction_name' => 'Name on Credit Card', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |             'bank_card_transaction_card_number' => 'Credit Card Number', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |             'bank_card_transaction_expiration_month' => 'Credit Card Expiry Month', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |             'bank_card_transaction_expiration_year' => 'Credit Card Expiry Year', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |             'bank_card_transaction_type' => 'Transaction type', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |             'bank_card_transaction_amount' => 'Transaction amount', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |             'bank_card_token' => 'Credit Card Token' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |         ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |         return $fieldMappings[$field]; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 51 |  |  |     } | 
            
                                                        
            
                                    
            
            
                | 52 |  |  | } |