mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-09 20:52:56 +01:00
Added support for partial payments
This commit is contained in:
parent
96a71864ed
commit
168bb7cfb0
@ -246,8 +246,7 @@ class PaymentController extends BaseController
|
|||||||
private function getPaymentDetails($invitation, $input = null)
|
private function getPaymentDetails($invitation, $input = null)
|
||||||
{
|
{
|
||||||
$invoice = $invitation->invoice;
|
$invoice = $invitation->invoice;
|
||||||
$key = $invoice->invoice_number.'_details';
|
$key = $invoice->account_id.'-'.$invoice->invoice_number;
|
||||||
$gateway = $invoice->client->account->getGatewayByType(Session::get('payment_type'))->gateway;
|
|
||||||
$currencyCode = $invoice->client->currency ? $invoice->client->currency->code : ($invoice->account->currency ? $invoice->account->currency->code : 'USD');
|
$currencyCode = $invoice->client->currency ? $invoice->client->currency->code : ($invoice->account->currency ? $invoice->account->currency->code : 'USD');
|
||||||
|
|
||||||
if ($input) {
|
if ($input) {
|
||||||
@ -568,6 +567,7 @@ class PaymentController extends BaseController
|
|||||||
$invitation->transaction_reference = $ref;
|
$invitation->transaction_reference = $ref;
|
||||||
$invitation->save();
|
$invitation->save();
|
||||||
|
|
||||||
|
Session::put('transaction_reference', $ref);
|
||||||
Session::save();
|
Session::save();
|
||||||
$response->redirect();
|
$response->redirect();
|
||||||
} else {
|
} else {
|
||||||
@ -630,6 +630,14 @@ class PaymentController extends BaseController
|
|||||||
$payerId = Request::query('PayerID');
|
$payerId = Request::query('PayerID');
|
||||||
$token = Request::query('token');
|
$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();
|
$invitation = Invitation::with('invoice.client.currency', 'invoice.client.account.account_gateways.gateway')->where('transaction_reference', '=', $token)->firstOrFail();
|
||||||
$invoice = $invitation->invoice;
|
$invoice = $invitation->invoice;
|
||||||
|
|
||||||
@ -637,20 +645,26 @@ class PaymentController extends BaseController
|
|||||||
$gateway = self::createGateway($accountGateway);
|
$gateway = self::createGateway($accountGateway);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$details = self::getPaymentDetails($invitation);
|
if (method_exists($gateway, 'completePurchase')) {
|
||||||
$response = $gateway->completePurchase($details)->send();
|
$details = self::getPaymentDetails($invitation);
|
||||||
$ref = $response->getTransactionReference();
|
$response = $gateway->completePurchase($details)->send();
|
||||||
|
$ref = $response->getTransactionReference();
|
||||||
|
|
||||||
if ($response->isSuccessful()) {
|
if ($response->isSuccessful()) {
|
||||||
$payment = self::createPayment($invitation, $ref, $payerId);
|
$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 {
|
} else {
|
||||||
$errorMessage = trans('texts.payment_error')."\n\n".$response->getMessage();
|
$payment = self::createPayment($invitation, $token, $payerId);
|
||||||
Session::flash('error', $errorMessage);
|
Session::flash('message', trans('texts.applied_payment'));
|
||||||
Utils::logError($errorMessage);
|
|
||||||
|
|
||||||
return Redirect::to('view/'.$invitation->invitation_key);
|
return Redirect::to('view/'.$invitation->invitation_key);
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,8 @@ class Gateway extends Eloquent
|
|||||||
$link = 'https://www.paypal.com/us/cgi-bin/webscr?cmd=_login-api-run';
|
$link = 'https://www.paypal.com/us/cgi-bin/webscr?cmd=_login-api-run';
|
||||||
} elseif ($this->id == GATEWAY_TWO_CHECKOUT) {
|
} elseif ($this->id == GATEWAY_TWO_CHECKOUT) {
|
||||||
$link = 'https://www.2checkout.com/referral?r=2c37ac2298';
|
$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;
|
$key = 'texts.gateway_help_'.$this->id;
|
||||||
|
@ -46,8 +46,8 @@ Developed by [@hillelcoren](https://twitter.com/hillelcoren) | Designed by [kant
|
|||||||
### Steps to setup from GitHub
|
### 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.
|
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
|
cd ninja
|
||||||
|
|
||||||
Install Laravel packages using Composer
|
Install Laravel packages using Composer
|
||||||
|
@ -587,7 +587,7 @@ return array(
|
|||||||
'resend_confirmation' => 'Resend confirmation email',
|
'resend_confirmation' => 'Resend confirmation email',
|
||||||
'confirmation_resent' => 'The confirmation email was resent',
|
'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.<br/>Note: use a Legacy API Key, not an API token.',
|
||||||
'payment_type_credit_card' => 'Credit card',
|
'payment_type_credit_card' => 'Credit card',
|
||||||
'payment_type_paypal' => 'PayPal',
|
'payment_type_paypal' => 'PayPal',
|
||||||
'payment_type_bitcoin' => 'Bitcoin',
|
'payment_type_bitcoin' => 'Bitcoin',
|
||||||
|
@ -578,7 +578,7 @@ return array(
|
|||||||
'resend_confirmation' => 'Bestätigungsmail erneut senden',
|
'resend_confirmation' => 'Bestätigungsmail erneut senden',
|
||||||
'confirmation_resent' => 'Bestätigungsemail wurde erneut gesendet',
|
'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.<br/>Note: use a Legacy API Key, not an API token.',
|
||||||
'payment_type_credit_card' => 'Credit card',
|
'payment_type_credit_card' => 'Credit card',
|
||||||
'payment_type_paypal' => 'PayPal',
|
'payment_type_paypal' => 'PayPal',
|
||||||
'payment_type_bitcoin' => 'Bitcoin',
|
'payment_type_bitcoin' => 'Bitcoin',
|
||||||
|
@ -585,7 +585,7 @@ return array(
|
|||||||
'resend_confirmation' => 'Resend confirmation email',
|
'resend_confirmation' => 'Resend confirmation email',
|
||||||
'confirmation_resent' => 'The confirmation email was resent',
|
'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.<br/>Note: use a Legacy API Key, not an API token.',
|
||||||
'payment_type_credit_card' => 'Credit card',
|
'payment_type_credit_card' => 'Credit card',
|
||||||
'payment_type_paypal' => 'PayPal',
|
'payment_type_paypal' => 'PayPal',
|
||||||
'payment_type_bitcoin' => 'Bitcoin',
|
'payment_type_bitcoin' => 'Bitcoin',
|
||||||
|
@ -557,7 +557,7 @@ return array(
|
|||||||
'resend_confirmation' => 'Resend confirmation email',
|
'resend_confirmation' => 'Resend confirmation email',
|
||||||
'confirmation_resent' => 'The confirmation email was resent',
|
'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.<br/>Note: use a Legacy API Key, not an API token.',
|
||||||
'payment_type_credit_card' => 'Credit card',
|
'payment_type_credit_card' => 'Credit card',
|
||||||
'payment_type_paypal' => 'PayPal',
|
'payment_type_paypal' => 'PayPal',
|
||||||
'payment_type_bitcoin' => 'Bitcoin',
|
'payment_type_bitcoin' => 'Bitcoin',
|
||||||
|
@ -586,7 +586,7 @@ return array(
|
|||||||
'resend_confirmation' => 'Resend confirmation email',
|
'resend_confirmation' => 'Resend confirmation email',
|
||||||
'confirmation_resent' => 'The confirmation email was resent',
|
'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.<br/>Note: use a Legacy API Key, not an API token.',
|
||||||
'payment_type_credit_card' => 'Credit card',
|
'payment_type_credit_card' => 'Credit card',
|
||||||
'payment_type_paypal' => 'PayPal',
|
'payment_type_paypal' => 'PayPal',
|
||||||
'payment_type_bitcoin' => 'Bitcoin',
|
'payment_type_bitcoin' => 'Bitcoin',
|
||||||
|
@ -578,7 +578,7 @@ return array(
|
|||||||
'resend_confirmation' => 'Resend confirmation email',
|
'resend_confirmation' => 'Resend confirmation email',
|
||||||
'confirmation_resent' => 'The confirmation email was resent',
|
'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.<br/>Note: use a Legacy API Key, not an API token.',
|
||||||
'payment_type_credit_card' => 'Credit card',
|
'payment_type_credit_card' => 'Credit card',
|
||||||
'payment_type_paypal' => 'PayPal',
|
'payment_type_paypal' => 'PayPal',
|
||||||
'payment_type_bitcoin' => 'Bitcoin',
|
'payment_type_bitcoin' => 'Bitcoin',
|
||||||
|
@ -580,7 +580,7 @@ return array(
|
|||||||
'resend_confirmation' => 'Resend confirmation email',
|
'resend_confirmation' => 'Resend confirmation email',
|
||||||
'confirmation_resent' => 'The confirmation email was resent',
|
'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.<br/>Note: use a Legacy API Key, not an API token.',
|
||||||
'payment_type_credit_card' => 'Credit card',
|
'payment_type_credit_card' => 'Credit card',
|
||||||
'payment_type_paypal' => 'PayPal',
|
'payment_type_paypal' => 'PayPal',
|
||||||
'payment_type_bitcoin' => 'Bitcoin',
|
'payment_type_bitcoin' => 'Bitcoin',
|
||||||
|
@ -588,7 +588,7 @@ return array(
|
|||||||
'resend_confirmation' => 'Resend confirmation email',
|
'resend_confirmation' => 'Resend confirmation email',
|
||||||
'confirmation_resent' => 'The confirmation email was resent',
|
'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.<br/>Note: use a Legacy API Key, not an API token.',
|
||||||
'payment_type_credit_card' => 'Credit card',
|
'payment_type_credit_card' => 'Credit card',
|
||||||
'payment_type_paypal' => 'PayPal',
|
'payment_type_paypal' => 'PayPal',
|
||||||
'payment_type_bitcoin' => 'Bitcoin',
|
'payment_type_bitcoin' => 'Bitcoin',
|
||||||
|
@ -586,7 +586,7 @@ return array(
|
|||||||
'resend_confirmation' => 'Resend confirmation email',
|
'resend_confirmation' => 'Resend confirmation email',
|
||||||
'confirmation_resent' => 'The confirmation email was resent',
|
'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.<br/>Note: use a Legacy API Key, not an API token.',
|
||||||
'payment_type_credit_card' => 'Credit card',
|
'payment_type_credit_card' => 'Credit card',
|
||||||
'payment_type_paypal' => 'PayPal',
|
'payment_type_paypal' => 'PayPal',
|
||||||
'payment_type_bitcoin' => 'Bitcoin',
|
'payment_type_bitcoin' => 'Bitcoin',
|
||||||
|
@ -581,7 +581,7 @@ return array(
|
|||||||
'resend_confirmation' => 'Resend confirmation email',
|
'resend_confirmation' => 'Resend confirmation email',
|
||||||
'confirmation_resent' => 'The confirmation email was resent',
|
'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.<br/>Note: use a Legacy API Key, not an API token.',
|
||||||
'payment_type_credit_card' => 'Credit card',
|
'payment_type_credit_card' => 'Credit card',
|
||||||
'payment_type_paypal' => 'PayPal',
|
'payment_type_paypal' => 'PayPal',
|
||||||
'payment_type_bitcoin' => 'Bitcoin',
|
'payment_type_bitcoin' => 'Bitcoin',
|
||||||
|
@ -581,7 +581,7 @@ return array(
|
|||||||
'resend_confirmation' => 'Resend confirmation email',
|
'resend_confirmation' => 'Resend confirmation email',
|
||||||
'confirmation_resent' => 'The confirmation email was resent',
|
'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.<br/>Note: use a Legacy API Key, not an API token.',
|
||||||
'payment_type_credit_card' => 'Credit card',
|
'payment_type_credit_card' => 'Credit card',
|
||||||
'payment_type_paypal' => 'PayPal',
|
'payment_type_paypal' => 'PayPal',
|
||||||
'payment_type_bitcoin' => 'Bitcoin',
|
'payment_type_bitcoin' => 'Bitcoin',
|
||||||
|
@ -584,7 +584,7 @@ return array(
|
|||||||
'resend_confirmation' => 'Resend confirmation email',
|
'resend_confirmation' => 'Resend confirmation email',
|
||||||
'confirmation_resent' => 'The confirmation email was resent',
|
'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.<br/>Note: use a Legacy API Key, not an API token.',
|
||||||
'payment_type_credit_card' => 'Credit card',
|
'payment_type_credit_card' => 'Credit card',
|
||||||
'payment_type_paypal' => 'PayPal',
|
'payment_type_paypal' => 'PayPal',
|
||||||
'payment_type_bitcoin' => 'Bitcoin',
|
'payment_type_bitcoin' => 'Bitcoin',
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
@endforeach
|
@endforeach
|
||||||
@endif
|
@endif
|
||||||
@else
|
@else
|
||||||
{!! Former::populateField('gateway_id', GATEWAY_AUTHORIZE_NET) !!}
|
{!! Former::populateField('gateway_id', GATEWAY_STRIPE) !!}
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
{!! Former::select('payment_type_id')
|
{!! Former::select('payment_type_id')
|
||||||
|
@ -1655,7 +1655,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
@if ($data)
|
@if ($data)
|
||||||
window.model = new ViewModel({{ $data }});
|
window.model = new ViewModel({!! $data !!});
|
||||||
@else
|
@else
|
||||||
window.model = new ViewModel();
|
window.model = new ViewModel();
|
||||||
model.addTaxRate();
|
model.addTaxRate();
|
||||||
|
Loading…
Reference in New Issue
Block a user