mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
temp, still missing payment screen
This commit is contained in:
parent
c7d7e46582
commit
e220cb7a4e
@ -13,6 +13,8 @@
|
||||
namespace App\PaymentDrivers\Blockonomics;
|
||||
|
||||
use App\Models\Payment;
|
||||
use App\Models\PaymentType;
|
||||
use App\Models\GatewayType;
|
||||
use App\PaymentDrivers\BlockonomicsPaymentDriver;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use App\PaymentDrivers\Common\MethodInterface;
|
||||
@ -67,35 +69,24 @@ class Blockonomics implements MethodInterface
|
||||
|
||||
$drv = $this->driver_class;
|
||||
if (
|
||||
strlen($drv->api_key) < 1
|
||||
strlen($drv->api_key) < 1 ||
|
||||
strlen($drv->callback_secret) < 1 ||
|
||||
strlen($drv->callback_url) < 1
|
||||
) {
|
||||
throw new PaymentFailed('Blockonomics is not well configured');
|
||||
}
|
||||
|
||||
try {
|
||||
// This is where the payment happens
|
||||
// Will probably have to implement a curl request to the blockonomics API
|
||||
// to create a new payment request
|
||||
// Or potentially use an off-site solution
|
||||
// $data = [
|
||||
// 'payment_method' => '',
|
||||
// 'payment_type' => PaymentType::CRYPTO,
|
||||
// 'amount' => 200,
|
||||
// 'transaction_reference' => 123,
|
||||
// 'gateway_type_id' => GatewayType::CRYPTO,
|
||||
// ];
|
||||
|
||||
$_invoice = collect($drv->payment_hash->data->invoices)->first();
|
||||
$cli = $drv->client;
|
||||
|
||||
$metaData = [
|
||||
'buyerName' => $cli->name,
|
||||
'buyerAddress1' => $cli->address1,
|
||||
'buyerAddress2' => $cli->address2,
|
||||
'buyerCity' => $cli->city,
|
||||
'buyerState' => $cli->state,
|
||||
'buyerZip' => $cli->postal_code,
|
||||
'buyerCountry' => $cli->country_id,
|
||||
'buyerPhone' => $cli->phone,
|
||||
'itemDesc' => "From InvoiceNinja",
|
||||
'InvoiceNinjaPaymentHash' => $drv->payment_hash->hash
|
||||
];
|
||||
|
||||
|
||||
$urlRedirect = redirect()->route('client.invoice.show', ['invoice' => $_invoice->invoice_id])->getTargetUrl();
|
||||
// $payment = $this->createPayment($data, Payment::STATUS_COMPLETED);
|
||||
return redirect()->route('client.payments.show', ['payment' => $this->encodePrimaryKey(6)]);
|
||||
|
||||
} catch (\Throwable $e) {
|
||||
PaymentFailureMailer::dispatch($drv->client, $drv->payment_hash->data, $drv->client->company, $request->amount);
|
||||
|
@ -53,8 +53,8 @@ class BlockonomicsPaymentDriver extends BaseDriver
|
||||
public function init()
|
||||
{
|
||||
$this->api_key = $this->company_gateway->getConfigField('apiKey');
|
||||
$response = $this->get_callbacks($this->api_key);
|
||||
$this->callback_url = $response;
|
||||
$this->callback_secret = $this->company_gateway->getConfigField('callbackSecret');
|
||||
$this->callback_url = $this->company_gateway->getConfigField('callbackUrl');
|
||||
return $this; /* This is where you boot the gateway with your auth credentials*/
|
||||
}
|
||||
|
||||
@ -93,6 +93,20 @@ class BlockonomicsPaymentDriver extends BaseDriver
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function getBTCPrice($id_currency)
|
||||
{
|
||||
$BLOCKONOMICS_BASE_URL = 'https://www.blockonomics.co';
|
||||
$BLOCKONOMICS_PRICE_URL = $BLOCKONOMICS_BASE_URL . '/api/price?currency=';
|
||||
// Getting price
|
||||
// $currency = new Currency((int) $id_currency);
|
||||
// $options = ['http' => ['method' => 'GET']];
|
||||
// $context = stream_context_create($options);
|
||||
// $contents = Tools::file_get_contents(Configuration::get('BLOCKONOMICS_PRICE_URL') . $currency->iso_code, false, $context);
|
||||
// $priceObj = Tools::jsonDecode($contents);
|
||||
|
||||
return $priceObj->price;
|
||||
}
|
||||
|
||||
// public function get_callbackSecret()
|
||||
// {
|
||||
// return md5(uniqid(rand(), true));
|
||||
@ -161,7 +175,7 @@ class BlockonomicsPaymentDriver extends BaseDriver
|
||||
|
||||
if (!$webhookClient->isIncomingWebhookRequestValid($webhook_payload, $sig, $this->webhook_secret)) {
|
||||
throw new \RuntimeException(
|
||||
'Invalid BTCPayServer payment notification message received - signature did not match.'
|
||||
'Invalid blockonomics payment notification message received - signature did not match.'
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -15,13 +15,10 @@ return new class extends Migration
|
||||
if(!Gateway::find(64))
|
||||
{
|
||||
|
||||
$BLOCKONOMICS_BASE_URL = 'https://www.blockonomics.co';
|
||||
$BLOCKONOMICS_GET_CALLBACKS_URL = $BLOCKONOMICS_BASE_URL . '/api/address?&no_balance=true&only_xpub=true&get_callback=true';
|
||||
$fields = new \stdClass;
|
||||
$fields->apiKey = "";
|
||||
// insert call to get callback url and set callback url based on response
|
||||
$fields->callbackUrl = config('ninja.app_url');
|
||||
$fields->callbackSecret = md5(uniqid(rand(), true));
|
||||
$fields->callbackUrl = "";
|
||||
$fields->callbackSecret = "";
|
||||
|
||||
$gateway = new Gateway;
|
||||
$gateway->id = 64;
|
||||
|
@ -24,6 +24,16 @@ class PaymentLibrariesSeeder extends Seeder
|
||||
{
|
||||
Model::unguard();
|
||||
|
||||
// TODO: use get callbacks API to get the callback URL
|
||||
$callbackUrl = config('ninja.app_url') . '/payment/callback';
|
||||
$callbackSecret = md5(uniqid(rand(), true));
|
||||
$blockonomics_fields = "{
|
||||
\"apiKey\": \"\",
|
||||
\"callbackUrl\": \"$callbackUrl\",
|
||||
\"callbackSecret\": \"$callbackSecret\"
|
||||
}";
|
||||
|
||||
|
||||
$gateways = [
|
||||
['id' => 1, 'name' => 'Authorize.Net', 'provider' => 'Authorize', 'sort_order' => 5, 'key' => '3b6621f970ab18887c4f6dca78d3f8bb', 'fields' => '{"apiLoginId":"","transactionKey":"","testMode":false,"developerMode":false,"liveEndpoint":"https:\/\/api2.authorize.net\/xml\/v1\/request.api","developerEndpoint":"https:\/\/apitest.authorize.net\/xml\/v1\/request.api"}
|
||||
'],
|
||||
@ -89,7 +99,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' => '{"apiKey":"", "callbackUrl":"", "callbackSecret": ""}'],
|
||||
['id' => 64, 'name' => 'Blockonomics', 'provider' => 'Blockonomics', 'key' => 'wbhf02us6owgo7p4nfjd0ymssdshks4d', 'fields' => "$blockonomics_fields"],
|
||||
];
|
||||
|
||||
foreach ($gateways as $gateway) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user