Skip to content

Commit

Permalink
Merge pull request #686 from Attendize/disable-refunds-on-stripe-sca
Browse files Browse the repository at this point in the history
Disable refunds on Stripe
  • Loading branch information
jeremyquinton committed Sep 18, 2019
2 parents 9cb2b2a + e57f3f8 commit b3f5771
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 13 deletions.
2 changes: 2 additions & 0 deletions app/Http/Controllers/EventCheckoutController.php
Expand Up @@ -433,6 +433,8 @@ public function postCreateOrder(Request $request, $event_id)
session()->push('ticket_order_' . $event_id . '.transaction_data',
$gateway->getTransactionData() + $additionalData);

$gateway->completeTransaction($additionalData);

return $this->completeOrder($event_id);

} elseif ($response->isRedirect()) {
Expand Down
2 changes: 1 addition & 1 deletion app/Services/PaymentGateway/Dummy.php
Expand Up @@ -48,7 +48,7 @@ public function getTransactionData() {

public function extractRequestParameters($request) {}

public function completeTransaction($transactionId) {}
public function completeTransaction($data) {}

public function getAdditionalData() {}

Expand Down
8 changes: 2 additions & 6 deletions app/Services/PaymentGateway/Stripe.php
Expand Up @@ -56,13 +56,9 @@ public function extractRequestParameters($request)
}
}

public function completeTransaction($transactionId)
{
}
public function completeTransaction($data) {}

public function getAdditionalData()
{
}
public function getAdditionalData(){}

public function storeAdditionalData()
{
Expand Down
23 changes: 17 additions & 6 deletions app/Services/PaymentGateway/StripeSCA.php
Expand Up @@ -62,17 +62,28 @@ public function extractRequestParameters($request)
}
}

public function completeTransaction($transactionId = '')
public function completeTransaction($data)
{

$intentData = [
'paymentIntentReference' => $this->options['payment_intent'],
];
if (array_key_exists('payment_intent', $data)) {
$intentData = [
'paymentIntentReference' => $data['payment_intent'],
];
} else {
$intentData = [
'paymentIntentReference' => $this->options['payment_intent'],
];
}

$paymentIntent = $this->gateway->fetchPaymentIntent($intentData);
$response = $paymentIntent->send();

if ($response->requiresConfirmation()) {
$response = $this->gateway->confirm($intentData)->send();
$confirmResponse = $this->gateway->confirm($intentData)->send();
if ($confirmResponse->isSuccessful()) {
$response = $this->gateway->capture($intentData)->send();
}
} else {
$response = $this->gateway->capture($intentData)->send();
}

return $response;
Expand Down
@@ -0,0 +1,30 @@
<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class DisableRefundsOnStripeSca extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
DB::table('payment_gateways')
->where('name', 'Stripe\PaymentIntents')
->update(['can_refund' => 0]);
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
}

0 comments on commit b3f5771

Please sign in to comment.