1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00

BaseDriver:

- Allow passing additional properties to ClientGatewayToken entity
CreditCard:
- Fix saving gateway_customer_reference
This commit is contained in:
Benjamin Beganović 2020-10-28 16:48:24 +01:00
parent dab59138cc
commit 13655d48ea
2 changed files with 9 additions and 4 deletions

View File

@ -270,7 +270,7 @@ class BaseDriver extends AbstractPaymentDriver
* @param array $data
* @return null|\App\Models\ClientGatewayToken
*/
public function storeGatewayToken(array $data): ?ClientGatewayToken
public function storeGatewayToken(array $data, array $additional = []): ?ClientGatewayToken
{
$company_gateway_token = new ClientGatewayToken();
$company_gateway_token->company_id = $this->client->company->id;
@ -279,6 +279,11 @@ class BaseDriver extends AbstractPaymentDriver
$company_gateway_token->company_gateway_id = $this->company_gateway->id;
$company_gateway_token->gateway_type_id = $data['payment_method_id'];
$company_gateway_token->meta = $data['payment_meta'];
foreach ($additional as $key => $value) {
$company_gateway_token->{$key} = $value;
}
$company_gateway_token->save();
if ($this->client->gateway_tokens->count() == 1) {

View File

@ -54,7 +54,7 @@ class CreditCard
$stripe_method = $this->stripe->getStripePaymentMethod($stripe_response->payment_method);
$this->storePaymentMethod($stripe_method, $request->payment_method_id);
$this->storePaymentMethod($stripe_method, $request->payment_method_id, $customer);
return redirect()->route('client.payment_methods.index');
}
@ -205,7 +205,7 @@ class CreditCard
throw new \Exception('Failed to process the payment.', 1);
}
private function storePaymentMethod(\Stripe\PaymentMethod $method, $payment_method_id)
private function storePaymentMethod(\Stripe\PaymentMethod $method, $payment_method_id, $customer)
{
try {
$payment_meta = new \stdClass;
@ -221,7 +221,7 @@ class CreditCard
'payment_method_id' => $payment_method_id,
];
$this->stripe->storeGatewayToken($data);
$this->stripe->storeGatewayToken($data, ['gateway_customer_reference' => $customer->id]);
} catch (\Exception $e) {
return $this->stripe->processInternallyFailedPayment($this->stripe, $e);
}