Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Value Criteria For Payment Method #1871

Merged

Conversation

xpayserver
Copy link
Contributor

I upgrade lightning max/bitcoin min to support better control in store. Now can have setting only enable specific payment method only if value high/low I think make code simple more too and backward compatible with old feature
image

Copy link
Member

@Kukks Kukks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, only small nits from my end and glad to be getting rid of that extra method on the payment method handler implementations!

currencyPairsToFetch.Add(new CurrencyPair(network.CryptoCode, storeBlob.OnChainMinValue.Currency));
foreach (var paymentMethodCriteria in store.GetPaymentMethodCriteria(_NetworkProvider, storeBlob))
{
if (paymentMethodCriteria.Value != null)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better to put in foreach with a .Where

BTCPayServer/Controllers/InvoiceController.cs Show resolved Hide resolved
@NicolasDorier
Copy link
Member

LGTM, @pavlenex you can test?

@pavlenex
Copy link
Contributor

pavlenex commented Sep 11, 2020

To me, this looks a bit odd way to solve this UX-wise. But I am not nacking it since I can't think of a different way to present this.

Maybe @dstrukt has an idea on how this can be solved in a better way

What we have now
PR1

What is proposed in this PR
PR

@dstrukt
Copy link
Member

dstrukt commented Sep 12, 2020

@pavlenex will take a look today

@dstrukt
Copy link
Member

dstrukt commented Sep 14, 2020

Few clarifications, but will use the mocks for reference:

  1. We can clarify that the payment will be enabled if a there a minimum reached via invoice total, however, wouldn't we need the ability to disable it? Conversely, the ability to add another payment method easily? (Unless there are other methods for doing this more easily / clearly?)

Option B might solve our problem at the moment, but thinking ahead, option A could address a few potential solutions as well, but might not be needed at this time.

Screen Shot 2020-09-13 at 5 06 24 PM

Screen Shot 2020-09-13 at 5 06 46 PM

  1. Stepping back from that specific feature, I think a few things on this screen need clarification and should broken out into respective sections... but I realize this pushes the scope of this ticket, so regardless of what we choose for Creating CNAME file for domain #1 (which can be updated and reflected in the follow), here are some other ideas for discussion....

Explicitly some of the sections need better descriptors, and even in this mock they could be pushed a bit more, but overall, this is an initiative I'd like to push across the entire product.

Screen Shot 2020-09-13 at 5 04 15 PM

Feedback, need for clarification, etc.. welcome as always!

@pavlenex

@dstrukt
Copy link
Member

dstrukt commented Sep 15, 2020

@Kukks and I chatted about the feature in MM. I had a few misunderstandings..made some changes.

An idea proposed by Kukks that gives the user the ability to select greater/less than..

The wording for the label could use a second pair of eyes, but I think it's clear enough.

Screen Shot 2020-09-15 at 12 35 48 AM

Apologize for any delay in release.

@pavlenex
Copy link
Contributor

IMO ^ is a perfect solution and quite clear. Good idea @dstrukt and @Kukks.

@xpayserver could you please make the change according to the proposal so that it's clearer on what's going on?

@xpayserver xpayserver force-pushed the feat/payment-method-criteria branch 2 times, most recently from 2b6f7a8 to a125ade Compare September 17, 2020 13:37
I upgrade lightning max/bitcoin min to support better control in store. Now can have setting only enable specific payment method only if value high/low I think make code simple more too and backward compatible
@pavlenex pavlenex added this to In Progress in 0.09 Miles-stone via automation Sep 22, 2020
@pavlenex
Copy link
Contributor

pavlenex commented Sep 22, 2020

tACK with a minor cosmetic change.

Just to have everyone on board here's a PR preview with e276443

Screenshot 2020-09-22 at 13 08 46

Looks great @xpayserver. I've tested it and here are a few minor notes (some of them may not be related to this PR, but perhaps are good to discuss them so we can improve stuff in the future).

I just suggest we change Enable payment methods only when amount is.. to Enable payment method when the invoice total is as originally suggested.

Unrelated to this PR, but an interesting edge-case.

  1. Have 1 payment method, on-chain BTC for example.
  2. Do not enable payment method if value is lower than 10 USD
  3. Create an invoice at 9 USD
  4. Infinite loop invoce creation called
Exception thrown: 'BTCPayServer.BitpayHttpException' in BTCPayServer.dll
Exception thrown: 'BTCPayServer.BitpayHttpException' in System.Private.CoreLib.dll
Exception thrown: 'BTCPayServer.BitpayHttpException' in System.Private.CoreLib.dll
Loaded 'csmx3w15.vlp'. Cannot find or open the PDB file.
Exception thrown: 'BTCPayServer.BitpayHttpException' in System.Private.CoreLib.dll
Exception thrown: 'NBXplorer.Models.NBXplorerException' in System.Private.CoreLib.dll
Exception thrown: 'NBXplorer.Models.NBXplorerException' in System.Private.CoreLib.dll
Loaded 'c5vyykp5.rgn'. Cannot find or open the PDB file.
Loaded 'oqculfgf.d3s'. Cannot find or open the PDB file.
The thread 319301 has exited with code 0 (0x0).
Exception thrown: 'Microsoft.EntityFrameworkCore.DbUpdateConcurrencyException' in System.Private.CoreLib.dll

@NicolasDorier
Copy link
Member

thinking merging that for next release.

Infinite loop invoce creation called

This should not happen. It should say no payment method available.

}
if (amount > limitValueCrypto && !criteria.Above)
{
logs.Write($"{logPrefix} invoice amount above accepted value for payment method", InvoiceEventData.EventSeverity.Error);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should not be errors.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the diff, this was an error before

@pavlenex
Copy link
Contributor

thinking merging that for next release.

Infinite loop invoce creation called

This should not happen. It should say no payment method available.

@NicolasDorier Should I create a separate issue for this?

@NicolasDorier
Copy link
Member

no leave it here

@NicolasDorier
Copy link
Member

@pavlenex I think your "loops" came from your weird PC. Can you replicate again?

@pavlenex pavlenex moved this from In Progress to Pending Review in 0.09 Miles-stone Sep 24, 2020
0.09 Miles-stone automation moved this from Pending Review to Review complete Sep 30, 2020
Copy link
Member

@Kukks Kukks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks ok to me

}
if (amount > limitValueCrypto && !criteria.Above)
{
logs.Write($"{logPrefix} invoice amount above accepted value for payment method", InvoiceEventData.EventSeverity.Error);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the diff, this was an error before

@NicolasDorier NicolasDorier merged commit a66578c into btcpayserver:master Sep 30, 2020
0.09 Miles-stone automation moved this from Review complete to Done Sep 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

5 participants