1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-08 20:22:42 +01:00

Fixes for blockonomics

This commit is contained in:
David Bomba 2024-09-18 17:12:52 +10:00
parent 9848a54192
commit 7f936ad18b
5 changed files with 19 additions and 15 deletions

View File

@ -237,7 +237,7 @@ class Gateway extends StaticModel
],
GatewayType::ACSS => ['refund' => false, 'token_billing' => true, 'webhooks' => []]
]; // Rotessa
case 64:
case 65:
return [
GatewayType::CRYPTO => ['refund' => true, 'token_billing' => false, 'webhooks' => ['confirmed', 'paid_out', 'failed', 'fulfilled']],
]; //Blockonomics

View File

@ -109,10 +109,11 @@ class Blockonomics implements MethodInterface
$data['payment_method_id'] = $request->payment_method_id;
$data['payment_type'] = PaymentType::CRYPTO;
$data['gateway_type_id'] = GatewayType::CRYPTO;
$data['transaction_reference'] = "payment hash: " . $request->payment_hash . " txid: " . $request->txid . " BTC amount: " . $request->btc_amount;
$data['transaction_reference'] = $request->txid;
$statusId = Payment::STATUS_PENDING;
$payment = $this->blockonomics->createPayment($data, $statusId);
SystemLogger::dispatch(
['response' => $payment, 'data' => $data],
SystemLog::CATEGORY_GATEWAY_RESPONSE,

View File

@ -115,10 +115,11 @@ class BlockonomicsPaymentDriver extends BaseDriver
return $this->payment_method->paymentResponse($request);
}
public function processWebhookRequest()
public function processWebhookRequest(PaymentWebhookRequest $request)
{
$url_callback_secret = $_GET['secret'];
nlog($request->all());
$url_callback_secret = $request->secret;
$db_callback_secret = $this->getCallbackSecret();
if ($url_callback_secret != $db_callback_secret) {
@ -150,13 +151,16 @@ class BlockonomicsPaymentDriver extends BaseDriver
}
if($payment->status_id == $statusId) {
header('HTTP/1.1 200 OK');
echo "No change in payment status";
return response()->json([], 200);
// header('HTTP/1.1 200 OK');
// echo "No change in payment status";
} else {
$payment->status_id = $statusId;
$payment->save();
header('HTTP/1.1 200 OK');
echo "Payment status updated successfully";
return response()->json([], 200);
// header('HTTP/1.1 200 OK');
// echo "Payment status updated successfully";
}
}

View File

@ -12,20 +12,19 @@ return new class extends Migration
*/
public function up(): void
{
if(!Gateway::find(64))
if(!Gateway::find(65))
{
$fields = new \stdClass;
$fields->apiKey = "";
$fields->callbackUrl = "";
$fields->callbackSecret = "";
$gateway = new Gateway;
$gateway->id = 64;
$gateway->id = 65;
$gateway->name = 'Blockonomics';
$gateway->key = 'wbhf02us6owgo7p4nfjd0ymssdshks4d';
$gateway->provider = 'Blockonomics';
$gateway->is_offsite = true;
$gateway->is_offsite = false;
$gateway->fields = \json_encode($fields);

View File

@ -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' => 65, 'name' => 'Blockonomics', 'provider' => 'Blockonomics', 'key' => 'wbhf02us6owgo7p4nfjd0ymssdshks4d', 'fields' => "$blockonomics_fields"],
];
foreach ($gateways as $gateway) {
@ -115,7 +115,7 @@ class PaymentLibrariesSeeder extends Seeder
Gateway::query()->update(['visible' => 0]);
Gateway::whereIn('id', [1, 3, 7, 11, 15, 20, 39, 46, 55, 50, 57, 52, 58, 59, 60, 62, 63, 64])->update(['visible' => 1]);
Gateway::whereIn('id', [1, 3, 7, 11, 15, 20, 39, 46, 55, 50, 57, 52, 58, 59, 60, 62, 63, 64,65])->update(['visible' => 1]);
if (Ninja::isHosted()) {
Gateway::whereIn('id', [20, 49])->update(['visible' => 0]);