| @@ -76,9 +76,8 @@ | ||
| 76 | 76 | // And return true so it does not try to handle it as an error. |
| 77 | 77 | return true; |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - // TODO: Only render when we visit the PayPal tab. | |
| 81 | 80 | $status = self::get_seller_status(); |
| 82 | 81 | |
| 83 | 82 | /* |
| 84 | 83 | $status = new stdClass(); |
| @@ -849,14 +848,9 @@ | ||
| 849 | 848 | /** |
| 850 | 849 | * @return array |
| 851 | 850 | */ |
| 852 | 851 | private static function get_standard_authenticated_body() { |
| 853 | - $mode = self::get_mode_value_from_post(); | |
| 854 | - return array( | |
| 855 | - 'merchant_id' => get_option( self::get_merchant_id_option_name( $mode ) ), | |
| 856 | - 'server_password' => get_option( self::get_server_side_token_option_name( $mode ) ), | |
| 857 | - 'client_password' => get_option( self::get_client_side_token_option_name( $mode ) ), | |
| 858 | - ); | |
| 852 | + return self::get_body_for_mode( FrmPayPalLiteAppHelper::active_mode() ); | |
| 859 | 853 | } |
| 860 | 854 | |
| 861 | 855 | /** |
| 862 | 856 | * Check $_POST for live or test mode value as it can be updated in real time from PayPal Settings and can be configured before the update is saved. |
| @@ -873,8 +867,26 @@ | ||
| 873 | 867 | return $test_mode ? 'test' : 'live'; |
| 874 | 868 | } |
| 875 | 869 | |
| 876 | 870 | /** |
| 871 | + * Get the standard body with account id, mode, and passwords to send to the connect server. | |
| 872 | + * | |
| 873 | + * @since 6.32.1 | |
| 874 | + * | |
| 875 | + * @param string $mode 'live' or 'test'. | |
| 876 | + * | |
| 877 | + * @return array | |
| 878 | + */ | |
| 879 | + private static function get_body_for_mode( $mode ) { | |
| 880 | + return array( | |
| 881 | + 'merchant_id' => get_option( self::get_merchant_id_option_name( $mode ) ), | |
| 882 | + 'server_password' => get_option( self::get_server_side_token_option_name( $mode ) ), | |
| 883 | + 'client_password' => get_option( self::get_client_side_token_option_name( $mode ) ), | |
| 884 | + 'frm_paypal_api_mode' => $mode, | |
| 885 | + ); | |
| 886 | + } | |
| 887 | + | |
| 888 | + /** | |
| 877 | 889 | * @return string|null |
| 878 | 890 | */ |
| 879 | 891 | public static function get_latest_error_from_paypal_api() { |
| 880 | 892 | return self::$latest_error_from_paypal_api; |
| @@ -937,8 +949,9 @@ | ||
| 937 | 949 | |
| 938 | 950 | public static function handle_disconnect() { |
| 939 | 951 | self::disconnect(); |
| 940 | 952 | self::reset_paypal_api_integration(); |
| 953 | + FrmTransLiteAppHelper::trigger_gateway_disconnected_hook( 'paypal', self::get_mode_value_from_post() ); | |
| 941 | 954 | wp_send_json_success(); |
| 942 | 955 | } |
| 943 | 956 | |
| 944 | 957 | /** |
| @@ -944,11 +957,9 @@ | ||
| 944 | 957 | /** |
| 945 | 958 | * @return false|object |
| 946 | 959 | */ |
| 947 | 960 | private static function disconnect() { |
| 948 | - $additional_body = array( | |
| 949 | - 'frm_paypal_api_mode' => self::get_mode_value_from_post(), | |
| 950 | - ); | |
| 961 | + $additional_body = self::get_body_for_mode( self::get_mode_value_from_post() ); | |
| 951 | 962 | return self::post_with_authenticated_body( 'disconnect', $additional_body ); |
| 952 | 963 | } |
| 953 | 964 | |
| 954 | 965 | /** |
| @@ -1084,21 +1095,10 @@ | ||
| 1084 | 1095 | return self::post_with_authenticated_body( 'create_subscription', compact( 'data' ) ); |
| 1085 | 1096 | } |
| 1086 | 1097 | |
| 1087 | 1098 | /** |
| 1088 | - * @since 6.31 | |
| 1089 | - * | |
| 1090 | - * @param array $data Setup token data including payment_source. | |
| 1091 | - * | |
| 1092 | 1099 | * @return false|object |
| 1093 | 1100 | */ |
| 1094 | - public static function create_vault_setup_token( $data = array() ) { | |
| 1095 | - return self::post_with_authenticated_body( 'create_vault_setup_token', compact( 'data' ) ); | |
| 1096 | - } | |
| 1097 | - | |
| 1098 | - /** | |
| 1099 | - * @return false|object | |
| 1100 | - */ | |
| 1101 | 1101 | public static function get_seller_status() { |
| 1102 | 1102 | $mode = self::get_mode_value_from_post(); |
| 1103 | 1103 | $status = get_option( self::get_paypal_seller_status_option_name( $mode ) ); |
| 1104 | 1104 | |
| @@ -1105,11 +1105,9 @@ | ||
| 1105 | 1105 | if ( is_object( $status ) ) { |
| 1106 | 1106 | return $status; |
| 1107 | 1107 | } |
| 1108 | 1108 | |
| 1109 | - $additional_body = array( | |
| 1110 | - 'frm_paypal_api_mode' => $mode, | |
| 1111 | - ); | |
| 1109 | + $additional_body = self::get_body_for_mode( $mode ); | |
| 1112 | 1110 | |
| 1113 | 1111 | return self::post_with_authenticated_body( 'get_seller_status', $additional_body ); |
| 1114 | 1112 | } |
| 1115 | 1113 | |
| @@ -1152,6 +1150,19 @@ | ||
| 1152 | 1150 | * @return string |
| 1153 | 1151 | */ |
| 1154 | 1152 | public static function get_bn_code() { |
| 1155 | 1153 | return 'Strategy11LLCPPCP_SP'; |
| 1154 | + } | |
| 1155 | + | |
| 1156 | + /** | |
| 1157 | + * @since 6.31 | |
| 1158 | + * @deprecated 6.32.1 | |
| 1159 | + * | |
| 1160 | + * @param array $data Setup token data including payment_source. | |
| 1161 | + * | |
| 1162 | + * @return false|object | |
| 1163 | + */ | |
| 1164 | + public static function create_vault_setup_token( $data = array() ) { | |
| 1165 | + _deprecated_function( __METHOD__, '6.32.1' ); | |
| 1166 | + return false; | |
| 1156 | 1167 | } |
| 1157 | 1168 | } |