# SetPaymentProvider throws error

**URL:** <https://forum.litium.com/t/setpaymentprovider-throws-error/2468>\
**Category:** Questions\
**Tags:** litium-8\
**Created:** [February 24, 2022, 10:24am UTC](https://forum.litium.com/t/setpaymentprovider-throws-error/2468 "2022-02-24T10:24:33Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![adam.clettborn](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/adam.clettborn/32/956_2.png) [@adam.clettborn](https://forum.litium.com/u/adam.clettborn)\
**Post date:** [February 24, 2022, 10:24am UTC](https://forum.litium.com/t/setpaymentprovider-throws-error/2468/1 "2022-02-24T10:24:34Z")

</div>

Hi,

When I load the checkout, the following error is thrown from SetPaymentProvider:

```auto
2022-02-24 11:19:41.5304 [App:01] [90fb8f5a34eba9b52f0409015c59c5e8] [INFO] [.NET ThreadPool Worker] System.Net.Http.HttpClient.Default.LogicalHandler - Start processing HTTP request POST https://customer-direct-payment.localtest.me:10011/api/payments/6432241f-5e27-48cb-b11b-9b9c664c67de/initialize 
2022-02-24 11:19:41.5304 [App:01] [90fb8f5a34eba9b52f0409015c59c5e8] [TRACE] [.NET ThreadPool Worker] System.Net.Http.HttpClient.Default.LogicalHandler - Request Headers:
User-Agent: Litium, (Client=directpayment), (8.2.1)
Authorization: Bearer xx
Content-Type: application/json; charset=utf-8
 
2022-02-24 11:19:41.5304 [App:01] [90fb8f5a34eba9b52f0409015c59c5e8] [INFO] [.NET ThreadPool Worker] System.Net.Http.HttpClient.Default.ClientHandler - Sending HTTP request POST https://customer-direct-payment.localtest.me:10011/api/payments/6432241f-5e27-48cb-b11b-9b9c664c67de/initialize 
2022-02-24 11:19:41.5304 [App:01] [90fb8f5a34eba9b52f0409015c59c5e8] [TRACE] [.NET ThreadPool Worker] System.Net.Http.HttpClient.Default.ClientHandler - Request Headers:
User-Agent: Litium, (Client=directpayment), (8.2.1)
Authorization: Bearer xx
Content-Type: application/json; charset=utf-8
 
2022-02-24 11:19:41.6214 [App:01] [90fb8f5a34eba9b52f0409015c59c5e8] [INFO] [] System.Net.Http.HttpClient.Default.ClientHandler - Received HTTP response headers after 90.8085ms - 200 
2022-02-24 11:19:41.6214 [App:01] [90fb8f5a34eba9b52f0409015c59c5e8] [TRACE] [] System.Net.Http.HttpClient.Default.ClientHandler - Response Headers:
Cache-Control: no-store, no-cache
Server: Microsoft-IIS/10.0
Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: *
X-Robots-Tag: noindex, nofollow
Date: Thu, 24 Feb 2022 10:19:41 GMT
Content-Length: 11909
Content-Type: text/html
 
2022-02-24 11:19:41.6214 [App:01] [90fb8f5a34eba9b52f0409015c59c5e8] [INFO] [] System.Net.Http.HttpClient.Default.LogicalHandler - End processing HTTP request after 91.1564ms - 200 
2022-02-24 11:19:41.6214 [App:01] [90fb8f5a34eba9b52f0409015c59c5e8] [TRACE] [] System.Net.Http.HttpClient.Default.LogicalHandler - Response Headers:
Cache-Control: no-store, no-cache
Server: Microsoft-IIS/10.0
Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: *
X-Robots-Tag: noindex, nofollow
Date: Thu, 24 Feb 2022 10:19:41 GMT
Content-Length: 11909
Content-Type: text/html
 
2022-02-24 11:19:41.6214 [App:01] [90fb8f5a34eba9b52f0409015c59c5e8] [TRACE] [] Newtonsoft.Json.JsonSerializer - Unexpected character encountered while parsing value: <. Path '', line 0, position 0. Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: <. Path '', line 0, position 0.
   at Newtonsoft.Json.JsonTextReader.ParseValue()
   at Newtonsoft.Json.JsonReader.ReadForType(JsonContract contract, Boolean hasConverter)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
2022-02-24 11:19:41.8700 [App:01] [90fb8f5a34eba9b52f0409015c59c5e8] [ERROR] [.NET ThreadPool Worker] Litium.Accelerator.Mvc.Controllers.Api.CheckoutController - Error when changing payment method to DirectPayment:DirectPay Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: <. Path '', line 0, position 0.
   at Newtonsoft.Json.JsonTextReader.ParseValue()
   at Newtonsoft.Json.JsonReader.ReadForType(JsonContract contract, Boolean hasConverter)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
   at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
   at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)
   at Litium.Application.Runtime.ApplicationJsonConverterImpl.TryConvert[T](String json, Func`2 action)
   at Litium.Application.Runtime.ApplicationJsonConverterImpl.ConvertJsonToObject[T](String jsonString)
   at Litium.Connect.Application.Payments.PaymentProviderClient.SendAsJsonAsync[T](HttpClient httpClient, HttpMethod httpMethod, Uri uri, Object payload, CancellationToken cancellationToken)
   at Litium.Connect.Application.Payments.PaymentProviderClient.InitializeOrUpdateSessionAsync(Payment payment, CancellationToken cancellationToken)
   at Litium.Connect.Application.Payments.PaymentServiceBase.InitializePaymentAsync(Guid paymentSystemId, CartContextSession cartContext, InitializePaymentArgs args)
   at Litium.Application.Sales.Checkout.CheckoutServiceImpl.BuildPaymentFlowResults(CartContextSession cartContext)
   at Litium.Application.Sales.Checkout.CheckoutServiceImpl.InitializePaymentsAsync(CartContextSession cartContext, InitializePaymentsArgs args)
   at Litium.Application.Sales.Checkout.CheckoutServiceImpl.AddPaymentAsync(ProviderOptionIdentifier paymentOptionId, CartContextSession cartContext, AddPaymentArgs args)
   at Litium.Application.Sales.Checkout.CheckoutServiceImpl.AddPaymentAsync(ProviderOptionIdentifier paymentOptionId, CartContextSession cartContext, AddPaymentArgs args)
   at Litium.Application.Sales.CartContextSessionServiceImpl.SelectPaymentOptionAsync(Guid systemId, SelectPaymentOptionArgs args)
   at Litium.Application.Sales.CartContextSessionServiceImpl.SelectPaymentOptionAsync(Guid systemId, SelectPaymentOptionArgs args)
   at Litium.Application.Sales.CartContextImpl.SelectPaymentOptionAsync(SelectPaymentOptionArgs args, CancellationToken cancellationToken)
   at Litium.Accelerator.Mvc.Controllers.Api.CheckoutController.SetPaymentProvider(CheckoutViewModel model) in C:\xx\Src\Litium.Accelerator.Mvc\Controllers\Api\CheckoutController.cs:line 165

```

docker-compose.yaml:

```auto
version: '3'
services:
  dnsresolver:
    image: cytopia/bind
    container_name: dnsresolver
    ports:
    - "53:53/tcp"
    - "53:53/udp"
    environment: 
    - WILDCARD_DNS=localtest.me=host.docker.internal
    - DNS_FORWARDER=192.168.65.5
    dns: 192.168.65.5
    restart: unless-stopped
  direct-payment:
    image: registry.litium.cloud/apps/direct-payment:latest
    dns: 
    - 192.168.65.2
    restart: unless-stopped
    ports:
    - "10010:80"
    - "10011:443"
    environment:
    # Enable HTTPS binding
    - ASPNETCORE_URLS=https://+;http://+
    - ASPNETCORE_HTTPS_PORT=10011
    # Configuration for HTTPS inside the container, exported dotnet dev-certs with corresponding password
    - ASPNETCORE_Kestrel __Certificates__ Default__Password=xx
    - ASPNETCORE_Kestrel __Certificates__ Default__Path=/https/localhost.pfx
    # Folder for the configuraiton, this is volume-mapped
    - CONFIG_PATH=/app_config
    # Folder where logfiles should be placed, this is volume-mapped
    - APP_LOG_PATH=/logs
    # Don't validate certificates
    - AppConfiguration__ValidateCertificate=false
    # Url to this app
    - AppMetadata__AppUrl=https://customer-direct-payment.localtest.me:10011
    # Url to the litium installation
    - LitiumApi__ApiUrl=https://customer.localtest.me
    volumes:
    - ./data/direct-payment/config:/app_config
    - ./data/direct-payment/data:/app_data
    - ./data/direct-payment/logs:/logs
    - ./data/direct-payment/DataProtection-Keys:/root/.aspnet/DataProtection-Keys
    - ./data/https:/https:ro
  direct-shipment:
    image: registry.litium.cloud/apps/direct-shipment:latest
    dns: 
    - 192.168.65.2
    restart: unless-stopped
    ports:
    - "10020:80"
    - "10021:443"
    environment:
    # Enable HTTPS binding
    - ASPNETCORE_URLS=https://+;http://+
    - ASPNETCORE_HTTPS_PORT=10021
    # Configuration for HTTPS inside the container, exported dotnet dev-certs with corresponding password
    - ASPNETCORE_Kestrel __Certificates__ Default__Password=xx
    - ASPNETCORE_Kestrel __Certificates__ Default__Path=/https/localhost.pfx
    # Folder for the configuraiton, this is volume-mapped
    - CONFIG_PATH=/app_config
    # Folder where logfiles should be placed, this is volume-mapped
    - APP_LOG_PATH=/logs
    # Don't validate certificates
    - AppConfiguration__ValidateCertificate=false
    # Url to this app
    - AppMetadata__AppUrl=https://customer-direct-shipment.localtest.me:10021
    # Url to the litium installation
    - LitiumApi__ApiUrl=https://customer.localtest.me
    volumes:
    - ./data/direct-shipment/config:/app_config
    - ./data/direct-shipment/data:/app_data
    - ./data/direct-shipment/logs:/logs
    - ./data/direct-shipment/DataProtection-Keys:/root/.aspnet/DataProtection-Keys
    - ./data/https:/https:ro

```

direct payment config:

```auto
{
  "DirectPay": {
    "PaymentAccounts": [
      {
        "Id": "DirectPay",
        "MerchantAccountId": null,
        "Environment": "Test"
      }
    ]
  }
}

```

Not really sure what to do here…

Direct payment version: 1.1.2  
Litium version: 8.2.1

---

<div class="post-metadata">

**Author:** ![adam.clettborn](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/adam.clettborn/32/956_2.png) [@adam.clettborn](https://forum.litium.com/u/adam.clettborn)\
**Post date:** [February 24, 2022, 10:31am UTC](https://forum.litium.com/t/setpaymentprovider-throws-error/2468/2 "2022-02-24T10:31:32Z")

</div>

I tried to post to the same url that is specified in the logs, and I receive the backoffice html code as a response?

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/litium/original/1X/d7aca2b2078a0c3373c511ec40ff53aaad60e82d.png)

---

<div class="post-metadata">

**Author:** ![Ericsj11](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/ericsj11/32/899_2.png) [@Ericsj11](https://forum.litium.com/u/Ericsj11)\
**Post date:** [February 24, 2022, 10:46am UTC](https://forum.litium.com/t/setpaymentprovider-throws-error/2468/3 "2022-02-24T10:46:33Z")

</div>

I have the same problem, if i set up payment/shipment on my computer, another developer have to reinstall the apps for there checkout to work.

We are using a shared database.

So everytime a developer has to do development on the checkout, they have to reinstall the apps.

Have not found a way around this yet.

---

<div class="post-metadata">

**Author:** ![adam.clettborn](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/adam.clettborn/32/956_2.png) [@adam.clettborn](https://forum.litium.com/u/adam.clettborn)\
**Post date:** [February 24, 2022, 11:05am UTC](https://forum.litium.com/t/setpaymentprovider-throws-error/2468/4 "2022-02-24T11:05:49Z")

</div>

That worked, thank you.

Weird behaviour… 😃

---

<div class="post-metadata">

**Author:** ![patric.forsgard](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/patric.forsgard/32/10_2.png) [@patric.forsgard](https://forum.litium.com/u/patric.forsgard)\
**Post date:** [February 24, 2022, 12:15pm UTC](https://forum.litium.com/t/setpaymentprovider-throws-error/2468/5 "2022-02-24T12:15:08Z")

</div>

If you using a shared database, maybe to setup an shared version of the payment/shipment apps for that customer also? Then all developers can use the same database without the need to reinstall for their computer.

When using a shared database, also the redis for communication between the developers computer can be needed for everything to work correctly.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex030/uploads/litium/original/1X/12eddac3b8b661de1db86af10ac8151b571e6fb9.png) [@system](https://forum.litium.com/u/system)\
**Post date:** [March 24, 2022, 12:15pm UTC](https://forum.litium.com/t/setpaymentprovider-throws-error/2468/6 "2022-03-24T12:15:17Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
