mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-08 12:12:48 +01:00
Working on Bitcoin with Stripe
This commit is contained in:
parent
9a2581c610
commit
370be9e63c
@ -91,7 +91,7 @@ class StripePaymentDriver extends BasePaymentDriver
|
||||
|
||||
public function shouldUseSource()
|
||||
{
|
||||
return in_array($this->gatewayType, [GATEWAY_TYPE_ALIPAY, GATEWAY_TYPE_SOFORT]);
|
||||
return in_array($this->gatewayType, [GATEWAY_TYPE_ALIPAY, GATEWAY_TYPE_SOFORT, GATEWAY_TYPE_BITCOIN]);
|
||||
}
|
||||
|
||||
protected function checkCustomerExists($customer)
|
||||
@ -358,6 +358,7 @@ class StripePaymentDriver extends BasePaymentDriver
|
||||
$amount = intval($this->invoice()->getRequestedAmount() * 100);
|
||||
$invoiceNumber = $this->invoice()->invoice_number;
|
||||
$currency = $this->client()->getCurrencyCode();
|
||||
$email = $this->contact()->email;
|
||||
$gatewayType = GatewayType::getAliasFromId($this->gatewayType);
|
||||
$redirect = url("/complete_source/{$this->invitation->invitation_key}/{$gatewayType}");
|
||||
$country = $this->client()->country ? $this->client()->country->iso_3166_2 : ($this->account()->country ? $this->account()->country->iso_3166_2 : '');
|
||||
@ -368,6 +369,12 @@ class StripePaymentDriver extends BasePaymentDriver
|
||||
throw new Exception('Alipay is not enabled');
|
||||
}
|
||||
$type = 'alipay';
|
||||
} elseif ($this->gatewayType == GATEWAY_TYPE_BITCOIN) {
|
||||
if (! $this->accountGateway->getBitcoinEnabled()) {
|
||||
throw new Exception('Bitcoin is not enabled');
|
||||
}
|
||||
$type = 'bitcoin';
|
||||
$extra = "&owner[email]={$email}";
|
||||
} else {
|
||||
if (! $this->accountGateway->getSofortEnabled()) {
|
||||
throw new Exception('Sofort is not enabled');
|
||||
@ -383,7 +390,18 @@ class StripePaymentDriver extends BasePaymentDriver
|
||||
$this->invitation->transaction_reference = $response['id'];
|
||||
$this->invitation->save();
|
||||
|
||||
if ($this->gatewayType == GATEWAY_TYPE_BITCOIN) {
|
||||
return view('payments/stripe/bitcoin', [
|
||||
'client' => $this->client(),
|
||||
'account' => $this->account(),
|
||||
'invitation' => $this->invitation,
|
||||
'invoiceNumber' => $invoiceNumber,
|
||||
'amount' => $amount,
|
||||
'source' => $response,
|
||||
]);
|
||||
} else {
|
||||
return redirect($response['redirect']['url']);
|
||||
}
|
||||
} else {
|
||||
throw new Exception($response);
|
||||
}
|
||||
|
@ -38,7 +38,8 @@
|
||||
"card": "^2.1.1",
|
||||
"fullcalendar": "^3.5.1",
|
||||
"toastr": "^2.1.3",
|
||||
"jt.timepicker": "jquery-timepicker-jt#^1.11.12"
|
||||
"jt.timepicker": "jquery-timepicker-jt#^1.11.12",
|
||||
"qrcode.js": "qrcode-js#*"
|
||||
},
|
||||
"resolutions": {
|
||||
"jquery": "~1.11"
|
||||
|
@ -116,6 +116,10 @@ elixir(function(mix) {
|
||||
bowerDir + '/card/dist/card.js',
|
||||
], 'public/js/card.min.js');
|
||||
|
||||
mix.scripts([
|
||||
bowerDir + '/qrcode.js/qrcode.js',
|
||||
], 'public/js/qrcode.min.js');
|
||||
|
||||
mix.scripts([
|
||||
bowerDir + '/tablesorter/dist/js/jquery.tablesorter.combined.js',
|
||||
bowerDir + '/tablesorter/dist/js/widgets/widget-grouping.min.js',
|
||||
|
BIN
public/images/gateways/logo_Bitcoin.png
Normal file
BIN
public/images/gateways/logo_Bitcoin.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.7 KiB |
2
public/js/qrcode.min.js
vendored
Normal file
2
public/js/qrcode.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
public/js/qrcode.min.js.map
Normal file
1
public/js/qrcode.min.js.map
Normal file
File diff suppressed because one or more lines are too long
@ -174,12 +174,12 @@
|
||||
->label('SEPA')
|
||||
->text(trans('texts.enable_sepa'))
|
||||
->value(1) !!}
|
||||
-->
|
||||
|
||||
{!! Former::checkbox('enable_bitcoin')
|
||||
->label(trans('texts.bitcoin'))
|
||||
->text(trans('texts.enable_bitcoin'))
|
||||
->value(1) !!}
|
||||
-->
|
||||
|
||||
{!! Former::checkbox('enable_alipay')
|
||||
->label(trans('texts.alipay'))
|
||||
@ -312,6 +312,8 @@
|
||||
$('#enable_ach').change(updateWebhookShown);
|
||||
$('#enable_alipay').change(updateWebhookShown);
|
||||
$('#enable_sofort').change(updateWebhookShown);
|
||||
$('#enable_sepa').change(updateWebhookShown);
|
||||
$('#enable_bitcoin').change(updateWebhookShown);
|
||||
|
||||
@if (!$accountGateway && count($secondaryGateways))
|
||||
$('#primary_gateway_id').append($('<option>', {
|
||||
|
34
resources/views/payments/stripe/bitcoin.blade.php
Normal file
34
resources/views/payments/stripe/bitcoin.blade.php
Normal file
@ -0,0 +1,34 @@
|
||||
@extends('payments.payment_method')
|
||||
|
||||
@section('head')
|
||||
@parent
|
||||
|
||||
<script type="text/javascript" src="{{ asset('js/qrcode.min.js') }}"></script>
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
var qrcode = new QRCode(document.getElementById("qrcode"), {
|
||||
text: "{{ $source['bitcoin']['uri'] }}",
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
@stop
|
||||
|
||||
|
||||
@section('payment_details')
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<img src="{{ asset('/images/gateways/logo_Bitcoin.png') }}"/>
|
||||
<p> </p>
|
||||
<h2>{{ $source['bitcoin']['amount'] / 100000000 }} BTC</h2>
|
||||
<h3>{{ $source['receiver']['address'] }}</h3>
|
||||
<p> </p>
|
||||
{!! Button::normal(strtoupper(trans('texts.cancel')))->large()->asLinkTo($invitation->getLink()) !!}
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div id="qrcode"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@stop
|
Loading…
Reference in New Issue
Block a user