| 1 |
<?php |
| 2 |
|
| 3 |
namespace Payplug\PayplugWoocommerce\Admin\Vue; |
| 4 |
|
| 5 |
class PaymentMethods { |
| 6 |
|
| 7 |
/** |
| 8 |
* @param $active |
| 9 |
* |
| 10 |
* @return array |
| 11 |
*/ |
| 12 |
public function payment_method_standard( ) { |
| 13 |
|
| 14 |
$option = (get_option( 'woocommerce_payplug_settings', [] )['payment_method'] != "") ? get_option( 'woocommerce_payplug_settings', [] )['payment_method'] : false; |
| 15 |
|
| 16 |
$redirect = false; |
| 17 |
if($option === "redirect"){ |
| 18 |
$redirect = true; |
| 19 |
} |
| 20 |
|
| 21 |
return [ |
| 22 |
"type" => "payment_method", |
| 23 |
"name" => "standard", |
| 24 |
"title" => __( 'payplug_section_standard_payment_title', 'payplug' ), |
| 25 |
"image" => esc_url( PAYPLUG_GATEWAY_PLUGIN_URL . 'assets/images/standard.svg' ), |
| 26 |
"checked" => true, |
| 27 |
"hide" => true, |
| 28 |
"available_test_mode" => true, |
| 29 |
"descriptions" => [ |
| 30 |
"live" => [ |
| 31 |
"description" => __( 'payplug_section_standard_payment_description', 'payplug' ), |
| 32 |
"advanced_options" => __( 'payplug_section_standard_payment_advanced_options_label', 'payplug' ), |
| 33 |
], |
| 34 |
"sandbox" => [ |
| 35 |
"description" => __( 'payplug_section_standard_payment_description', 'payplug' ), |
| 36 |
"advanced_options" => __( 'payplug_section_standard_payment_advanced_options_label', 'payplug' ), |
| 37 |
] |
| 38 |
], |
| 39 |
"options" => [ |
| 40 |
$this->title_field(), |
| 41 |
$this->description_field(), |
| 42 |
$this->embeded_option($redirect), |
| 43 |
$this->one_click_option(), |
| 44 |
] |
| 45 |
]; |
| 46 |
} |
| 47 |
|
| 48 |
private function description_field(){ |
| 49 |
$description = get_option( 'woocommerce_payplug_settings', [] )['description']; |
| 50 |
return array( |
| 51 |
"type" => "payment_option", |
| 52 |
"sub_type" => "input", |
| 53 |
"name" => "standard_payment_description", |
| 54 |
"title" => __("payplug_standard_payment_description_title", "payplug"), |
| 55 |
"value" => $description ?: null, |
| 56 |
"descriptions" => [ |
| 57 |
"live" => [ |
| 58 |
"description" => __("payplug_standard_payment_description_description", "payplug"), |
| 59 |
"placeholder" => __("payplug_standard_payment_description_placeholder", "payplug"), |
| 60 |
], |
| 61 |
"sandbox" => [ |
| 62 |
"description" => __("payplug_standard_payment_description_description", "payplug"), |
| 63 |
"placeholder" => __("payplug_standard_payment_description_placeholder", "payplug"), |
| 64 |
] |
| 65 |
] |
| 66 |
); |
| 67 |
} |
| 68 |
private function title_field(){ |
| 69 |
$title = get_option( 'woocommerce_payplug_settings', [] )['title']; |
| 70 |
return array( |
| 71 |
"type" => "payment_option", |
| 72 |
"sub_type" => "input", |
| 73 |
"name" => "standard_payment_title", |
| 74 |
"title" => __("payplug_standard_payment_title_title", "payplug"), |
| 75 |
"value" => !empty($title) ? $title : __("payplug_standard_payment_title_placeholder", "payplug"), |
| 76 |
"descriptions" => [ |
| 77 |
"live" => [ |
| 78 |
"description" => __("payplug_standard_payment_title_description", "payplug"), |
| 79 |
"placeholder" => __("payplug_standard_payment_title_placeholder", "payplug"), |
| 80 |
], |
| 81 |
"sandbox" => [ |
| 82 |
"description" => __("payplug_standard_payment_title_description", "payplug"), |
| 83 |
"placeholder" => __("payplug_standard_payment_title_placeholder", "payplug"), |
| 84 |
] |
| 85 |
], |
| 86 |
); |
| 87 |
} |
| 88 |
|
| 89 |
/** |
| 90 |
* @param $active |
| 91 |
* |
| 92 |
* @return array|bool[]|false[] |
| 93 |
*/ |
| 94 |
public function one_click_option( $active = null ) { |
| 95 |
$option = [ |
| 96 |
"type" => "payment_option", |
| 97 |
"sub_type" => "switch", |
| 98 |
"name" => "one_click", |
| 99 |
"title" => __( 'payplug_section_one_click_option_title', 'payplug' ), |
| 100 |
"descriptions" => [ |
| 101 |
"live" => [ |
| 102 |
"description" => __( 'payplug_section_one_click_option_description', 'payplug' ), |
| 103 |
"link_know_more" => Component::link( |
| 104 |
__( 'payplug_know_more_label', 'payplug' ), |
| 105 |
"https://support.payplug.com/hc/en-gb/articles/4409698334098", |
| 106 |
"_blank" ), |
| 107 |
], |
| 108 |
"sandbox" => [ |
| 109 |
"description" => __( 'payplug_section_one_click_option_description', 'payplug' ), |
| 110 |
"link_know_more" => Component::link( |
| 111 |
__( 'payplug_know_more_label', 'payplug' ), |
| 112 |
"https://support.payplug.com/hc/en-gb/articles/4409698334098", |
| 113 |
"_blank" ), |
| 114 |
] |
| 115 |
] |
| 116 |
]; |
| 117 |
if (isset(get_option( 'woocommerce_payplug_settings', [] )['oneclick'])) { |
| 118 |
if (get_option( 'woocommerce_payplug_settings', [] )['oneclick'] != 'no') { |
| 119 |
$option = $option + ["checked" => true]; |
| 120 |
} elseif (get_option( 'woocommerce_payplug_settings', [] )['oneclick'] == 'no') { |
| 121 |
$option = $option + ["checked" => false]; |
| 122 |
} |
| 123 |
|
| 124 |
} |
| 125 |
return $option; |
| 126 |
} |
| 127 |
|
| 128 |
/** |
| 129 |
* @return array |
| 130 |
*/ |
| 131 |
public function embeded_option($redirect) { |
| 132 |
|
| 133 |
return [ |
| 134 |
"type" => "payment_option", |
| 135 |
"sub_type" => "IOptions", |
| 136 |
"name" => "embeded", |
| 137 |
"title" => __( 'payplug_section_standard_payment_option_title', 'payplug' ), |
| 138 |
"descriptions" => [ |
| 139 |
"live" => [ |
| 140 |
"description_redirect" => __( 'payplug_section_standard_payment_redirected_description', 'payplug' ), |
| 141 |
"description_popup" => __( 'payplug_section_standard_payment_popup_description', 'payplug' ), |
| 142 |
"link_know_more" => Component::link( |
| 143 |
__( 'payplug_know_more_label', 'payplug' ), |
| 144 |
__( 'payplug_embeded_option_url', 'payplug' ), |
| 145 |
"_blank" ), |
| 146 |
], |
| 147 |
"sandbox" => [ |
| 148 |
"description_redirect" => __( 'payplug_section_standard_payment_redirected_description', 'payplug' ), |
| 149 |
"description_popup" => __( 'payplug_section_standard_payment_popup_description', 'payplug' ), |
| 150 |
"link_know_more" => Component::link( |
| 151 |
__( 'payplug_know_more_label', 'payplug' ), |
| 152 |
__( 'payplug_embeded_option_url', 'payplug' ), |
| 153 |
"_blank" ), |
| 154 |
] |
| 155 |
], |
| 156 |
"options" => [ |
| 157 |
[ |
| 158 |
"name" => "payplug_embedded", |
| 159 |
"label" => __( 'payplug_section_standard_payment_option_popup_label', 'payplug' ), |
| 160 |
"value" => "popup", |
| 161 |
"checked" => $redirect ? false : true |
| 162 |
], |
| 163 |
[ |
| 164 |
"name" => "payplug_embedded", |
| 165 |
"label" => __( 'payplug_section_standard_payment_option_redirected_label', 'payplug' ), |
| 166 |
"value" => "redirect", |
| 167 |
"checked" => $redirect ? true : false |
| 168 |
] |
| 169 |
] |
| 170 |
]; |
| 171 |
} |
| 172 |
|
| 173 |
/** |
| 174 |
* @param $active |
| 175 |
* |
| 176 |
* @return array |
| 177 |
*/ |
| 178 |
public static function payment_method_applepay( $active = false ) { |
| 179 |
return [ |
| 180 |
"type" => "payment_method", |
| 181 |
"name" => "applepay", |
| 182 |
"title" => __( 'payplug_section_applepay_payment_title', 'payplug' ), |
| 183 |
"image" => esc_url( PAYPLUG_GATEWAY_PLUGIN_URL . 'assets/images/applepay.svg' ), |
| 184 |
"checked" => $active, |
| 185 |
"available_test_mode" => false, |
| 186 |
"descriptions" => [ |
| 187 |
"live" => [ |
| 188 |
"description" => __( 'payplug_section_applepay_payment_description', 'payplug' ), |
| 189 |
"link_know_more" => Component::link(__( 'payplug_know_more_label', 'payplug' ), __( 'payplug_applepay_more_url', 'payplug' ), "_blank"), |
| 190 |
], |
| 191 |
"sandbox" => [ |
| 192 |
"description" => __( 'payplug_unavailable_testmode_description', 'payplug' ), |
| 193 |
"link_know_more" => Component::link(__( 'payplug_know_more_label', 'payplug' ), __( 'payplug_applepay_more_url', 'payplug' ), "_blank"), |
| 194 |
] |
| 195 |
], |
| 196 |
]; |
| 197 |
} |
| 198 |
|
| 199 |
/** |
| 200 |
* @param $active |
| 201 |
* |
| 202 |
* @return array |
| 203 |
*/ |
| 204 |
public static function payment_method_bancontact( $active = false ) { |
| 205 |
return [ |
| 206 |
"type" => "payment_method", |
| 207 |
"name" => "bancontact", |
| 208 |
"title" => __( 'payplug_section_bancontact_payment_title', 'payplug' ), |
| 209 |
"image" => esc_url( PAYPLUG_GATEWAY_PLUGIN_URL . 'assets/images/bancontact.svg' ), |
| 210 |
"checked" => $active, |
| 211 |
"available_test_mode" => false, |
| 212 |
"descriptions" => [ |
| 213 |
"live" => [ |
| 214 |
"description" => __( 'payplug_section_bancontact_payment_description', 'payplug' ), |
| 215 |
"link_know_more" => Component::link(__( 'payplug_know_more_label', 'payplug' ), __( 'payplug_bancontact_more_url', 'payplug' ), "_blank"), |
| 216 |
], |
| 217 |
"sandbox" => [ |
| 218 |
"description" => __( 'payplug_unavailable_testmode_description', 'payplug' ), |
| 219 |
"link_know_more" => Component::link(__( 'payplug_know_more_label', 'payplug' ), __( 'payplug_bancontact_more_url', 'payplug' ), "_blank"), |
| 220 |
] |
| 221 |
], |
| 222 |
]; |
| 223 |
} |
| 224 |
|
| 225 |
/** |
| 226 |
* @param $active |
| 227 |
* |
| 228 |
* @return array |
| 229 |
*/ |
| 230 |
public static function payment_method_amex( $active = false ) { |
| 231 |
return [ |
| 232 |
"type" => "payment_method", |
| 233 |
"name" => "american_express", |
| 234 |
"title" => __( 'payplug_section_american_express_payment_title', 'payplug' ), |
| 235 |
"image" => esc_url( PAYPLUG_GATEWAY_PLUGIN_URL . 'assets/images/Amex_logo_color.svg' ), |
| 236 |
"checked" => $active, |
| 237 |
"available_test_mode" => false, |
| 238 |
"descriptions" => [ |
| 239 |
"live" => [ |
| 240 |
"description" => __( 'payplug_section_american_express_payment_description', 'payplug' ), |
| 241 |
"link_know_more" => Component::link(__( 'payplug_know_more_label', 'payplug' ), __( 'payplug_amex_more_url', 'payplug' ), "_blank"), |
| 242 |
], |
| 243 |
"sandbox" => [ |
| 244 |
"description" => __( 'payplug_unavailable_testmode_description', 'payplug' ), |
| 245 |
"link_know_more" => Component::link(__( 'payplug_know_more_label', 'payplug' ), __( 'payplug_amex_more_url', 'payplug' ), "_blank"), |
| 246 |
] |
| 247 |
], |
| 248 |
]; |
| 249 |
} |
| 250 |
|
| 251 |
} |
| 252 |
|