mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
temp
This commit is contained in:
parent
bd4b4a6712
commit
97e3881017
@ -33,7 +33,7 @@ class Blockonomics implements MethodInterface
|
||||
{
|
||||
use MakesHash;
|
||||
|
||||
protected BlockonomicsPaymentDriver $blockonomics;
|
||||
public $driver_class;
|
||||
|
||||
public function __construct(BlockonomicsPaymentDriver $driver_class)
|
||||
{
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
// }
|
@ -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) {
|
||||
|
@ -21,7 +21,7 @@
|
||||
<input class="full-width-input" id="btcAddress" value="{{$btc_address}}" readonly >
|
||||
<img src="{{ 'data:image/svg+xml;base64,' . base64_encode('<svg width="22" height="24" viewBox="0 0 22 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M15.5 1H3.5C2.4 1 1.5 1.9 1.5 3V17H3.5V3H15.5V1ZM18.5 5H7.5C6.4 5 5.5 5.9 5.5 7V21C5.5 22.1 6.4 23 7.5 23H18.5C19.6 23 20.5 22.1 20.5 21V7C20.5 5.9 19.6 5 18.5 5ZM18.5 21H7.5V7H18.5V21Z" fill="#000"/></svg>') }}" class="icon" alt="Copy Icon">
|
||||
</div>
|
||||
<div id="countdown"></div>
|
||||
<div id="countdown"></div><span class="blockonomics-icon-refresh"></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -163,6 +163,10 @@
|
||||
transform: translateY(-50%);
|
||||
cursor: pointer;
|
||||
}
|
||||
.icon-refresh::before {
|
||||
content: '\e903';
|
||||
cursor: pointer;
|
||||
}
|
||||
/* .progress-message {
|
||||
display: none;
|
||||
margin: 90px 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user