# Stripe Provider Integration

## Stripe

### Installing the integration

* Install the `Ucommerce.Payments.Stripe` NuGet package.
* Add the Stripe integration to the program.cs file to use the default Stripe implementation:

{% code title="Program.cs" %}

```csharp
        services.AddUcommerce()    
            .AddBackOffice()
            .AddPayments()
            .AddStripe()
        
        app.UseUcommerce()
            .UseBackOfficeUi()
            .UsePayments()
            .UseStripe("OptionalCallbackUri");
```

{% endcode %}

{% hint style="warning" %}
`OptionalCallbackUri` is the URI where the Stripe webhook should be pointed to later. If left without a value, the default endpoint will be:`{yourDomain}/Stripe/process/callback`
{% endhint %}

Stripe is now available as a payment method service. It can now be selected for new and existing payment methods.

### Creating a Payment Method

* In the back office UI, navigate to **Settings** -> **Payment Methods.**
* Click *New* to create a new payment method.
* Select *Stripe* as the service.

<figure><img src="/files/Agr1L5SyL0819dzePwd2" alt="" width="446"><figcaption><p>All added services will show up in the <em>Service</em> tab</p></figcaption></figure>

### Configuring Stripe

Connect the payment method to a Stripe account by filling out the *Service properties* section in UI.

<figure><img src="/files/maFgqPMZCb5P5OxnKTSr" alt="" width="563"><figcaption><p>This is what the default payment service properties looks like - it only contains an <em>AcceptUrl</em> property.</p></figcaption></figure>

{% hint style="info" %}
The service properties available will vary depending on the payment service selected.
{% endhint %}

<table><thead><tr><th>Property</th><th>Description</th><th data-type="checkbox">Required</th></tr></thead><tbody><tr><td>Public Key</td><td>The account-specific public key for the Stripe account. It can be found in the Stripe Developer Dashboard.</td><td>true</td></tr><tr><td>Secret Key</td><td>The account-specific secret key for the Stripe account. It can be found in the Stripe Developer Dashboard.</td><td>true</td></tr><tr><td>Webhook Secret</td><td>The webhook-specific key. It is set up in the Stripe Developer Dashboard.</td><td>true</td></tr><tr><td>Success URL</td><td>The partial route that the user is navigated to on a successful purchase.</td><td>false</td></tr><tr><td>Cancel URL</td><td>The partial route that the user is navigated to on an unsuccessful purchase.</td><td>false</td></tr></tbody></table>

{% hint style="warning" %}
The keys can be found on the Stripe Developer Dashboard located [here](https://dashboard.stripe.com/). When setting up the webhook, remember to point it to the [webhook set on startup](#installing-the-integration).&#x20;
{% endhint %}

Once configured, the payment method can be enabled by flipping the *Enabled* toggle in the UI.

{% hint style="info" %}
When testing the Stripe integration, the [Stripe CLI](https://stripe.com/docs/stripe-cli) can greatly help. If testing is done on a local machine using localhost, a tunneling service can be used as a proxy.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://dev.ucommerce.net/readme/payment-providers/stripe-provider-integration.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
