mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Minor fixes for Stripe ACH Verifications
This commit is contained in:
parent
d75bd765aa
commit
6d7ddc3beb
@ -109,6 +109,7 @@ class StorePaymentRequest extends Request
|
|||||||
'credits.*.amount' => ['bail','required', new CreditsSumRule($this->all())],
|
'credits.*.amount' => ['bail','required', new CreditsSumRule($this->all())],
|
||||||
'invoices' => new ValidPayableInvoicesRule(),
|
'invoices' => new ValidPayableInvoicesRule(),
|
||||||
'number' => ['nullable', 'bail', Rule::unique('payments')->where('company_id', auth()->user()->company()->id)],
|
'number' => ['nullable', 'bail', Rule::unique('payments')->where('company_id', auth()->user()->company()->id)],
|
||||||
|
'idempotency_key' => ['nullable', 'bail', 'string','max:64', Rule::unique('payments')->where('company_id', auth()->user()->company()->id)],
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -125,6 +125,20 @@ class ACH
|
|||||||
|
|
||||||
$bank_account = Customer::retrieveSource($request->customer, $request->source, [], $this->stripe->stripe_connect_auth);
|
$bank_account = Customer::retrieveSource($request->customer, $request->source, [], $this->stripe->stripe_connect_auth);
|
||||||
|
|
||||||
|
/* Catch externally validated bank accounts and mark them as verified */
|
||||||
|
if(property_exists($bank_account, 'status') && $bank_account->status == 'verified'){
|
||||||
|
|
||||||
|
$meta = $token->meta;
|
||||||
|
$meta->state = 'authorized';
|
||||||
|
$token->meta = $meta;
|
||||||
|
$token->save();
|
||||||
|
|
||||||
|
return redirect()
|
||||||
|
->route('client.payment_methods.show', $token->hashed_id)
|
||||||
|
->with('message', __('texts.payment_method_verified'));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$bank_account->verify(['amounts' => request()->transactions]);
|
$bank_account->verify(['amounts' => request()->transactions]);
|
||||||
|
|
||||||
|
@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('payments', function (Blueprint $table) {
|
||||||
|
$table->string('idempotency_key', 64)->nullable()->index();
|
||||||
|
|
||||||
|
$table->unique(['company_id', 'idempotency_key']);
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
@ -62,6 +62,55 @@ class PaymentTest extends TestCase
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testStorePaymentIdempotencyKeyIllegalLength()
|
||||||
|
{
|
||||||
|
$client = ClientFactory::create($this->company->id, $this->user->id);
|
||||||
|
$client->save();
|
||||||
|
|
||||||
|
$this->invoice = InvoiceFactory::create($this->company->id, $this->user->id); //stub the company and user_id
|
||||||
|
$this->invoice->client_id = $client->id;
|
||||||
|
|
||||||
|
$this->invoice->line_items = $this->buildLineItems();
|
||||||
|
$this->invoice->uses_inclusive_Taxes = false;
|
||||||
|
|
||||||
|
$this->invoice->save();
|
||||||
|
|
||||||
|
$this->invoice_calc = new InvoiceSum($this->invoice);
|
||||||
|
$this->invoice_calc->build();
|
||||||
|
|
||||||
|
$this->invoice = $this->invoice_calc->getInvoice();
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'amount' => $this->invoice->amount,
|
||||||
|
'client_id' => $client->hashed_id,
|
||||||
|
'invoices' => [
|
||||||
|
[
|
||||||
|
'invoice_id' => $this->invoice->hashed_id,
|
||||||
|
'amount' => $this->invoice->amount,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'date' => '2020/12/11',
|
||||||
|
'idempotency_key' => 'dsjafhajklsfhlaksjdhlkajsdjdfjdfljasdfhkjlsafhljfkfhsjlfhiuwayerfiuwaskjgbzmvnjzxnjcbgfkjhdgfoiwwrasdfasdfkashjdfkaskfjdasfda'
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
$response = false;
|
||||||
|
try {
|
||||||
|
$response = $this->withHeaders([
|
||||||
|
'X-API-SECRET' => config('ninja.api_secret'),
|
||||||
|
'X-API-TOKEN' => $this->token,
|
||||||
|
])->post('/api/v1/payments/', $data);
|
||||||
|
} catch (ValidationException $e) {
|
||||||
|
// $message = json_decode($e->validator->getMessageBag(), 1);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->assertFalse($response);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public function testPaymentList()
|
public function testPaymentList()
|
||||||
{
|
{
|
||||||
Client::factory()->create(['user_id' => $this->user->id, 'company_id' => $this->company->id])->each(function ($c) {
|
Client::factory()->create(['user_id' => $this->user->id, 'company_id' => $this->company->id])->each(function ($c) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user