【发布时间】:2016-02-18 00:43:27
【问题描述】:
我已将 Pay with Amazon 与我的 Web 应用程序集成,但我确定只有在我逐步完成代码调试时才能捕获资金,如果我没有断点则不会发生。对我来说,这表明暂停是必要的。我正在使用定期付款。相关部分代码如下:
...
//make checkout object
AmazonAutomaticSimpleCheckout asc = new AmazonAutomaticSimpleCheckout(billingAgreeementId);
//capture
CaptureResponse cr = asc.Capture(authId, amount, 1);
//check if capture was successful
if (cr.CaptureResult.CaptureDetails.CaptureStatus.State == PaymentStatus.COMPLETED)
{
...
//give the user the things they paid for in the database
...
return "success";
}
...
所以,如果我在//capture 下的捕获行有一个断点,那么该函数将返回成功。如果我没有断点,我会收到关于以下 if 语句的运行时异常System.NullReferenceException: Object reference not set to an instance of an object.。
对我来说,这意味着我应该能够等待捕获方法。
另请注意,capture(...) 方法正在调用 CaptureAction(...) 方法,就像 C# 示例一样。
//Invoke the Capture method
public CaptureResponse Capture(string authId, string captureAmount, int indicator)
{
return CaptureAction(propertiesCollection, service, authId, captureAmount, billingAgreementId, indicator, null, null);
}
我如何等待capture 电话?是不是忘记传递参数来指示它应该立即执行操作?
【问题讨论】:
-
只是快速阅读一些 API 示例,看起来您应该等待长达 60 秒的响应。当详细信息可用时,看起来确实设置了某种标志。你看过样本吗?
-
我浏览了样本。我希望我可以等待捕获(正如你所说,最多 60 秒)。我只是不明白如何做到这一点,因为它不是标准的 C# 异步函数。
标签: c# amazon-pay