| @@ -7,12 +7,8 @@ | ||
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | namespace SeQura\WC\Services\Order; |
| 10 | 10 | |
| 11 | -use SeQura\Core\BusinessLogic\Domain\Order\Models\OrderRequest\Address; | |
| 12 | -use SeQura\Core\BusinessLogic\Domain\Order\Models\OrderRequest\Customer; | |
| 13 | -use SeQura\Core\BusinessLogic\Domain\Order\Models\OrderRequest\DeliveryMethod; | |
| 14 | -use SeQura\Core\BusinessLogic\Domain\Order\Models\OrderRequest\PreviousOrder; | |
| 15 | 11 | use SeQura\WC\Dto\Cart_Info; |
| 16 | 12 | use SeQura\WC\Dto\Payment_Method_Data; |
| 17 | 13 | use WC_Order; |
| 18 | 14 | |
| @@ -21,110 +17,8 @@ | ||
| 21 | 17 | */ |
| 22 | 18 | interface Interface_Order_Service { |
| 23 | 19 | |
| 24 | 20 | /** |
| 25 | - * Get delivery method | |
| 26 | - */ | |
| 27 | - public function get_delivery_method( ?WC_Order $order ): DeliveryMethod; | |
| 28 | - | |
| 29 | - /** | |
| 30 | - * Get client first name. If the order is null, attempt to retrieve data from the session. | |
| 31 | - */ | |
| 32 | - public function get_first_name( ?WC_Order $order, $is_delivery = true ): string; | |
| 33 | - | |
| 34 | - /** | |
| 35 | - * Get client last name. If the order is null, attempt to retrieve data from the session. | |
| 36 | - */ | |
| 37 | - public function get_last_name( ?WC_Order $order, $is_delivery = true ): string; | |
| 38 | - | |
| 39 | - /** | |
| 40 | - * Get client company. If the order is null, attempt to retrieve data from the session. | |
| 41 | - */ | |
| 42 | - public function get_company( ?WC_Order $order, $is_delivery = true ): string; | |
| 43 | - | |
| 44 | - /** | |
| 45 | - * Get client address's first line. If the order is null, attempt to retrieve data from the session. | |
| 46 | - */ | |
| 47 | - public function get_address_1( ?WC_Order $order, $is_delivery = true ): string; | |
| 48 | - | |
| 49 | - /** | |
| 50 | - * Get client address's second line. If the order is null, attempt to retrieve data from the session. | |
| 51 | - */ | |
| 52 | - public function get_address_2( ?WC_Order $order, $is_delivery = true ): string; | |
| 53 | - | |
| 54 | - /** | |
| 55 | - * Get client postcode. If the order is null, attempt to retrieve data from the session. | |
| 56 | - */ | |
| 57 | - public function get_postcode( ?WC_Order $order, $is_delivery = true ): string; | |
| 58 | - | |
| 59 | - /** | |
| 60 | - * Get client city. If the order is null, attempt to retrieve data from the session. | |
| 61 | - */ | |
| 62 | - public function get_city( ?WC_Order $order, $is_delivery = true ): string; | |
| 63 | - | |
| 64 | - /** | |
| 65 | - * Get client country code. If the order is null, attempt to retrieve data from the session. | |
| 66 | - */ | |
| 67 | - public function get_country( ?WC_Order $order, $is_delivery = true ): string; | |
| 68 | - | |
| 69 | - /** | |
| 70 | - * Get client state. If the order is null, attempt to retrieve data from the session. | |
| 71 | - */ | |
| 72 | - public function get_state( ?WC_Order $order, $is_delivery = true ): string; | |
| 73 | - | |
| 74 | - /** | |
| 75 | - * Get client phone. If the order is null, attempt to retrieve data from the session. | |
| 76 | - */ | |
| 77 | - public function get_phone( ?WC_Order $order, $is_delivery = true ): string; | |
| 78 | - | |
| 79 | - /** | |
| 80 | - * Get client email. If the order is null, attempt to retrieve data from the session. | |
| 81 | - */ | |
| 82 | - public function get_email( ?WC_Order $order ): string; | |
| 83 | - | |
| 84 | - /** | |
| 85 | - * Get client vat number. If the order is null, attempt to retrieve data from the session. | |
| 86 | - */ | |
| 87 | - public function get_vat( ?WC_Order $order, $is_delivery = true ): string; | |
| 88 | - | |
| 89 | - /** | |
| 90 | - * Get client NIN number. If the order is null, attempt to retrieve data from the session. | |
| 91 | - */ | |
| 92 | - public function get_nin( ?WC_Order $order ): ?string; | |
| 93 | - | |
| 94 | - /** | |
| 95 | - * Get date of birth. If the order is null, attempt to retrieve data from the session. | |
| 96 | - */ | |
| 97 | - public function get_dob( ?WC_Order $order ): ?string; | |
| 98 | - | |
| 99 | - /** | |
| 100 | - * Get shopper title. If the order is null, attempt to retrieve data from the session. | |
| 101 | - */ | |
| 102 | - public function get_shopper_title( ?WC_Order $order ): ?string; | |
| 103 | - | |
| 104 | - /** | |
| 105 | - * Get shopper created at date. If the order is null, attempt to retrieve data from the session. | |
| 106 | - */ | |
| 107 | - public function get_shopper_created_at( ?WC_Order $order ): ?string; | |
| 108 | - | |
| 109 | - /** | |
| 110 | - * Get shopper updated at date. If the order is null, attempt to retrieve data from the session. | |
| 111 | - */ | |
| 112 | - public function get_shopper_updated_at( ?WC_Order $order ): ?string; | |
| 113 | - | |
| 114 | - /** | |
| 115 | - * Get shopper rating. If the order is null, attempt to retrieve data from the session. | |
| 116 | - */ | |
| 117 | - public function get_shopper_rating( ?WC_Order $order ): ?int; | |
| 118 | - | |
| 119 | - /** | |
| 120 | - * Get previous orders | |
| 121 | - * | |
| 122 | - * @return PreviousOrder[] | |
| 123 | - */ | |
| 124 | - public function get_previous_orders( int $customer_id ): array; | |
| 125 | - | |
| 126 | - /** | |
| 127 | 21 | * Get the seQura payment method title for the order. |
| 128 | 22 | * If the order is not a seQura order an empty string is returned. |
| 129 | 23 | */ |
| 130 | 24 | public function get_payment_method_title( WC_Order $order ): string; |
| @@ -153,60 +47,85 @@ | ||
| 153 | 47 | */ |
| 154 | 48 | public function get_cart_info( WC_Order $order ): ?Cart_Info; |
| 155 | 49 | |
| 156 | 50 | /** |
| 51 | + * Set cart info for the order | |
| 52 | + * | |
| 53 | + * @param Cart_Info $cart_info Cart info | |
| 54 | + */ | |
| 55 | + public function set_cart_info( WC_Order $order, $cart_info ): void; | |
| 56 | + | |
| 57 | + /** | |
| 157 | 58 | * Set cart info if it is not already set |
| 158 | 59 | */ |
| 159 | 60 | public function create_cart_info( WC_Order $order ): ?Cart_Info; |
| 160 | - | |
| 61 | + | |
| 161 | 62 | /** |
| 162 | - * Get payment gateway webhook identifier | |
| 63 | + * Get the meta key used to store the sent to seQura value. | |
| 163 | 64 | */ |
| 164 | - public function get_ipn_url( WC_Order $order, string $store_id ): string; | |
| 65 | + public function get_sent_to_sequra_meta_key(): string; | |
| 165 | 66 | |
| 166 | 67 | /** |
| 167 | - * Get payment gateway webhook identifier | |
| 68 | + * Set the order as sent to seQura | |
| 168 | 69 | */ |
| 169 | - public function get_return_url( WC_Order $order ): string; | |
| 70 | + public function set_as_sent_to_sequra( WC_Order $order ): void; | |
| 170 | 71 | |
| 171 | 72 | /** |
| 172 | - * Get payment gateway webhook identifier | |
| 73 | + * Call the Order Update API to sync the order status with SeQura | |
| 173 | 74 | */ |
| 174 | - public function get_event_url( WC_Order $order, string $store_id ): string; | |
| 75 | + public function update_sequra_order_status( WC_Order $order, string $old_store_status, string $new_store_status ): void; | |
| 175 | 76 | |
| 176 | 77 | /** |
| 177 | - * Get the meta key used to store the sent to seQura value. | |
| 78 | + * Update the order amount in SeQura after a refund | |
| 79 | + * | |
| 80 | + * @throws Throwable | |
| 178 | 81 | */ |
| 179 | - public function get_sent_to_sequra_meta_key(): string; | |
| 82 | + public function handle_refund( WC_Order $order, float $amount ): void; | |
| 180 | 83 | |
| 181 | 84 | /** |
| 182 | - * Get customer for the order | |
| 85 | + * Get the link to the SeQura back office for the order | |
| 183 | 86 | */ |
| 184 | - public function get_customer( ?WC_Order $order, string $lang, int $fallback_user_id = 0, string $fallback_ip = '', string $fallback_user_agent = '' ): Customer; | |
| 87 | + public function get_link_to_sequra_back_office( WC_Order $order ): ?string; | |
| 185 | 88 | |
| 186 | 89 | /** |
| 187 | - * Get delivery or invoice address | |
| 90 | + * Get the total amount of the order | |
| 91 | + * | |
| 92 | + * @param WC_Order $order | |
| 93 | + * @return float|int | |
| 188 | 94 | */ |
| 189 | - public function get_address( ?WC_Order $order, bool $is_delivery ): Address; | |
| 95 | + public function get_total( $order, $in_cents = true ); | |
| 190 | 96 | |
| 191 | 97 | /** |
| 192 | - * Set the order as sent to seQura | |
| 98 | + * Cleanup orders | |
| 99 | + * | |
| 100 | + * @return void | |
| 193 | 101 | */ |
| 194 | - public function set_as_sent_to_sequra( WC_Order $order ): void; | |
| 102 | + public function cleanup_orders(); | |
| 195 | 103 | |
| 196 | 104 | /** |
| 197 | - * Call the Order Update API to sync the order status with SeQura | |
| 105 | + * Get the Merchant ID | |
| 106 | + * | |
| 107 | + * @param WC_Order $order | |
| 108 | + * @return string | |
| 198 | 109 | */ |
| 199 | - public function update_sequra_order_status( WC_Order $order, string $old_store_status, string $new_store_status ): void; | |
| 110 | + public function get_merchant_id( $order ); | |
| 200 | 111 | |
| 201 | 112 | /** |
| 202 | - * Update the order amount in SeQura after a refund | |
| 203 | - * | |
| 204 | - * @throws Throwable | |
| 113 | + * Check if the migration process is complete | |
| 114 | + * | |
| 115 | + * @return bool True if they are missing indexes, false otherwise | |
| 205 | 116 | */ |
| 206 | - public function handle_refund( WC_Order $order, float $amount ): void; | |
| 117 | + public function is_migration_complete(); | |
| 207 | 118 | |
| 208 | 119 | /** |
| 209 | - * Get the link to the SeQura back office for the order | |
| 120 | + * Execute the migration process | |
| 210 | 121 | */ |
| 211 | - public function get_link_to_sequra_back_office( WC_Order $order ): ?string; | |
| 122 | + public function migrate_data(); | |
| 123 | + | |
| 124 | + /** | |
| 125 | + * Get the order completion date or current date if not completed. | |
| 126 | + * | |
| 127 | + * @param WC_Order $order | |
| 128 | + * @return string | |
| 129 | + */ | |
| 130 | + public function get_order_completion_date( $order ); | |
| 212 | 131 | } |