既然可以拿到商品列表了 怎么进行购买呢?其实代码也很简单还是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 应用内购买 / 应用内支付 有了大概的了解。
