diff --git a/app/PaymentDrivers/Blockonomics/Blockonomics.php b/app/PaymentDrivers/Blockonomics/Blockonomics.php
index 313063921fe6..3da7a37815a9 100644
--- a/app/PaymentDrivers/Blockonomics/Blockonomics.php
+++ b/app/PaymentDrivers/Blockonomics/Blockonomics.php
@@ -33,7 +33,7 @@ class Blockonomics implements MethodInterface
{
use MakesHash;
- protected BlockonomicsPaymentDriver $blockonomics;
+ public $driver_class;
public function __construct(BlockonomicsPaymentDriver $driver_class)
{
diff --git a/app/PaymentDrivers/BlockonomicsPaymentDriver.php b/app/PaymentDrivers/BlockonomicsPaymentDriver.php
index 70fc1cf56c14..3438c0f6bc58 100644
--- a/app/PaymentDrivers/BlockonomicsPaymentDriver.php
+++ b/app/PaymentDrivers/BlockonomicsPaymentDriver.php
@@ -53,10 +53,102 @@ class BlockonomicsPaymentDriver extends BaseDriver
{
$this->api_key = $this->company_gateway->getConfigField('apiKey');
$this->callback_url = $this->company_gateway->getConfigField('callbackUrl');
+ $this->callback_secret = $this->company_gateway->getConfigField('callbackSecret');
// $this->setCallbackUrl();
return $this; /* This is where you boot the gateway with your auth credentials*/
}
+
+ public function findPaymentByTxid($txid)
+ {
+ return Payment::whereRaw('BINARY `transaction_reference` LIKE ?', ["%txid: " . $txid])->firstOrFail();
+ }
+
+
+
+ /* Returns an array of gateway types for the payment gateway */
+ public function gatewayTypes(): array
+ {
+ $types = [];
+
+ $types[] = GatewayType::CRYPTO;
+
+ return $types;
+ }
+
+ public function setPaymentMethod($payment_method_id)
+ {
+ $class = self::$methods[$payment_method_id];
+ $this->payment_method = new $class($this);
+ return $this;
+ }
+
+ public function processPaymentView(array $data)
+ {
+ return $this->payment_method->paymentView($data); //this is your custom implementation from here
+ }
+
+ public function processPaymentResponse($request)
+ {
+ return $this->payment_method->paymentResponse($request);
+ }
+
+ public function processWebhookRequest()
+ {
+ // TODO: Figure out why init does not work
+ $this->init();
+ $secret = $this->callback_secret;
+ //Match secret for security
+ if ($_GET['secret'] != $secret) {
+ echo "Invalid Secret";
+ return;
+ }
+
+ $txid = $_GET['txid'];
+ $value = $_GET['value'];
+ $status = $_GET['status'];
+ $addr = $_GET['addr'];
+
+ // Only accept confirmed transactions
+ if ($status != 2) {
+ throw new PaymentFailed('Transaction not confirmed');
+ }
+
+ $payment = $this->findPaymentByTxid($txid);
+ // $payment_hash = $this->findPaymentHashInTransactionReference($payment->transaction_reference);
+
+ switch ($status) {
+ case 0:
+ $statusId = Payment::STATUS_PENDING;
+ break;
+ case 1:
+ $statusId = Payment::STATUS_PENDING;
+ break;
+ case 2:
+ $statusId = Payment::STATUS_COMPLETED;
+ break;
+ }
+
+ // Save the updated payment status
+ if ($payment->status_id != $statusId) {
+ $payment->status_id = $statusId;
+ $payment->save();
+ }
+
+ header('HTTP/1.1 200 OK');
+ echo 'SUCCESS';
+ return;
+ }
+
+
+ public function refund(Payment $payment, $amount, $return_client_response = false)
+ {
+ $this->setPaymentMethod(GatewayType::CRYPTO);
+ return $this->payment_method->refund($payment, $amount); //this is your custom implementation from here
+ }
+}
+
+
// public function doCurlCall($url, $post_content = '')
// {
// $ch = curl_init();
@@ -109,93 +201,4 @@ class BlockonomicsPaymentDriver extends BaseDriver
// // Return null if no match is found
// return null;
// }
- // }
-
- public function findPaymentByTxid($txid)
- {
- return Payment::whereRaw('BINARY `transaction_reference` LIKE ?', ["%txid: " . $txid])->firstOrFail();
- }
-
-
-
- /* Returns an array of gateway types for the payment gateway */
- public function gatewayTypes(): array
- {
- $types = [];
-
- $types[] = GatewayType::CRYPTO;
-
- return $types;
- }
-
- public function setPaymentMethod($payment_method_id)
- {
- $class = self::$methods[$payment_method_id];
- $this->payment_method = new $class($this);
- return $this;
- }
-
- public function processPaymentView(array $data)
- {
- return $this->payment_method->paymentView($data); //this is your custom implementation from here
- }
-
- public function processPaymentResponse($request)
- {
- return $this->payment_method->paymentResponse($request);
- }
-
- public function processWebhookRequest()
- {
- // TODO: Figure out why init does not work
- // $this->init();
- // $secret = $this->company_gateway->getConfigField('callbackSecret');
- // //Match secret for security
- // if ($_GET['secret'] != $secret) {
- // echo "Invalid Secret";
- // return;
- // }
-
- $txid = $_GET['txid'];
- $value = $_GET['value'];
- $status = $_GET['status'];
- $addr = $_GET['addr'];
-
- // Only accept confirmed transactions
- if ($status != 2) {
- throw new PaymentFailed('Transaction not confirmed');
- }
-
- $payment = $this->findPaymentByTxid($txid);
- // $payment_hash = $this->findPaymentHashInTransactionReference($payment->transaction_reference);
-
- switch ($status) {
- case 0:
- $statusId = Payment::STATUS_PENDING;
- break;
- case 1:
- $statusId = Payment::STATUS_PENDING;
- break;
- case 2:
- $statusId = Payment::STATUS_COMPLETED;
- break;
- }
-
- // Save the updated payment status
- if ($payment->status_id != $statusId) {
- $payment->status_id = $statusId;
- $payment->save();
- }
-
- header('HTTP/1.1 200 OK');
- echo 'SUCCESS';
- return;
- }
-
-
- public function refund(Payment $payment, $amount, $return_client_response = false)
- {
- $this->setPaymentMethod(GatewayType::CRYPTO);
- return $this->payment_method->refund($payment, $amount); //this is your custom implementation from here
- }
-}
+ // }
\ No newline at end of file
diff --git a/database/seeders/PaymentLibrariesSeeder.php b/database/seeders/PaymentLibrariesSeeder.php
index 964b81864909..84ba32556b4e 100644
--- a/database/seeders/PaymentLibrariesSeeder.php
+++ b/database/seeders/PaymentLibrariesSeeder.php
@@ -25,11 +25,11 @@ class PaymentLibrariesSeeder extends Seeder
Model::unguard();
$callbackSecret = md5(uniqid(rand(), true));
- $callbackUrl = config('ninja.app_url') . "/api/v1/blockonomics/callback/?secret=$callbackSecret";
+ $callbackUrl = config('ninja.app_url') . '/api/v1/blockonomics/callback/?secret=' . $callbackSecret;
$blockonomics_fields = "{
- \"apiKey\": \"\",
+ \"apiKey\": \"PleaseEnterYourApiKeyHere\",
\"callbackUrl\": \"$callbackUrl\",
- \"callbackSecret\": \"$callbackSecret\",
+ \"callbackSecret\": \"$callbackSecret\"
}";
@@ -98,7 +98,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' => "$blockonomics_fields"],
+ ['id' => 64, 'name' => 'Blockonomics', 'provider' => 'Blockonomics', 'key' => 'wbhf02us6owgo7p4nfjd0ymssdshks4d', 'fields' => $blockonomics_fields],
];
foreach ($gateways as $gateway) {
diff --git a/resources/views/portal/ninja2020/gateways/blockonomics/pay.blade.php b/resources/views/portal/ninja2020/gateways/blockonomics/pay.blade.php
index baf8bc44ac71..ca6030019cfa 100644
--- a/resources/views/portal/ninja2020/gateways/blockonomics/pay.blade.php
+++ b/resources/views/portal/ninja2020/gateways/blockonomics/pay.blade.php
@@ -21,7 +21,7 @@