1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
<?php
defined( 'ABSPATH' ) || exit();
class WC_Stripe_Account_Settings extends WC_Stripe_Settings_API {
public function __construct() {
$this->id = 'stripe_account';
parent::__construct();
}
public function hooks() {
add_action( 'wc_stripe_connect_settings', array( $this, 'connect_settings' ) );
}
public function connect_settings( $response ) {
$this->save_account_settings( $response->live->stripe_user_id );
}
public function save_account_settings( $account_id ) {
$account = WC_Stripe_Gateway::load( 'live' )->accounts->retrieve( $account_id );
if ( ! is_wp_error( $account ) ) {
$this->settings['account_id'] = $account->id;
$this->settings['country'] = strtoupper( $account->country );
$this->settings['default_currency'] = strtoupper( $account->default_currency );
update_option( $this->get_option_key(), $this->settings, 'yes' );
}
}
}