public virtual async Task <LNURLPayPaymentMethodData> UpdateStoreLNURLPayPaymentMethod( string storeId, string cryptoCode, LNURLPayPaymentMethodData paymentMethod, CancellationToken token = default) { var response = await _httpClient.SendAsync( CreateHttpRequest($"api/v1/stores/{storeId}/payment-methods/LNURLPay/{cryptoCode}", bodyPayload : paymentMethod, method : HttpMethod.Put), token); return(await HandleResponse <LNURLPayPaymentMethodData>(response)); }
public async Task <IActionResult> UpdateLNURLPayPaymentMethod(string storeId, string cryptoCode, [FromBody] LNURLPayPaymentMethodData paymentMethodData) { var paymentMethodId = new PaymentMethodId(cryptoCode, PaymentTypes.LNURLPay); AssertCryptoCodeWallet(cryptoCode, out _); var lnMethod = GreenfieldStoreLightningNetworkPaymentMethodsController.GetExistingLightningLikePaymentMethod(_btcPayNetworkProvider, cryptoCode, Store); if ((lnMethod is null || lnMethod.Enabled is false) && paymentMethodData.Enabled) { ModelState.AddModelError(nameof(LNURLPayPaymentMethodData.Enabled), "LNURL Pay cannot be enabled unless the lightning payment method is configured and enabled on this store"); } if (!ModelState.IsValid) { return(this.CreateValidationError(ModelState)); } LNURLPaySupportedPaymentMethod?paymentMethod = new LNURLPaySupportedPaymentMethod() { CryptoCode = cryptoCode, UseBech32Scheme = paymentMethodData.UseBech32Scheme, EnableForStandardInvoices = paymentMethodData.EnableForStandardInvoices }; var store = Store; var storeBlob = store.GetStoreBlob(); store.SetSupportedPaymentMethod(paymentMethodId, paymentMethod); storeBlob.SetExcluded(paymentMethodId, !paymentMethodData.Enabled); store.SetStoreBlob(storeBlob); await _storeRepository.UpdateStore(store); return(Ok(GetExistingLNURLPayPaymentMethod(cryptoCode, store))); }