diff --git a/app/Http/Controllers/PaymentController.php b/app/Http/Controllers/PaymentController.php
index 6bc4b700896c..cfa492463bf6 100644
--- a/app/Http/Controllers/PaymentController.php
+++ b/app/Http/Controllers/PaymentController.php
@@ -246,8 +246,7 @@ class PaymentController extends BaseController
private function getPaymentDetails($invitation, $input = null)
{
$invoice = $invitation->invoice;
- $key = $invoice->invoice_number.'_details';
- $gateway = $invoice->client->account->getGatewayByType(Session::get('payment_type'))->gateway;
+ $key = $invoice->account_id.'-'.$invoice->invoice_number;
$currencyCode = $invoice->client->currency ? $invoice->client->currency->code : ($invoice->account->currency ? $invoice->account->currency->code : 'USD');
if ($input) {
@@ -568,6 +567,7 @@ class PaymentController extends BaseController
$invitation->transaction_reference = $ref;
$invitation->save();
+ Session::put('transaction_reference', $ref);
Session::save();
$response->redirect();
} else {
@@ -630,6 +630,14 @@ class PaymentController extends BaseController
$payerId = Request::query('PayerID');
$token = Request::query('token');
+ if (!$token) {
+ $token = Session::pull('transaction_reference');
+ }
+
+ if (!$token) {
+ return redirect(NINJA_WEB_URL);
+ }
+
$invitation = Invitation::with('invoice.client.currency', 'invoice.client.account.account_gateways.gateway')->where('transaction_reference', '=', $token)->firstOrFail();
$invoice = $invitation->invoice;
@@ -637,20 +645,26 @@ class PaymentController extends BaseController
$gateway = self::createGateway($accountGateway);
try {
- $details = self::getPaymentDetails($invitation);
- $response = $gateway->completePurchase($details)->send();
- $ref = $response->getTransactionReference();
+ if (method_exists($gateway, 'completePurchase')) {
+ $details = self::getPaymentDetails($invitation);
+ $response = $gateway->completePurchase($details)->send();
+ $ref = $response->getTransactionReference();
- if ($response->isSuccessful()) {
- $payment = self::createPayment($invitation, $ref, $payerId);
+ if ($response->isSuccessful()) {
+ $payment = self::createPayment($invitation, $ref, $payerId);
+ Session::flash('message', trans('texts.applied_payment'));
- Session::flash('message', trans('texts.applied_payment'));
+ return Redirect::to('view/'.$invitation->invitation_key);
+ } else {
+ $errorMessage = trans('texts.payment_error')."\n\n".$response->getMessage();
+ Session::flash('error', $errorMessage);
+ Utils::logError($errorMessage);
- return Redirect::to('view/'.$invitation->invitation_key);
+ return Redirect::to('view/'.$invitation->invitation_key);
+ }
} else {
- $errorMessage = trans('texts.payment_error')."\n\n".$response->getMessage();
- Session::flash('error', $errorMessage);
- Utils::logError($errorMessage);
+ $payment = self::createPayment($invitation, $token, $payerId);
+ Session::flash('message', trans('texts.applied_payment'));
return Redirect::to('view/'.$invitation->invitation_key);
}
diff --git a/app/Models/Gateway.php b/app/Models/Gateway.php
index d0b4bd847972..5af3974f6249 100644
--- a/app/Models/Gateway.php
+++ b/app/Models/Gateway.php
@@ -22,6 +22,8 @@ class Gateway extends Eloquent
$link = 'https://www.paypal.com/us/cgi-bin/webscr?cmd=_login-api-run';
} elseif ($this->id == GATEWAY_TWO_CHECKOUT) {
$link = 'https://www.2checkout.com/referral?r=2c37ac2298';
+ } elseif ($this->id == GATEWAY_BITPAY) {
+ $link = 'https://bitpay.com/dashboard/signup';
}
$key = 'texts.gateway_help_'.$this->id;
diff --git a/readme.md b/readme.md
index 37236a85d6c3..c74e58eb5456 100644
--- a/readme.md
+++ b/readme.md
@@ -46,8 +46,8 @@ Developed by [@hillelcoren](https://twitter.com/hillelcoren) | Designed by [kant
### Steps to setup from GitHub
If you plan on submitting changes it's best to [fork the repo](https://help.github.com/articles/fork-a-repo), otherwise you can just checkout the code.
-
- git clone https://github.com/hillelcoren/invoice-ninja.git ninja
+
+ git clone git@github.com:hillelcoren/invoice-ninja.git ninja
cd ninja
Install Laravel packages using Composer
diff --git a/resources/lang/da/texts.php b/resources/lang/da/texts.php
index 59c05e563509..3eef8bc21c49 100644
--- a/resources/lang/da/texts.php
+++ b/resources/lang/da/texts.php
@@ -587,7 +587,7 @@ return array(
'resend_confirmation' => 'Resend confirmation email',
'confirmation_resent' => 'The confirmation email was resent',
- 'gateway_help_42' => 'Note: use a BitPay Legacy API Key, not an API token.',
+ 'gateway_help_42' => ':link to sign up for BitPay.
Note: use a Legacy API Key, not an API token.',
'payment_type_credit_card' => 'Credit card',
'payment_type_paypal' => 'PayPal',
'payment_type_bitcoin' => 'Bitcoin',
diff --git a/resources/lang/de/texts.php b/resources/lang/de/texts.php
index 646ebf4af9e9..38bc210a3731 100644
--- a/resources/lang/de/texts.php
+++ b/resources/lang/de/texts.php
@@ -578,7 +578,7 @@ return array(
'resend_confirmation' => 'Bestätigungsmail erneut senden',
'confirmation_resent' => 'Bestätigungsemail wurde erneut gesendet',
- 'gateway_help_42' => 'Note: use a BitPay Legacy API Key, not an API token.',
+ 'gateway_help_42' => ':link to sign up for BitPay.
Note: use a Legacy API Key, not an API token.',
'payment_type_credit_card' => 'Credit card',
'payment_type_paypal' => 'PayPal',
'payment_type_bitcoin' => 'Bitcoin',
diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php
index 3ab0a35d27ee..2417bc5fef88 100644
--- a/resources/lang/en/texts.php
+++ b/resources/lang/en/texts.php
@@ -585,7 +585,7 @@ return array(
'resend_confirmation' => 'Resend confirmation email',
'confirmation_resent' => 'The confirmation email was resent',
- 'gateway_help_42' => 'Note: use a BitPay Legacy API Key, not an API token.',
+ 'gateway_help_42' => ':link to sign up for BitPay.
Note: use a Legacy API Key, not an API token.',
'payment_type_credit_card' => 'Credit card',
'payment_type_paypal' => 'PayPal',
'payment_type_bitcoin' => 'Bitcoin',
diff --git a/resources/lang/es/texts.php b/resources/lang/es/texts.php
index e00057bcbb98..1008331520bf 100644
--- a/resources/lang/es/texts.php
+++ b/resources/lang/es/texts.php
@@ -557,7 +557,7 @@ return array(
'resend_confirmation' => 'Resend confirmation email',
'confirmation_resent' => 'The confirmation email was resent',
- 'gateway_help_42' => 'Note: use a BitPay Legacy API Key, not an API token.',
+ 'gateway_help_42' => ':link to sign up for BitPay.
Note: use a Legacy API Key, not an API token.',
'payment_type_credit_card' => 'Credit card',
'payment_type_paypal' => 'PayPal',
'payment_type_bitcoin' => 'Bitcoin',
diff --git a/resources/lang/es_ES/texts.php b/resources/lang/es_ES/texts.php
index 0fbf4030239e..1ffb5addd929 100644
--- a/resources/lang/es_ES/texts.php
+++ b/resources/lang/es_ES/texts.php
@@ -586,7 +586,7 @@ return array(
'resend_confirmation' => 'Resend confirmation email',
'confirmation_resent' => 'The confirmation email was resent',
- 'gateway_help_42' => 'Note: use a BitPay Legacy API Key, not an API token.',
+ 'gateway_help_42' => ':link to sign up for BitPay.
Note: use a Legacy API Key, not an API token.',
'payment_type_credit_card' => 'Credit card',
'payment_type_paypal' => 'PayPal',
'payment_type_bitcoin' => 'Bitcoin',
diff --git a/resources/lang/fr/texts.php b/resources/lang/fr/texts.php
index 13c9ccb88234..c7eb81adaa6c 100644
--- a/resources/lang/fr/texts.php
+++ b/resources/lang/fr/texts.php
@@ -578,7 +578,7 @@ return array(
'resend_confirmation' => 'Resend confirmation email',
'confirmation_resent' => 'The confirmation email was resent',
- 'gateway_help_42' => 'Note: use a BitPay Legacy API Key, not an API token.',
+ 'gateway_help_42' => ':link to sign up for BitPay.
Note: use a Legacy API Key, not an API token.',
'payment_type_credit_card' => 'Credit card',
'payment_type_paypal' => 'PayPal',
'payment_type_bitcoin' => 'Bitcoin',
diff --git a/resources/lang/it/texts.php b/resources/lang/it/texts.php
index ad40d5014e68..a750f07f2aec 100644
--- a/resources/lang/it/texts.php
+++ b/resources/lang/it/texts.php
@@ -580,7 +580,7 @@ return array(
'resend_confirmation' => 'Resend confirmation email',
'confirmation_resent' => 'The confirmation email was resent',
- 'gateway_help_42' => 'Note: use a BitPay Legacy API Key, not an API token.',
+ 'gateway_help_42' => ':link to sign up for BitPay.
Note: use a Legacy API Key, not an API token.',
'payment_type_credit_card' => 'Credit card',
'payment_type_paypal' => 'PayPal',
'payment_type_bitcoin' => 'Bitcoin',
diff --git a/resources/lang/lt/texts.php b/resources/lang/lt/texts.php
index 3bca31dd23ea..5c4915bb41af 100644
--- a/resources/lang/lt/texts.php
+++ b/resources/lang/lt/texts.php
@@ -588,7 +588,7 @@ return array(
'resend_confirmation' => 'Resend confirmation email',
'confirmation_resent' => 'The confirmation email was resent',
- 'gateway_help_42' => 'Note: use a BitPay Legacy API Key, not an API token.',
+ 'gateway_help_42' => ':link to sign up for BitPay.
Note: use a Legacy API Key, not an API token.',
'payment_type_credit_card' => 'Credit card',
'payment_type_paypal' => 'PayPal',
'payment_type_bitcoin' => 'Bitcoin',
diff --git a/resources/lang/nb_NO/texts.php b/resources/lang/nb_NO/texts.php
index 20cbada5e501..724200d007fc 100644
--- a/resources/lang/nb_NO/texts.php
+++ b/resources/lang/nb_NO/texts.php
@@ -586,7 +586,7 @@ return array(
'resend_confirmation' => 'Resend confirmation email',
'confirmation_resent' => 'The confirmation email was resent',
- 'gateway_help_42' => 'Note: use a BitPay Legacy API Key, not an API token.',
+ 'gateway_help_42' => ':link to sign up for BitPay.
Note: use a Legacy API Key, not an API token.',
'payment_type_credit_card' => 'Credit card',
'payment_type_paypal' => 'PayPal',
'payment_type_bitcoin' => 'Bitcoin',
diff --git a/resources/lang/nl/texts.php b/resources/lang/nl/texts.php
index 0c9d11a851b2..be8838eb3928 100644
--- a/resources/lang/nl/texts.php
+++ b/resources/lang/nl/texts.php
@@ -581,7 +581,7 @@ return array(
'resend_confirmation' => 'Resend confirmation email',
'confirmation_resent' => 'The confirmation email was resent',
- 'gateway_help_42' => 'Note: use a BitPay Legacy API Key, not an API token.',
+ 'gateway_help_42' => ':link to sign up for BitPay.
Note: use a Legacy API Key, not an API token.',
'payment_type_credit_card' => 'Credit card',
'payment_type_paypal' => 'PayPal',
'payment_type_bitcoin' => 'Bitcoin',
diff --git a/resources/lang/pt_BR/texts.php b/resources/lang/pt_BR/texts.php
index ab1709120fb9..4827bf0a9977 100644
--- a/resources/lang/pt_BR/texts.php
+++ b/resources/lang/pt_BR/texts.php
@@ -581,7 +581,7 @@ return array(
'resend_confirmation' => 'Resend confirmation email',
'confirmation_resent' => 'The confirmation email was resent',
- 'gateway_help_42' => 'Note: use a BitPay Legacy API Key, not an API token.',
+ 'gateway_help_42' => ':link to sign up for BitPay.
Note: use a Legacy API Key, not an API token.',
'payment_type_credit_card' => 'Credit card',
'payment_type_paypal' => 'PayPal',
'payment_type_bitcoin' => 'Bitcoin',
diff --git a/resources/lang/sv/texts.php b/resources/lang/sv/texts.php
index 936fc232bfb9..3e9edf79d084 100644
--- a/resources/lang/sv/texts.php
+++ b/resources/lang/sv/texts.php
@@ -584,7 +584,7 @@ return array(
'resend_confirmation' => 'Resend confirmation email',
'confirmation_resent' => 'The confirmation email was resent',
- 'gateway_help_42' => 'Note: use a BitPay Legacy API Key, not an API token.',
+ 'gateway_help_42' => ':link to sign up for BitPay.
Note: use a Legacy API Key, not an API token.',
'payment_type_credit_card' => 'Credit card',
'payment_type_paypal' => 'PayPal',
'payment_type_bitcoin' => 'Bitcoin',
diff --git a/resources/views/accounts/account_gateway.blade.php b/resources/views/accounts/account_gateway.blade.php
index 92f55fac213f..6158cc5e436a 100644
--- a/resources/views/accounts/account_gateway.blade.php
+++ b/resources/views/accounts/account_gateway.blade.php
@@ -22,7 +22,7 @@
@endforeach
@endif
@else
- {!! Former::populateField('gateway_id', GATEWAY_AUTHORIZE_NET) !!}
+ {!! Former::populateField('gateway_id', GATEWAY_STRIPE) !!}
@endif
{!! Former::select('payment_type_id')
diff --git a/resources/views/invoices/edit.blade.php b/resources/views/invoices/edit.blade.php
index 6e68b18e9b69..2f700e9b10d9 100644
--- a/resources/views/invoices/edit.blade.php
+++ b/resources/views/invoices/edit.blade.php
@@ -1655,7 +1655,7 @@
}
@if ($data)
- window.model = new ViewModel({{ $data }});
+ window.model = new ViewModel({!! $data !!});
@else
window.model = new ViewModel();
model.addTaxRate();