activities_helper.php
1 year ago
agent_helper.php
1 year ago
auth_helper.php
1 year ago
blocks_helper.php
1 year ago
booking_helper.php
1 year ago
bricks_helper.php
1 year ago
bundles_helper.php
1 year ago
calendar_helper.php
1 year ago
carts_helper.php
1 year ago
connector_helper.php
1 year ago
csv_helper.php
1 year ago
customer_helper.php
1 year ago
database_helper.php
1 year ago
debug_helper.php
1 year ago
defaults_helper.php
1 year ago
elementor_helper.php
1 year ago
email_helper.php
1 year ago
encrypt_helper.php
1 year ago
events_helper.php
1 year ago
form_helper.php
1 year ago
icalendar_helper.php
1 year ago
image_helper.php
1 year ago
invoices_helper.php
1 year ago
license_helper.php
1 year ago
location_helper.php
1 year ago
marketing_systems_helper.php
1 year ago
meeting_systems_helper.php
1 year ago
menu_helper.php
1 year ago
meta_helper.php
1 year ago
migrations_helper.php
1 year ago
money_helper.php
1 year ago
notifications_helper.php
1 year ago
order_intent_helper.php
1 year ago
orders_helper.php
1 year ago
pages_helper.php
1 year ago
params_helper.php
1 year ago
payments_helper.php
1 year ago
price_breakdown_helper.php
1 year ago
process_jobs_helper.php
1 year ago
processes_helper.php
1 year ago
replacer_helper.php
1 year ago
resource_helper.php
1 year ago
roles_helper.php
1 year ago
router_helper.php
1 year ago
service_helper.php
1 year ago
sessions_helper.php
1 year ago
settings_helper.php
1 year ago
shortcodes_helper.php
1 year ago
sms_helper.php
1 year ago
steps_helper.php
1 year ago
stripe_connect_helper.php
1 year ago
styles_helper.php
1 year ago
support_topics_helper.php
1 year ago
time_helper.php
1 year ago
timeline_helper.php
1 year ago
transaction_intent_helper.php
1 year ago
util_helper.php
1 year ago
version_specific_updates_helper.php
1 year ago
whatsapp_helper.php
1 year ago
work_periods_helper.php
1 year ago
wp_datetime.php
1 year ago
wp_user_helper.php
1 year ago
transaction_intent_helper.php
51 lines
| 1 | <?php |
| 2 | /* |
| 3 | * Copyright (c) 2024 LatePoint LLC. All rights reserved. |
| 4 | */ |
| 5 | |
| 6 | class OsTransactionIntentHelper { |
| 7 | |
| 8 | |
| 9 | public static function generate_continue_intent_url( $transaction_intent_key ) { |
| 10 | return OsRouterHelper::build_admin_post_link( [ |
| 11 | 'orders', |
| 12 | 'continue_transaction_intent' |
| 13 | ], [ 'transaction_intent_key' => $transaction_intent_key ] ); |
| 14 | } |
| 15 | |
| 16 | |
| 17 | public static function get_order_id_from_intent_key( $intent_key ) { |
| 18 | if ( empty( $intent_key ) ) { |
| 19 | return false; |
| 20 | } |
| 21 | $transaction_intent = new OsTransactionIntentModel(); |
| 22 | $transaction_intent = $transaction_intent->where( [ 'intent_key' => $intent_key ] )->set_limit( 1 )->get_results_as_models(); |
| 23 | |
| 24 | if ( $transaction_intent && $transaction_intent->order_id ) { |
| 25 | return $transaction_intent->order_id; |
| 26 | } else { |
| 27 | return null; |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | public static function get_transaction_intent_by_intent_key( string $intent_key ) : OsTransactionIntentModel { |
| 32 | $transaction_intent = new OsTransactionIntentModel(); |
| 33 | if(empty($intent_key)) return $transaction_intent; |
| 34 | $transaction_intent = $transaction_intent->where( [ 'intent_key' => $intent_key ] )->set_limit( 1 )->get_results_as_models(); |
| 35 | if(!empty($transaction_intent)){ |
| 36 | return $transaction_intent; |
| 37 | }else{ |
| 38 | return new OsTransactionIntentModel(); |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | public static function is_converted( $transaction_intent_id ) { |
| 43 | $transaction_intent = new OsTransactionIntentModel( $transaction_intent_id ); |
| 44 | if ( ! empty( $transaction_intent->transaction_id ) ) { |
| 45 | return $transaction_intent->transaction_id; |
| 46 | } else { |
| 47 | return false; |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | } |