-
Notifications
You must be signed in to change notification settings - Fork 12
(fix) Test Setup Placement and Actual Test #130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: bch-admin-ui-updates
Are you sure you want to change the base?
(fix) Test Setup Placement and Actual Test #130
Conversation
Updated Test Setup Script and Frontend to send single request to test all enabled ceyptos. Current Issues:
|
return $test_results; | ||
} | ||
|
||
public function test_one_currency($new_api, $currency) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test_one_currency can be renamed to test_one_crypto and refactored to match the latest woocommerce structure, which makes the code easier to read:
https://github.com/blockonomics/woocommerce-plugin/blob/master/php/Blockonomics.php#L343-L357
https://github.com/blockonomics/woocommerce-plugin/blob/master/php/Blockonomics.php#L193-L208
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I though so too, but in the plugin code, crypto is being referred as currency in every function, changing it to crypto might cause confusions and human errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will be best to use currency
for the fiat currency linked to each order and crypto
for the blockonomics cryptocurrencies.
Moving forward lets use this standard. I have opened a new issue for us to correct any existing functions that do not adhere to this #131.
$response->errorStr = $error; | ||
if (isset($error) && count($error) != 0) { | ||
if (count(array_filter($error, function($item) { return $item != false; })) != 0) { | ||
$response->error = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$response->error can be removed as the errorStr will be an empty array if there are no errors
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay.
Updated and removed the new API Key check and extra params from response. |
if (isset($newApi)) { | ||
$blockonomics = new Blockonomics(); | ||
$response = array(); | ||
$error = array(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not required as testSetup returns an empty array if there are no errors. The checks below which count the error length can also be removed. The following code should be enough as we check the error array later:
$blockonomics = new Blockonomics();
$error = $blockonomics->testSetup();
echo json_encode($error);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
Refactored the testSetup functionality to individual methods corresponding to Woocommerce Plugin. |
Added:
|
Added:
|
} | ||
$callback_secret = $this->getCallbackSecret(); | ||
$callback_url = $this->getCallbackUrl($callback_secret); | ||
$base_url = preg_replace('/https?:\/\//', '', substr($callback_url, 0, -48)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-48 is a very hacky way, please use length of secret instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay
if (count($response->data) == 1) { | ||
$error_str = $_BLOCKLANG['testSetup']['existingCallbackUrl']; | ||
} else { | ||
$error_str = $_BLOCKLANG['testSetup']['multipleXpubs']; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not matching woocommerce code . please check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Because Woocommerce only returns Please add a new store on blockonomics website
while WHMCS Plugin returned You have an existing callback URL. Refer instructions on integrating multiple websites
and Your have an existing callback URL or multiple xPubs. Refer instructions on integrating multiple websites
based on whether user has single or multiple stores.
We can change it to the same as Woocommerce i.e. Single Message for both cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Referencing the comment, I Will change it to a single message.
$_BLOCKLANG['testSetup']['noXpub'] = 'You have not entered an xpub'; | ||
$_BLOCKLANG['testSetup']['existingCallbackUrl'] = 'Your have an existing callback URL. Refer instructions on integrating multiple websites'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no need for messages 59-61. Note the changes in wocoomerce. There is only one message that we use everywhere
https://github.com/blockonomics/woocommerce-plugin/blob/master/php/Blockonomics.php#L141
https://github.com/blockonomics/woocommerce-plugin/blob/master/php/Blockonomics.php#L187
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok
Updated:
|
@@ -760,7 +760,7 @@ public function examine_server_callback_urls($response, $currency) | |||
|
|||
$callback_secret = $this->getCallbackSecret(); | |||
$callback_url = $this->getCallbackUrl($callback_secret); | |||
$base_url = preg_replace('/https?:\/\//', '', substr($callback_url, 0, -48)); | |||
$base_url = preg_replace('/https?:\/\//', '', substr($callback_url, 0, -1 * (strlen($callback_secret) + 8))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the 8 added. Please add a code comment so that this code is more understandable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the extraction logic to use strtok
instead of manually working on it. it'll now split the string before ?
and give the callback URL without needing to use substr
This PR fixes Multi Crypto Testing and Layout issues. Extends #128