我们如何在Windows Phone 7中的应用购买中实现 [英] How do we implement in app purchase in windows phone 7
问题描述
我正在创建Windows Phone 7.1应用程序,需要在应用程序内购买
Hi i am creating a windows phone 7.1 application, which requires in app purchases
由于WP7没有像iphone一样具有特定的应用内购买SDK,我们可以使用paypal
进行应用内购买
As WP7 does not have a specific in app purchase SDK like iphone does, can we use paypal
for in app purchases,
我是Windows Phone 7和Paypal API的新手
I am new to windows phone 7 and paypal API
就像在browsercontrol
中打开移动Paypal网站.
like open a mobile paypal site in browsercontrol
when i click on payment button and get the payment done by the user and if the payment success return success message or if fail return failure message.
我不认为Movend
是最佳选择,因为我们也不得不在他们的网站上维护我不想要的产品数据库.
i do not think Movend
is a best option, as we have to maintain products database in their website also which i don't want.
推荐答案
这是我的问题的答案
Paypal没有针对WP7的特定sdk,因此我尝试通过以下方式解决上述问题
Paypal does not have specific sdk for WP7, so i tried to solve above the problem in following way
- 创建一个网站,该网站将使用查询字符串中的商品价格/详细信息
- 仅在该网站上实施ExpressCheckout.我已经使用贝宝实现了沙盒Web服务
- 在WP7应用中放置一个浏览器控件,并为该控件添加事件
BrowserControl_Navigated
- 为我们自己的网站(如
string.Format("http://localhost:62744/PaymentGateway/ExpressCheckout.aspx?ItemName={0}&Number={1}&Desc={2}&ItemPrice={3}&ItemUrl={4}", ItemName, ItemNumber, ItemDescription, ItemPrice, ItemUrl).Replace(" ", "+");
)创建网址
- 使用我们的WP7应用代码
BrowserControl.Navigate(new Uri(url));
调用网站
- 完成付款后,贝宝服务会将应用重定向到成功网址,否则我们将重定向到失败网址
- 在
BrowserControl_Navigated
事件中添加条件以检查贝宝的成功和失败网址 -
如果条件成功,请导航到WP7中的成功页面
- Create a website which will take item prices/details in querystring
- implement ExpressCheckout in that website only. I've implemented using paypal Sandbox Web service
- Place a browser control in the WP7 app and add an event
BrowserControl_Navigated
for that control - Create the Url for for our own website like
string.Format("http://localhost:62744/PaymentGateway/ExpressCheckout.aspx?ItemName={0}&Number={1}&Desc={2}&ItemPrice={3}&ItemUrl={4}", ItemName, ItemNumber, ItemDescription, ItemPrice, ItemUrl).Replace(" ", "+");
- Call the Website in our WP7 app code
BrowserControl.Navigate(new Uri(url));
- After completion of the payment paypal service will redirect the app to a success url which we mentioned otherwise redirect to failure url
- in the
BrowserControl_Navigated
event add conditions to check the paypal success and failure urls if the condition success navigate to success page in WP7
if (BrowserControl.Source.ToString().Contains( "http://localhost:62744/PaymentGateway/Success.html"))
NavigationService.Navigate(new Uri("/Success.xaml", UriKind.Relative));
更新:
以上代码会将页面重定向到PayPal移动页面,在外观上不如iOS登录页面好.我们可以使用Windows Phone 7中的一个小技巧来获取PayPal iOS页面
通过更改浏览器的标题(客户端的用户代理),将为我们提供PayPal iPhone页面
By changing the headers(user-agent of client) of the browser will give us the PayPal iPhone page
像下面一样
string header = "User-Agent:Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_1 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8B117 Safari/6531.22.7";
string url = string.Format("http://10.11.32.211:88/PaymentGateway/ExpressCheckout.aspx?ItemName={0}&Number={1}&Desc={2}&ItemPrice={3}&ItemUrl={4}", ItemName, ItemNumber, ItemDescription, ItemPrice, ItemUrl).Replace(" ", "+");
BrowserControl.IsScriptEnabled = true;
BrowserControl.Navigate(new Uri(url),null, header);
这篇关于我们如何在Windows Phone 7中的应用购买中实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!