你好,游客 登录 注册 搜索
背景:
阅读新闻

Windows Phone 8 In app purchase 应用内购买 / 应用内支付

[日期:2013-08-18] 来源:Linux社区  作者:王博_Nick [字体:大 中 小]

既然可以拿到商品列表了 怎么进行购买呢?其实代码也很简单还是CurrentApp

 
        private async void btnOrderProduct_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            var ProdList = await CurrentApp.LoadListingInformationAsync();
            var Prod = ProdList.ProductListings.FirstOrDefault(p => p.Value.ProductType == ProductType.Consumable);
            try
            {
                var Receipt = await CurrentApp.RequestProductPurchaseAsync(Prod.Value.ProductId, true);

                if (CurrentApp.LicenseInformation.ProductLicenses[Prod.Value.ProductId].IsActive)
                {
                    // do someting with this license...

                    // Notify the marketplace that the application has delivered the paid-for goods to the user. 
                    CurrentApp.ReportProductFulfillment(Prod.Value.ProductId);
                }
                MessageBox.Show(Receipt, "Fatura", MessageBoxButton.OK);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Fatura", MessageBoxButton.OK);
            }
        }
 

以上的代码 也可以参考

CurrentApp.RequestProductPurchaseAsync 打开应用商店进入支付页面,支付成功后 CurrentApp.LicenseInformation.ProductLicenses[Prod.Value.ProductId].IsActive 会返回true

CurrentApp.ReportProductFulfillment 是告知 MSservice 完成购买。

 

当然在判断支付成功后如果有需要的话还要和自己或product service同步。如果你没有开发者账号和应用 也可以自己搭建测试环境 请参考

相信我说到这里大家已经对 windows phone 8 应用内购买 / 应用内支付 有了大概的了解。

linux
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款