Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

在Qt应用中调用本地支付(Local Billing)APIs

From Wiki
Jump to: navigation, search

Delete instructional text in italic

This article explains how to ... Replace the abstract text with a short paragraph (or sentence) describing what the topic covers.

Enter article metadata as described below. Note that this template can be placed anywhere in the article. Do not remove parameters that you do not use

Article Metadata
Compatibility
Platform(s):
Symbian
Article
Created: ()
Last edited: renlin (22 Mar 2012)

Contents

Introduction

本文参考自Local Billing API开发团队的资料,介绍在Qt应用中使用Local billing的API及库的方法,API的接口定义参考本地支付平台API资源及使用, 开发环境是QtSDK

安装库到SDK和设备

1.复制ApiDll.dso ApiDll{000a0000}.dso到Symbian SDK相应位置C:\QtSDK\Symbian\SDKs\<$SDK>\epoc32\release\armv5\lib

开发过程

第一步,用QtCreator创建一个新的QtGui工程,将需要用到的两个头文件复制到工程下,并添加到工程中,在工程文件中可以看到:

HEADERS  += mainwindow.h \
MStateHandler.h \
PayApi.h

同时将需要用到dll库和PayClient 客户端一起打包到应用中:

  my_deployment.pkg_postrules.main = "IF NOT package(0x2005B89B)"\
"; install ApiDll_Symbian^3_Production.sis only if not already installed"\
"@\"ApiDll_Symbian^3_Production.sis\", (0x2005B89B)" \
"endif" \
"IF NOT package(0x2005B89E )"\
"; install PayClient.sis only if not already installed"\
"@\"PayClient_Symbian^3_Production.sis\", (0x2005B89E)"\
"endif"
DEPLOYMENT += my_deployment

第二步,打开mainwindow. ui文件, 添加一个pushButton 按钮 ,并连接到槽函数:on_pushButton_clicked()上。
第三步,让mainwindow.h 继承MStateHandler,并添加成员变量CPayApi* iPayApi 和声明继承自MStateHandler的两个虚函数。mainwindow.h为:

#include <QMainWindow>
#include "PayApi.h"
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow,public MStateHandler
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
private slots:
void on_pushButton_clicked();
public:
void ClientEvent(const TDesC& aEventDescription);
void PayResult(PAY_RESULT& aResult);
private:
Ui::MainWindow *ui;
CPayApi* iPayApi;
};

第四步在MainWindow.cpp中实现以上方法,调用支付客户端:

#include "mainwindow.h"
#include "ui_mainwindow.h"
#ifdef Q_OS_SYMBIAN
#include <eikenv.h>
#include <eikappui.h>
#include <aknenv.h>
#include <aknappui.h>
#include <e32base.h>
#endif
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
CAknAppUi* appUi = dynamic_cast<CAknAppUi*>(CEikonEnv::Static()->AppUi());
iPayApi = CPayApi::NewL(*this,appUi);//创建
}
MainWindow::~MainWindow()
{
delete ui;
delete iPayApi; //销毁
}
 
void MainWindow::on_pushButton_clicked()
{
iPayApi->IssuePayL(KNullDesC8,KNullDesC8,KNullDesC8,KNullDesC8,KNullDesC8);
}
//实现MStateHandler的两个函数
void MainWindow::ClientEvent(const TDesC& aEventDescription)
{
 
}
 
void MainWindow::PayResult(PAY_RESULT& aResult)
{
 
}

最后在Project中设置编译运行的SDK,连接设备,编译运行。源码下载:Media:Testnpp.zip

相关连接


Add categories below. Remove Category:Draft when the page is complete or near complete

This page was last modified on 22 March 2012, at 07:18.
198 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×