# Sync

## `$kit->payments->sync()`

Re-fetches a PaymentIntent from Stripe and persists it via your storage adapter's `savePayment()`.

## Signature

```php
public function sync(string $paymentIntentId, string|int|null $userId = null): array
```

## Example request

```php
$kit->payments->sync('pi_3P9k2K2eZvKYlo2C0example', 482);
```

## Example response

Same `KitPaymentRecord` shape as [`retrieve()`](/packagist-packages/stripekit/modules/payments/retrieve), with `userId` set to whatever you passed in.

## Notes

- Called automatically by StripeKit's webhook processing for `payment_intent.succeeded` and `payment_intent.payment_failed` when `autoSync` is not disabled. See [Webhooks](/packagist-packages/stripekit/modules/webhooks/process).