1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-20 00:11:35 +02:00

Support saving credit card and paypal tokens for the same client

This commit is contained in:
Hillel Coren 2016-08-02 13:40:20 +03:00
parent 60ce0716a9
commit 293e7cbb61
2 changed files with 11 additions and 10 deletions

View File

@ -507,15 +507,6 @@ class BasePaymentDriver
$customer->save();
}
// archive the old payment method
$paymentMethod = PaymentMethod::clientId($this->client()->id)
->isBankAccount($this->isGatewayType(GATEWAY_TYPE_BANK_TRANSFER))
->first();
if ($paymentMethod) {
$paymentMethod->delete();
}
$paymentMethod = $this->createPaymentMethod($customer);
if ($paymentMethod) {
@ -540,6 +531,15 @@ class BasePaymentDriver
$paymentMethod->setRelation('account_gateway_token', $customer);
$paymentMethod = $this->creatingPaymentMethod($paymentMethod);
// archive the old payment method
$oldPaymentMethod = PaymentMethod::clientId($this->client()->id)
->wherePaymentTypeId($paymentMethod->payment_type_id)
->first();
if ($oldPaymentMethod) {
$oldPaymentMethod->delete();
}
if ($paymentMethod) {
$paymentMethod->save();
}
@ -758,7 +758,7 @@ class BasePaymentDriver
} elseif ($paymentMethod->payment_type_id == PAYMENT_TYPE_PAYPAL) {
$label = 'PayPal: ' . $paymentMethod->email;
} else {
$label = trans('texts.use_card_on_file');
$label = trans('texts.payment_type_on_file', ['type' => $paymentMethod->payment_type->name]);
}
$links[] = [

View File

@ -2050,6 +2050,7 @@ $LANG = array(
'no_client_selected' => 'Please select a client',
'gateway_config_error' => 'It may help to set new passwords or generate new API keys.',
'payment_type_on_file' => ':type on file',
);