adapt needed vars to be in line with what's needed for blockonomics

This commit is contained in:
cnohall 2024-09-03 10:04:27 +09:00
parent 7d29463833
commit f26b38d09d
4 changed files with 25 additions and 21 deletions

View File

@ -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();

View File

@ -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.'
);
}

View File

@ -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;

View File

@ -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) {