MS_Gateway_Authorize

Authorize.net Gateway.

Defined (1)

The class is defined in the following location(s).

/app/gateway/authorize/class-ms-gateway-authorize.php  
  1. class MS_Gateway_Authorize extends MS_Gateway { 
  2.  
  3. const ID = 'authorize'; 
  4.  
  5. /** 
  6. * Gateway singleton instance. 
  7. * @since 1.0.0 
  8. * @var string $instance 
  9. */ 
  10. public static $instance; 
  11.  
  12. /** 
  13. * Authorize.net's Customer Information Manager wrapper. 
  14. * @since 1.0.0 
  15. * @var string $cim 
  16. */ 
  17. protected static $cim = ''; 
  18.  
  19. /** 
  20. * Authorize.net API login IP. 
  21. * @see @link https://www.authorize.net/support/CP/helpfiles/Account/Settings/Security_Settings/General_Settings/API_Login_ID_and_Transaction_Key.htm 
  22. * @since 1.0.0 
  23. * @var string $api_login_id 
  24. */ 
  25. protected $api_login_id = ''; 
  26.  
  27. /** 
  28. * Authorize.net API transaction key. 
  29. * @since 1.0.0 
  30. * @var string $api_transaction_key 
  31. */ 
  32. protected $api_transaction_key = ''; 
  33.  
  34. /** 
  35. * Secure transactions flag. 
  36. * If set to true then each payment request will include the users credit 
  37. * card verificaton code (CVC). This means that all recurring payments need 
  38. * the user to enter the CVC code again. 
  39. * @since 1.0.0 
  40. * @var bool $secure_cc 
  41. */ 
  42. protected $secure_cc = false; 
  43.  
  44.  
  45. /** 
  46. * Initialize the object. 
  47. * @since 1.0.0 
  48. */ 
  49. public function after_load() { 
  50. parent::after_load(); 
  51.  
  52. $this->id = self::ID; 
  53. $this->name = __( 'Authorize.net Gateway', 'membership2' ); 
  54. $this->group = 'Authorize.net'; 
  55. $this->manual_payment = true; // Recurring billed/paid manually 
  56. $this->pro_rate = true; 
  57.  
  58. /** 
  59. * Processes purchase action. 
  60. * This function is called when a payment was made: We check if the 
  61. * transaction was successful. If it was we call `$invoice->changed()` which 
  62. * will update the membership status accordingly. 
  63. * @since 1.0.0 
  64. * @param MS_Model_Relationship $subscription The related membership relationship. 
  65. */ 
  66. public function process_purchase( $subscription ) { 
  67. do_action( 
  68. 'ms_gateway_authorize_process_purchase_before',  
  69. $subscription,  
  70. $this 
  71. ); 
  72.  
  73. if ( ! is_ssl() ) { 
  74. throw new Exception( __( 'You must use HTTPS in order to do this', 'membership' ) ); 
  75.  
  76. $invoice = $subscription->get_current_invoice(); 
  77. $member = $subscription->get_member(); 
  78.  
  79. // manage authorize customer profile 
  80. $cim_profile_id = $this->get_cim_profile_id( $member ); 
  81.  
  82. if ( empty( $cim_profile_id ) ) { 
  83. $this->create_cim_profile( $member ); 
  84. } elseif ( $cim_payment_profile_id = trim( filter_input( INPUT_POST, 'profile' ) ) ) { 
  85. // Fetch for user selected cim profile 
  86. $response = $this->get_cim()->getCustomerPaymentProfile( $cim_profile_id, $cim_payment_profile_id ); 
  87.  
  88. if ( $response->isError() ) { 
  89. throw new Exception( 
  90. __( 'The selected payment profile is invalid, enter a new credit card', 'membership2' ) 
  91. ); 
  92. } else { 
  93. $this->update_cim_profile( $member ); 
  94.  
  95. if ( ! $invoice->is_paid() ) { 
  96. // Not paid yet, request the transaction. 
  97. $this->online_purchase( $invoice, $member, 'process' ); 
  98. } elseif ( 0 == $invoice->total ) { 
  99. // Paid and free. 
  100. $invoice->changed(); 
  101.  
  102. return apply_filters( 
  103. 'ms_gateway_authorize_process_purchase',  
  104. $invoice,  
  105. $this 
  106. ); 
  107.  
  108. /** 
  109. * Request automatic payment to the gateway. 
  110. * @since 1.0.0 
  111. * @param MS_Model_Relationship $subscription The related membership relationship. 
  112. * @return bool True on success. 
  113. */ 
  114. public function request_payment( $subscription ) { 
  115. $was_paid = false; 
  116.  
  117. do_action( 
  118. 'ms_gateway_authorize_request_payment_before',  
  119. $subscription,  
  120. $this 
  121. ); 
  122.  
  123. $member = $subscription->get_member(); 
  124. $invoice = $subscription->get_current_invoice(); 
  125.  
  126. if ( ! $invoice->is_paid() ) { 
  127. // Not paid yet, request the transaction. 
  128. $was_paid = $this->online_purchase( $invoice, $member, 'request' ); 
  129. } else { 
  130. // Invoice was already paid earlier. 
  131. $was_paid = true; 
  132.  
  133. do_action( 
  134. 'ms_gateway_authorize_request_payment_after',  
  135. $subscription,  
  136. $was_paid,  
  137. $this 
  138. ); 
  139.  
  140. return $was_paid; 
  141.  
  142. /** 
  143. * Processes online payments. 
  144. * Send to Authorize.net to process the payment immediatly. 
  145. * @since 1.0.0 
  146. * @param MS_Model_Invoice $invoice The invoice to pay. 
  147. * @param MS_Model_Member The member paying the invoice. 
  148. * @return bool True on success, otherwise throws an exception. 
  149. */ 
  150. protected function online_purchase( &$invoice, $member, $log_action ) { 
  151. $success = false; 
  152. $notes = ''; 
  153. $amount = 0; 
  154. $subscription = $invoice->get_subscription(); 
  155.  
  156. do_action( 
  157. 'ms_gateway_authorize_online_purchase_before',  
  158. $invoice,  
  159. $member,  
  160. $this 
  161. ); 
  162.  
  163. $need_code = lib3()->is_true( $this->secure_cc ); 
  164. $have_code = ! empty( $_POST['card_code'] ); 
  165.  
  166. if ( 0 == $invoice->total ) { 
  167. $notes = __( 'Total is zero. Payment approved. Not sent to gateway.', 'membership2' ); 
  168. $invoice->pay_it( MS_Gateway_Free::ID, '' ); 
  169. $invoice->add_notes( $notes ); 
  170. $invoice->save(); 
  171. $invoice->changed(); 
  172. } elseif ( ! $need_code || $have_code ) { 
  173. $amount = MS_Helper_Billing::format_price( $invoice->total ); 
  174.  
  175. $cim_transaction = $this->get_cim_transaction( $member ); 
  176. $cim_transaction->amount = $amount; 
  177. $cim_transaction->order->invoiceNumber = $invoice->id; 
  178.  
  179. $invoice->timestamp = time(); 
  180. $invoice->save(); 
  181.  
  182. $_POST['API Out: Secure Payment'] = lib3()->is_true( $this->secure_cc ); 
  183. $_POST['API Out: CustomerProfileID'] = $cim_transaction->customerProfileId; 
  184. $_POST['API Out: PaymentProfileID'] = $cim_transaction->customerPaymentProfileId; 
  185. $_POST['API Out: InvoiceNumber'] = $cim_transaction->order->invoiceNumber; 
  186.  
  187. $response = $this->get_cim()->createCustomerProfileTransaction( 
  188. 'AuthCapture',  
  189. $cim_transaction 
  190. ); 
  191.  
  192. if ( ! empty( $response->xml ) 
  193. && ! empty( $response->xml->messages ) 
  194. && ! empty( $response->xml->messages->message ) 
  195. ) { 
  196. $msg = $response->xml->messages->message; 
  197. $_POST['API Response: Short'] = $msg->code . ': ' . $msg->text; 
  198. } else { 
  199. $_POST['API Response: Short'] = '-'; 
  200. if ( isset( $response->response ) ) { 
  201. if ( is_string( $response->response ) ) { 
  202. $_POST['API Response: XML'] = $response->response; 
  203. } else { 
  204. $_POST['API Response: XML'] = json_encode( $response->response ); 
  205. } else { 
  206. $_POST['API Response: XML'] = json_encode( $response->response ); 
  207.  
  208. if ( $response->isOk() ) { 
  209. $transaction_response = $response->getTransactionResponse(); 
  210.  
  211. if ( $transaction_response->approved ) { 
  212. $external_id = $response->getTransactionResponse()->transaction_id; 
  213. $invoice->pay_it( self::ID, $external_id ); 
  214. $success = true; 
  215. $notes = __( 'Payment successful', 'membership2' ); 
  216. } else { 
  217. $notes = sprintf( 
  218. __( 'Payment Failed: code %s, subcode %s, reason code %, reason %s', 'membership2' ),  
  219. $transaction_response->response_code,  
  220. $transaction_response->response_subcode,  
  221. $transaction_response->response_reason_code,  
  222. $transaction_response->response_reason 
  223. ); 
  224. } else { 
  225. $notes = __( 'Payment Failed: ', 'membership2' ) . $response->getMessageText(); 
  226. } elseif ( $need_code && ! $have_code ) { 
  227. $notes = __( 'Secure payment failed: No Card Code found', 'membership2' ); 
  228.  
  229. // Mask the credit card number before logging it to database. 
  230. $card_num = ''; 
  231. $card_code = ''; 
  232. if ( isset( $_POST['card_num'] ) ) { 
  233. // Card Num 6789765435678765 
  234. // Becomes ************8765 
  235. $card_num = str_replace( ' ', '', $_POST['card_num'] ); 
  236. $_POST['card_num'] = str_pad( 
  237. substr( $card_num, -4 ),  
  238. strlen( $card_num ),  
  239. '*',  
  240. STR_PAD_LEFT 
  241. ); 
  242. if ( isset( $_POST['card_code'] ) ) { 
  243. $card_code = $_POST['card_code']; 
  244. $_POST['card_code'] = str_repeat( '*', strlen( $card_code ) ); 
  245.  
  246. do_action( 
  247. 'ms_gateway_transaction_log',  
  248. self::ID, // gateway ID 
  249. $log_action, // request|process|handle 
  250. $success, // success flag 
  251. $subscription->id, // subscription ID 
  252. $invoice->id, // invoice ID 
  253. $amount, // charged amount 
  254. $notes, // Descriptive text 
  255. $external_id // External ID 
  256. ); 
  257.  
  258. // Restore the POST data in case it's used elsewhere. 
  259. $_POST['card_num'] = $card_num; 
  260. $_POST['card_code'] = $card_code; 
  261. unset( $_POST['API Out: CustomerProfileID'] ); 
  262. unset( $_POST['API Out: PaymentProfileID'] ); 
  263. unset( $_POST['API Out: InvoiceNumber'] ); 
  264. unset( $_POST['API Out: Secure Payment'] ); 
  265. unset( $_POST['API Response: Short'] ); 
  266. unset( $_POST['API Response: XML'] ); 
  267.  
  268. return $success; 
  269.  
  270. /** 
  271. * Save card info. 
  272. * Save only 4 last digits and expire date. 
  273. * @since 1.0.0 
  274. * @param MS_Model_Member $member The member to save card info. 
  275. */ 
  276. public function save_card_info( $member ) { 
  277. $cim_profile_id = $this->get_cim_profile_id( $member ); 
  278. $cim_payment_profile_id = $this->get_cim_payment_profile_id( $member ); 
  279. $profile = $this->get_cim_profile( $member ); 
  280.  
  281. if ( ! empty( $profile['customerPaymentProfileId'] ) 
  282. && $cim_payment_profile_id == $profile['customerPaymentProfileId'] 
  283. ) { 
  284. $exp_year = filter_input( INPUT_POST, 'exp_year', FILTER_VALIDATE_INT ); 
  285. $exp_month = substr( filter_input( INPUT_POST, 'exp_month', FILTER_VALIDATE_INT ), -2 ); 
  286. $member->set_gateway_profile( 
  287. self::ID,  
  288. 'card_exp',  
  289. gmdate( 'Y-m-t', strtotime( "{$exp_year}-{$exp_month}-01" ) ) 
  290. ); 
  291.  
  292. $member->set_gateway_profile( 
  293. self::ID,  
  294. 'card_num',  
  295. str_replace( 'XXXX', '', $profile['payment']['creditCard']['cardNumber'] ) 
  296. ); 
  297.  
  298. do_action( 
  299. 'ms_gateway_authorize_save_card_info_after',  
  300. $member,  
  301. $this 
  302. ); 
  303.  
  304. /** 
  305. * Loads Authorize.net lib. 
  306. * @since 1.0.0 
  307. */ 
  308. protected function load_authorize_lib() { 
  309. do_action( 'ms_gateway_authorize_load_authorize_lib', $this ); 
  310.  
  311. require_once MS_Plugin::instance()->dir . '/lib/authorize.net/autoload.php'; 
  312.  
  313. /** 
  314. * Returns the instance of AuthorizeNetCIM class. 
  315. * @since 1.0.0 
  316. * @return M2_AuthorizeNetCIM The instance of AuthorizeNetCIM class. 
  317. */ 
  318. protected function get_cim() { 
  319. $cim = null; 
  320.  
  321. if ( ! empty( self::$cim ) ) { 
  322. $cim = self::$cim; 
  323. } else { 
  324. $this->load_authorize_lib(); 
  325.  
  326. $cim = new M2_AuthorizeNetCIM( $this->api_login_id, $this->api_transaction_key ); 
  327. $cim->setSandbox( ! $this->is_live_mode() ); 
  328.  
  329. if ( WDEV_DEBUG ) { // defined in wpmu-lib submodule. 
  330. $cim->setLogFile( WP_CONTENT_DIR . '/authorize-net.log' ); 
  331. self::$cim = $cim; 
  332.  
  333. return apply_filters( 
  334. 'ms_gateway_authorize_get_cim',  
  335. $cim,  
  336. $this 
  337. ); 
  338.  
  339. /** 
  340. * Get saved customer information manager profile id. 
  341. * @since 1.0.0 
  342. * @param int $user_id The user Id. 
  343. * @return string The CIM profile Id. 
  344. */ 
  345. public function get_cim_profile_id( $member ) { 
  346. $cim_profile_id = $member->get_gateway_profile( 
  347. self::ID,  
  348. 'cim_profile_id' 
  349. ); 
  350.  
  351. return apply_filters( 
  352. 'ms_gateway_authorize_get_cim_profile_id',  
  353. $cim_profile_id,  
  354. $member,  
  355. $this 
  356. ); 
  357.  
  358. /** 
  359. * Get saved customer information manager payment profile id. 
  360. * @since 1.0.0 
  361. * @param int $user_id The user Id. 
  362. * @return string The CIM payment profile Id. 
  363. */ 
  364. public function get_cim_payment_profile_id( $member ) { 
  365. $cim_payment_profile_id = $member->get_gateway_profile( 
  366. self::ID,  
  367. 'cim_payment_profile_id' 
  368. ); 
  369.  
  370. return apply_filters( 
  371. 'ms_gateway_authorize_get_cim_payment_profile_id',  
  372. $cim_payment_profile_id,  
  373. $member,  
  374. $this 
  375. ); 
  376.  
  377. /** 
  378. * Save CIM profile IDs. 
  379. * @since 1.0.0 
  380. * @param MS_Model_Member $member The member to save CIM IDs. 
  381. * @param string $cim_profile_id The CIM profile ID to save. 
  382. * @param string $cim_payment_profile_id The CIM payment profile ID to save. 
  383. */ 
  384. protected function save_cim_profile( $member, $cim_profile_id, $cim_payment_profile_id ) { 
  385. $member->set_gateway_profile( 
  386. self::ID,  
  387. 'cim_profile_id',  
  388. $cim_profile_id 
  389. ); 
  390. $member->set_gateway_profile( 
  391. self::ID,  
  392. 'cim_payment_profile_id',  
  393. $cim_payment_profile_id 
  394. ); 
  395.  
  396. $this->save_card_info( $member ); 
  397. $member->save(); 
  398.  
  399. do_action( 
  400. 'ms_gateway_authorize_save_cim_profile',  
  401. $member,  
  402. $cim_profile_id,  
  403. $cim_payment_profile_id,  
  404. $this 
  405. ); 
  406.  
  407. /** 
  408. * Get customer information manager profile from Authorize.net. 
  409. * @since 1.0.0 
  410. * @param MS_Model_Member $member The member. 
  411. * @return array The A.net payment profiles array structure. 
  412. */ 
  413. public function get_cim_profile( $member ) { 
  414. $cim_profiles = array(); 
  415. $cim_profile_id = $this->get_cim_profile_id( $member ); 
  416.  
  417. if ( $cim_profile_id ) { 
  418. $response = $this->get_cim()->getCustomerProfile( $cim_profile_id ); 
  419.  
  420. if ( $response->isOk() ) { 
  421. $cim_profiles = json_decode( json_encode( $response->xml->profile ), true ); 
  422.  
  423. if ( is_array( $cim_profiles ) 
  424. && ! empty( $cim_profiles['paymentProfiles'] ) 
  425. && is_array( $cim_profiles['paymentProfiles'] ) 
  426. ) { 
  427. $cim_profiles = $cim_profiles['paymentProfiles']; 
  428.  
  429. return apply_filters( 
  430. 'ms_gateway_authorize_get_cim_profile',  
  431. $cim_profiles,  
  432. $this 
  433. ); 
  434.  
  435. /** 
  436. * Creates Authorize.net CIM profile for current user. 
  437. * @since 1.0.0 
  438. * @param MS_Model_Member $member The member to create CIM profile to. 
  439. */ 
  440. protected function create_cim_profile( $member ) { 
  441. do_action( 
  442. 'ms_gateway_authorize_create_cim_profile_before',  
  443. $member,  
  444. $this 
  445. ); 
  446.  
  447. $this->load_authorize_lib(); 
  448. $customer = new M2_AuthorizeNetCustomer(); 
  449. $customer->merchantCustomerId = $member->id; 
  450. $customer->email = $member->email; 
  451. $customer->paymentProfiles[] = $this->create_cim_payment_profile(); 
  452.  
  453. $response = $this->get_cim()->createCustomerProfile( $customer ); 
  454.  
  455. if ( $response->isError() ) { 
  456. MS_Helper_Debug::log( $response ); 
  457.  
  458. // Duplicate record, delete the old one. 
  459. if ( 'E00039' == $response->xml->messages->message->code ) { 
  460. $cim_profile_id = str_replace( 'A duplicate record with ID ', '', $response->xml->messages->message->text ); 
  461. $cim_profile_id = (int) str_replace( ' already exists.', '', $cim_profile_id ); 
  462.  
  463. $this->get_cim()->deleteCustomerProfile( $cim_profile_id ); 
  464.  
  465. // Try again 
  466. $this->create_cim_profile( $member ); 
  467. return; 
  468. } else { 
  469. throw new Exception( 
  470. __( 'Payment failed due to CIM profile not created: ', 'membership2' ) . $response->getMessageText() 
  471. ); 
  472.  
  473. $cim_profile_id = $response->getCustomerProfileId(); 
  474. $cim_payment_profile_id = $response->getCustomerPaymentProfileIds(); 
  475. $this->save_cim_profile( $member, $cim_profile_id, $cim_payment_profile_id ); 
  476.  
  477. /** 
  478. * Updates CIM profile by adding a new credit card. 
  479. * @since 1.0.0 
  480. * @param MS_Model_Member $member The member to update CIM profile. 
  481. */ 
  482. public function update_cim_profile( $member ) { 
  483. do_action( 
  484. 'ms_gateway_authorize_update_cim_profile_before',  
  485. $member,  
  486. $this 
  487. ); 
  488.  
  489. $cim_profile_id = $this->get_cim_profile_id( $member ); 
  490. $cim_payment_profile_id = $this->get_cim_payment_profile_id( $member ); 
  491.  
  492. if ( empty( $cim_payment_profile_id ) ) { 
  493. $response = $this->get_cim()->createCustomerPaymentProfile( 
  494. $cim_profile_id,  
  495. $this->create_cim_payment_profile() 
  496. ); 
  497. $cim_payment_profile_id = $response->getCustomerPaymentProfileIds(); 
  498. } else { 
  499. $response = $this->get_cim()->updateCustomerPaymentProfile( 
  500. $cim_profile_id,  
  501. $cim_payment_profile_id,  
  502. self::create_cim_payment_profile() 
  503. ); 
  504.  
  505. // If the error is not due to a duplicate customer payment profile. 
  506. if ( $response->isError() && 'E00039' != $response->xml->messages->message->code ) { 
  507. throw new Exception( 
  508. __( 'Payment failed due to CIM profile not updated: ', 'membership2' ) . $response->getMessageText() 
  509. ); 
  510.  
  511. $this->save_cim_profile( $member, $cim_profile_id, $cim_payment_profile_id ); 
  512.  
  513. /** 
  514. * Creates CIM payment profile and fills it with posted credit card data. 
  515. * @since 1.0.0 
  516. * @return M2_AuthorizeNetPaymentProfile The instance of AuthorizeNetPaymentProfile class. 
  517. */ 
  518. protected function create_cim_payment_profile() { 
  519. $this->load_authorize_lib(); 
  520.  
  521. $payment = new M2_AuthorizeNetPaymentProfile(); 
  522.  
  523. // billing information 
  524. $payment->billTo->firstName = substr( trim( filter_input( INPUT_POST, 'first_name' ) ), 0, 50 ); 
  525. $payment->billTo->lastName = substr( trim( filter_input( INPUT_POST, 'last_name' ) ), 0, 50 ); 
  526. $payment->billTo->company = substr( trim( filter_input( INPUT_POST, 'company' ) ), 0, 50 ); 
  527. $payment->billTo->address = substr( trim( filter_input( INPUT_POST, 'address' ) ), 0, 60 ); 
  528. $payment->billTo->city = substr( trim( filter_input( INPUT_POST, 'city' ) ), 0, 40 ); 
  529. $payment->billTo->state = substr( trim( filter_input( INPUT_POST, 'state' ) ), 0, 40 ); 
  530. $payment->billTo->zip = substr( trim( filter_input( INPUT_POST, 'zip' ) ), 0, 20 ); 
  531. $payment->billTo->country = substr( trim( filter_input( INPUT_POST, 'country' ) ), 0, 60 ); 
  532. $payment->billTo->phoneNumber = substr( trim( filter_input( INPUT_POST, 'phone' ) ), 0, 25 ); 
  533.  
  534. // card information 
  535. $payment->payment->creditCard->cardNumber = preg_replace( '/\D/', '', filter_input( INPUT_POST, 'card_num' ) ); 
  536. $payment->payment->creditCard->cardCode = trim( filter_input( INPUT_POST, 'card_code' ) ); 
  537. $payment->payment->creditCard->expirationDate = sprintf( 
  538. '%02d-%04d',  
  539. filter_input( INPUT_POST, 'exp_month', FILTER_VALIDATE_INT ),  
  540. filter_input( INPUT_POST, 'exp_year', FILTER_VALIDATE_INT ) 
  541. ); 
  542.  
  543. return apply_filters( 
  544. 'ms_gateway_authorize_create_cim_payment_profile',  
  545. $payment,  
  546. $this 
  547. ); 
  548.  
  549. /** 
  550. * Initializes and returns Authorize.net CIM transaction object. 
  551. * @since 1.0.0 
  552. * @param MS_Model_Member $member The member. 
  553. * @return M2_AuthorizeNetTransaction The instance of AuthorizeNetTransaction class. 
  554. */ 
  555. protected function get_cim_transaction( $member ) { 
  556. $this->load_authorize_lib(); 
  557.  
  558. $cim_profile_id = $this->get_cim_profile_id( $member ); 
  559. $cim_payment_profile_id = $this->get_cim_payment_profile_id( $member ); 
  560.  
  561. if ( empty( $cim_profile_id ) || empty( $cim_payment_profile_id ) ) { 
  562. throw new Exception( __( 'CIM Payment profile not found', 'membership2' ) ); 
  563.  
  564. $transaction = new M2_AuthorizeNetTransaction(); 
  565. $transaction->customerProfileId = $cim_profile_id; 
  566. $transaction->customerPaymentProfileId = $cim_payment_profile_id; 
  567.  
  568. // Include the card code if the secure-cc flag is enabled! 
  569. if ( lib3()->is_true( $this->secure_cc ) ) { 
  570. if ( ! empty( $_POST['card_code'] ) ) { 
  571. $transaction->cardCode = $_POST['card_code']; 
  572.  
  573. return apply_filters( 
  574. 'ms_gateway_authorize_get_cim_transaction',  
  575. $transaction,  
  576. $member,  
  577. $this 
  578. ); 
  579.  
  580. /** 
  581. * Verify required fields. 
  582. * @since 1.0.0 
  583. * @return boolean True if it is configured. 
  584. */ 
  585. public function is_configured() { 
  586. $is_configured = true; 
  587. $required = array( 'api_login_id', 'api_transaction_key' ); 
  588.  
  589. foreach ( $required as $field ) { 
  590. $value = $this->$field; 
  591. if ( empty( $value ) ) { 
  592. $is_configured = false; 
  593. break; 
  594.  
  595. return apply_filters( 
  596. 'ms_gateway_authorize_is_configured',  
  597. $is_configured,  
  598. $this 
  599. );