diff --git a/app/PaymentDrivers/Blockonomics/Blockonomics.php b/app/PaymentDrivers/Blockonomics/Blockonomics.php index 7f67d7925ce7..9b6f5e282661 100644 --- a/app/PaymentDrivers/Blockonomics/Blockonomics.php +++ b/app/PaymentDrivers/Blockonomics/Blockonomics.php @@ -67,16 +67,10 @@ class Blockonomics implements MethodInterface $drv = $this->driver_class; if ( - strlen($drv->blockonomics_url) < 1 - || strlen($drv->api_key) < 1 - || strlen($drv->store_id) < 1 - || strlen($drv->webhook_secret) < 1 + strlen($drv->api_key) < 1 ) { throw new PaymentFailed('Blockonomics is not well configured'); } - if (!filter_var($this->driver_class->blockonomics_url, FILTER_VALIDATE_URL)) { - throw new PaymentFailed('Wrong format for Blockonomics Url'); - } try { $_invoice = collect($drv->payment_hash->data->invoices)->first(); diff --git a/app/PaymentDrivers/BlockonomicsPaymentDriver.php b/app/PaymentDrivers/BlockonomicsPaymentDriver.php index 170d0c134998..1660c56d0b28 100644 --- a/app/PaymentDrivers/BlockonomicsPaymentDriver.php +++ b/app/PaymentDrivers/BlockonomicsPaymentDriver.php @@ -28,7 +28,7 @@ class BlockonomicsPaymentDriver extends BaseDriver { use MakesHash; - public $refundable = true; //does this gateway support refunds? + public $refundable = false; //does this gateway support refunds? public $token_billing = false; //does this gateway support token billing? @@ -44,19 +44,31 @@ class BlockonomicsPaymentDriver extends BaseDriver public const SYSTEM_LOG_TYPE = SystemLog::TYPE_CHECKOUT; //define a constant for your gateway ie TYPE_YOUR_CUSTOM_GATEWAY - set the const in the SystemLog model - public $blockonomics_url = ""; - public $api_key = ""; - public $store_id = ""; - public $webhook_secret = ""; + public const api_key = ""; public $blockonomics; + public $BASE_URL = 'https://www.blockonomics.co'; + public $NEW_ADDRESS_URL = 'https://www.blockonomics.co/api/new_address'; + public $PRICE_URL = 'https://www.blockonomics.co/api/price'; + public $SET_CALLBACK_URL = 'https://www.blockonomics.co/api/update_callback'; + public $GET_CALLBACKS_URL = 'https://www.blockonomics.co/api/address?&no_balance=true&only_xpub=true&get_callback=true'; + public function get_callbacks($crypto) + { + $response = $this->get($GET_CALLBACKS_URL, $this->api_key); + return $response; + } + + public function get_callbackSecret() + { + return md5(uniqid(rand(), true)); + } + public function init() { - $this->blockonomics_url = $this->company_gateway->getConfigField('blockonomicsUrl'); + $response = $this->get_callbacks(); $this->api_key = $this->company_gateway->getConfigField('apiKey'); - $this->store_id = $this->company_gateway->getConfigField('storeId'); - $this->webhook_secret = $this->company_gateway->getConfigField('webhookSecret'); + $this->callback_url = $this->company_gateway->getConfigField('callbackUrl'); return $this; /* This is where you boot the gateway with your auth credentials*/ } @@ -118,11 +130,11 @@ class BlockonomicsPaymentDriver extends BaseDriver } $this->init(); - $webhookClient = new Webhook($this->blockonomics_url, $this->api_key); + $webhookClient = new Webhook($this->btcpay_url, $this->api_key); if (!$webhookClient->isIncomingWebhookRequestValid($webhook_payload, $sig, $this->webhook_secret)) { throw new \RuntimeException( - 'Invalid payment notification message received - signature did not match.' + 'Invalid BTCPayServer payment notification message received - signature did not match.' ); } diff --git a/database/migrations/2024_08_27_230111_blockonomics_gateway.php b/database/migrations/2024_08_27_230111_blockonomics_gateway.php index dcca0eeaffb6..0688903b8cdb 100644 --- a/database/migrations/2024_08_27_230111_blockonomics_gateway.php +++ b/database/migrations/2024_08_27_230111_blockonomics_gateway.php @@ -16,10 +16,8 @@ return new class extends Migration { $fields = new \stdClass; - $fields->blockonomicsUrl = ""; $fields->apiKey = ""; - $fields->storeId = ""; - $fields->webhookSecret = ""; + $fields->callbackUrl = ""; $gateway = new Gateway; $gateway->id = 64; diff --git a/database/seeders/PaymentLibrariesSeeder.php b/database/seeders/PaymentLibrariesSeeder.php index fb61aebdd175..0311a586a434 100644 --- a/database/seeders/PaymentLibrariesSeeder.php +++ b/database/seeders/PaymentLibrariesSeeder.php @@ -89,7 +89,7 @@ class PaymentLibrariesSeeder extends Seeder ['id' => 61, 'name' => 'PayPal Platform', 'provider' => 'PayPal_PPCP', 'key' => '80af24a6a691230bbec33e930ab40666', 'fields' => '{"testMode":false}'], ['id' => 62, 'name' => 'BTCPay', 'provider' => 'BTCPay', 'key' => 'vpyfbmdrkqcicpkjqdusgjfluebftuva', 'fields' => '{"btcpayUrl":"", "apiKey":"", "storeId":"", "webhookSecret":""}'], ['id' => 63, 'name' => 'Rotessa', 'is_offsite' => false, 'sort_order' => 22, 'provider' => 'Rotessa', 'key' => '91be24c7b792230bced33e930ac61676', 'fields' => '{"apiKey":"", "testMode":""}'], - ['id' => 64, 'name' => 'Blockonomics', 'provider' => 'Blockonomics', 'key' => 'wbhf02us6owgo7p4nfjd0ymssdshks4d', 'fields' => '{"blockonomicsUrl":"", "apiKey":"", "storeId":"", "webhookSecret":""}'], + ['id' => 64, 'name' => 'Blockonomics', 'provider' => 'Blockonomics', 'key' => 'wbhf02us6owgo7p4nfjd0ymssdshks4d', 'fields' => '{"apiKey":"", "callbackUrl":""}'], ]; foreach ($gateways as $gateway) {