コード例 #1
0
 protected function newAccount()
 {
     // make sure all required fields are populated
     if (empty($_POST['wpla_secret_key'])) {
         $this->showMessage(__('No secret key was provided.', 'wpla'), 1);
         return;
     }
     if (empty($_POST['wpla_access_key_id'])) {
         $this->showMessage(__('No AWS Access Key ID was provided.', 'wpla'), 1);
         return;
     }
     if (empty($_POST['wpla_merchant_id'])) {
         $this->showMessage(__('No Merchant ID was provided.', 'wpla'), 1);
         return;
     }
     if (empty($_POST['wpla_marketplace_id'])) {
         $this->showMessage(__('No Marketplace ID was provided.', 'wpla'), 1);
         return;
     }
     // TODO: check nonce
     if (isset($_POST['wpla_merchant_id'])) {
         // create new account
         $account = new WPLA_AmazonAccount();
         $account->title = stripslashes($_POST['wpla_account_title']);
         $account->market_id = trim($_POST['wpla_amazon_market_id']);
         $account->market_code = trim($_POST['wpla_amazon_market_code']);
         $account->merchant_id = trim($_POST['wpla_merchant_id']);
         $account->marketplace_id = trim($_POST['wpla_marketplace_id']);
         $account->access_key_id = trim($_POST['wpla_access_key_id']);
         $account->secret_key = trim($_POST['wpla_secret_key']);
         $account->active = 1;
         $account->add();
         // update allowed markets
         $account->updateMarketplaceParticipations();
         $this->showMessage(__('New account was added.', 'wpla'));
     }
 }