mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-08 17:24:29 -04:00
Sepa
This commit is contained in:
parent
7092d66ecd
commit
92d91904d2
109
app/PaymentDrivers/Stripe/SEPA.php
Normal file
109
app/PaymentDrivers/Stripe/SEPA.php
Normal file
@ -0,0 +1,109 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com).
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://www.elastic.co/licensing/elastic-license
|
||||
*/
|
||||
|
||||
namespace App\PaymentDrivers\Stripe;
|
||||
|
||||
use App\Exceptions\PaymentFailed;
|
||||
use App\Http\Requests\ClientPortal\Payments\PaymentResponseRequest;
|
||||
use App\Jobs\Mail\PaymentFailureMailer;
|
||||
use App\Jobs\Util\SystemLogger;
|
||||
use App\Models\GatewayType;
|
||||
use App\Models\Payment;
|
||||
use App\Models\PaymentType;
|
||||
use App\Models\SystemLog;
|
||||
use App\PaymentDrivers\StripePaymentDriver;
|
||||
use App\PaymentDrivers\Stripe\CreditCard;
|
||||
use App\Utils\Ninja;
|
||||
|
||||
class SEPA
|
||||
{
|
||||
/** @var StripePaymentDriver */
|
||||
public $stripe_driver;
|
||||
|
||||
public function __construct(StripePaymentDriver $stripe_driver)
|
||||
{
|
||||
$this->stripe_driver = $stripe_driver;
|
||||
}
|
||||
|
||||
public function authorizeView(array $data)
|
||||
{
|
||||
$customer = $this->stripe_driver->findOrCreateCustomer();
|
||||
|
||||
$setup_intent = \Stripe\SetupIntent::create([
|
||||
'payment_method_types' => ['sepa_debit'],
|
||||
'customer' => $customer->id,
|
||||
], $this->stripe_driver->stripe_connect_auth);
|
||||
|
||||
$client_secret = $setup_intent->client_secret
|
||||
// Pass the client secret to the client
|
||||
|
||||
|
||||
$data['gateway'] = $this->stripe;
|
||||
|
||||
return render('gateways.stripe.sepa.authorize', array_merge($data));
|
||||
}
|
||||
|
||||
|
||||
public function paymentResponse(PaymentResponseRequest $request)
|
||||
{
|
||||
|
||||
// $this->stripe_driver->init();
|
||||
|
||||
// $state = [
|
||||
// 'server_response' => json_decode($request->gateway_response),
|
||||
// 'payment_hash' => $request->payment_hash,
|
||||
// ];
|
||||
|
||||
// $state['payment_intent'] = \Stripe\PaymentIntent::retrieve($state['server_response']->id, $this->stripe_driver->stripe_connect_auth);
|
||||
|
||||
// $state['customer'] = $state['payment_intent']->customer;
|
||||
|
||||
// $this->stripe_driver->payment_hash->data = array_merge((array) $this->stripe_driver->payment_hash->data, $state);
|
||||
// $this->stripe_driver->payment_hash->save();
|
||||
|
||||
// $server_response = $this->stripe_driver->payment_hash->data->server_response;
|
||||
|
||||
// $response_handler = new CreditCard($this->stripe_driver);
|
||||
|
||||
// if ($server_response->status == 'succeeded') {
|
||||
|
||||
// $this->stripe_driver->logSuccessfulGatewayResponse(['response' => json_decode($request->gateway_response), 'data' => $this->stripe_driver->payment_hash], SystemLog::TYPE_STRIPE);
|
||||
|
||||
// return $response_handler->processSuccessfulPayment();
|
||||
// }
|
||||
|
||||
// return $response_handler->processUnsuccessfulPayment($server_response);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/* Searches for a stripe customer by email
|
||||
otherwise searches by gateway tokens in StripePaymentdriver
|
||||
finally creates a new customer if none found
|
||||
*/
|
||||
private function getCustomer()
|
||||
{
|
||||
$searchResults = \Stripe\Customer::all([
|
||||
"email" => $this->stripe_driver->client->present()->email(),
|
||||
"limit" => 1,
|
||||
"starting_after" => null
|
||||
], $this->stripe_driver->stripe_connect_auth);
|
||||
|
||||
|
||||
if(count($searchResults) >= 1)
|
||||
return $searchResults[0];
|
||||
|
||||
return $this->stripe_driver->findOrCreateCustomer();
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -44,6 +44,7 @@
|
||||
"fakerphp/faker": "^1.14",
|
||||
"fideloper/proxy": "^4.2",
|
||||
"fruitcake/laravel-cors": "^2.0",
|
||||
"gocardless/gocardless-pro": "^4.12",
|
||||
"google/apiclient": "^2.7",
|
||||
"guzzlehttp/guzzle": "^7.0.1",
|
||||
"hashids/hashids": "^4.0",
|
||||
|
59
composer.lock
generated
59
composer.lock
generated
@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "275a9dd3910b6ec79607b098406dc6c7",
|
||||
"content-hash": "bcd9405b1978cef268d732794883e91d",
|
||||
"packages": [
|
||||
{
|
||||
"name": "asm/php-ansible",
|
||||
@ -2221,6 +2221,61 @@
|
||||
],
|
||||
"time": "2021-04-26T11:24:25+00:00"
|
||||
},
|
||||
{
|
||||
"name": "gocardless/gocardless-pro",
|
||||
"version": "4.12.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/gocardless/gocardless-pro-php.git",
|
||||
"reference": "e63b97b215c27179023dd2e911133ee75e543fbd"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/gocardless/gocardless-pro-php/zipball/e63b97b215c27179023dd2e911133ee75e543fbd",
|
||||
"reference": "e63b97b215c27179023dd2e911133ee75e543fbd",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-curl": "*",
|
||||
"ext-json": "*",
|
||||
"ext-mbstring": "*",
|
||||
"guzzlehttp/guzzle": "^6.0 | ^7.0",
|
||||
"php": ">=5.6"
|
||||
},
|
||||
"require-dev": {
|
||||
"php-coveralls/php-coveralls": "^2.2",
|
||||
"phpunit/phpunit": "^7.5",
|
||||
"squizlabs/php_codesniffer": "^3.5"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"GoCardlessPro\\": "lib/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "GoCardless and contributors",
|
||||
"homepage": "https://github.com/gocardless/gocardless-pro-php/contributors"
|
||||
}
|
||||
],
|
||||
"description": "GoCardless Pro PHP Client Library",
|
||||
"homepage": "https://gocardless.com/",
|
||||
"keywords": [
|
||||
"api",
|
||||
"direct debit",
|
||||
"gocardless"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/gocardless/gocardless-pro-php/issues",
|
||||
"source": "https://github.com/gocardless/gocardless-pro-php/tree/v4.12.0"
|
||||
},
|
||||
"time": "2021-08-12T15:41:16+00:00"
|
||||
},
|
||||
{
|
||||
"name": "google/apiclient",
|
||||
"version": "v2.10.1",
|
||||
@ -14972,5 +15027,5 @@
|
||||
"platform-dev": {
|
||||
"php": "^7.3|^7.4|^8.0"
|
||||
},
|
||||
"plugin-api-version": "2.1.0"
|
||||
"plugin-api-version": "2.0.0"
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user