Skip to content

Commit

Permalink
custom intent build
Browse files Browse the repository at this point in the history
  • Loading branch information
repl6669 committed Nov 20, 2023
1 parent 4674cb0 commit 9369169
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion src/Managers/StripeManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Dystcz\LunarApiStripeAdapter\Managers;

use Illuminate\Support\Facades\Config;
use Lunar\Stripe\Managers\StripeManager as LunarStripeManager;
use Stripe\PaymentIntent;

Expand All @@ -21,6 +22,30 @@ public function __construct()
*/
protected function buildIntent($value, $currencyCode, $shipping): PaymentIntent
{
parent::buildIntent($value, $currencyCode, $shipping);
$intentData = [
'amount' => $value,
'currency' => $currencyCode,
'capture_method' => Config::get('lunar.stripe.policy', 'automatic'),
'shipping' => [
'name' => "{$shipping->first_name} {$shipping->last_name}",
'address' => [
'city' => $shipping->city,
'country' => $shipping->country->iso2,
'line1' => $shipping->line_one,
'line2' => $shipping->line_two,
'postal_code' => $shipping->postcode,
'state' => $shipping->state,
],
],
];

$intentData = array_merge(
$intentData,
Config::get('lunar-api.stripe.automatic_payment_methods', false)
? ['automatic_payment_methods' => ['enabled' => true]]
: ['payment_method_types' => Config::get('lunar-api.stripe.payment_method_types', ['card'])]
);

return PaymentIntent::create($intentData);
}
}

0 comments on commit 9369169

Please sign in to comment.