Subaddresses
Generate subaddress instead of payment id and don't bother creating an integrated address if we're using the rpc.
This commit is contained in:
parent
5064b95040
commit
8009819592
@ -209,12 +209,24 @@ class Monero_Gateway extends WC_Payment_Gateway
|
|||||||
|
|
||||||
$order = wc_get_order($order_id);
|
$order = wc_get_order($order_id);
|
||||||
|
|
||||||
// Generate a unique payment id
|
if(self::$confirm_type != 'wownero-wallet-rpc') {
|
||||||
do {
|
// Generate a unique payment id
|
||||||
$payment_id = bin2hex(openssl_random_pseudo_bytes(8));
|
do {
|
||||||
$query = $wpdb->prepare("SELECT COUNT(*) FROM $table_name WHERE payment_id=%s", array($payment_id));
|
$payment_id = bin2hex(openssl_random_pseudo_bytes(8));
|
||||||
$payment_id_used = $wpdb->get_var($query);
|
$query = $wpdb->prepare("SELECT COUNT(*) FROM $table_name WHERE payment_id=%s", array($payment_id));
|
||||||
} while ($payment_id_used);
|
$payment_id_used = $wpdb->get_var($query);
|
||||||
|
} while ($payment_id_used);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Generate subaddress
|
||||||
|
$payment_id = self::$wownero_wallet_rpc->create_address(0, 'Order: ' . $order_id);
|
||||||
|
if(isset($payment_id['address'])) {
|
||||||
|
$payment_id = $payment_id['address'];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$this->log->add('Wownero_Gateway', 'Couldn\'t create subaddress for order ' . $order_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$currency = $order->get_currency();
|
$currency = $order->get_currency();
|
||||||
$rate = self::get_live_rate($currency);
|
$rate = self::get_live_rate($currency);
|
||||||
@ -477,13 +489,7 @@ class Monero_Gateway extends WC_Payment_Gateway
|
|||||||
$payment_id = self::sanatize_id($details[0]->payment_id);
|
$payment_id = self::sanatize_id($details[0]->payment_id);
|
||||||
|
|
||||||
if(self::$confirm_type == 'monero-wallet-rpc') {
|
if(self::$confirm_type == 'monero-wallet-rpc') {
|
||||||
$array_integrated_address = self::$monero_wallet_rpc->make_integrated_address($payment_id);
|
$integrated_addr = $payment_id;
|
||||||
if (isset($array_integrated_address['integrated_address'])) {
|
|
||||||
$integrated_addr = $array_integrated_address['integrated_address'];
|
|
||||||
} else {
|
|
||||||
self::$log->add('Monero_Gateway', '[ERROR] Unable get integrated address');
|
|
||||||
return '[ERROR] Unable get integrated address';
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if ($address) {
|
if ($address) {
|
||||||
$decoded_address = self::$cryptonote->decode_address($address);
|
$decoded_address = self::$cryptonote->decode_address($address);
|
||||||
|
Loading…
Reference in New Issue
Block a user