【问题标题】:Square sq-payment-form Money amount not populatingSquare sq-payment-form 金额未填充
【发布时间】:2019-07-08 14:20:30
【问题描述】:

示例表单(C#),sq-payment-form 将收取的金额硬编码为 金额 = new Money(100, Money.CurrencyEnum.USD);我相信我需要更改 100 以引用表格中的费用值。但是,我找不到任何有关如何完成的信息。

我在表单 id "tc" 中添加了一个字段

  <div class="sq-field">
      <label class="sq-label sq-field--in-wrapper">Total Charge</label>
      <input class="sq-field" type="text" id="tc" />
      <div id="sq-amount"></div>
  </div>

并在 .js 文件中添加警报以显示 tc.value 我在警报中看到了值,但在 onpost 方法中我似乎无法使用 response.form("tc") 引用该字段 我已经厌倦了引用两者

string tcharge = Request.Form["sq-amount"].;
string tcharge = Request.Form["tc"]();

无济于事.....广场网站上的所有示例我都发现硬编码收费金额。 Square 网站上的其中一个示例实际上有如下评论; "// 货币金额以适用货币的最小单位指定。 // 此金额以美分为单位。它也被硬编码为 1.00 美元, // 这不是很有用。

        Money amount = new Money(100, Money.CurrencyEnum.USD);" 

我错过了什么

两个表单对象都为空,因此事务失败。我是 C# 的新手,希望能得到任何帮助。

【问题讨论】:

  • 经过更多挖掘再澄清一点.....我的形式是
    2000
    在 .js 中,totalcharge: { elementId: 'sq-totalcharge' },我的问题是什么是否替换 (Payment-Process.cshtml.cs) 以下代码行中的硬编码 100 以传递总费用金额?金额 = new Money(100, Money.CurrencyEnum.USD); TIA

标签: square-connect


【解决方案1】:

如果您希望客户能够输入一个值并将其传递给您的后端进行收费,您只需要实现另一个表单字段(如隐藏卡随机数)。例如:

<input type="text" name="sq-amount">

提交表单后,您将能够像上面一样检索输入的值(您可能需要添加一些检查以确保它是有效金额等):

string tcharge = Request.Form["sq-amount"].;
...
Money amount = new Money(Int32.Parse(tcharge), Money.CurrencyEnum.USD);" 

【讨论】:

    猜你喜欢
    • 2019-04-16
    • 2022-12-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多