开通页面点击立即购买,弹出支付方式,选择华为支付,拉起收银台,取消支付后页面显示重新支付,点击重新支付不会跳转到开通页面。
根据问题现象尝试复现问题:
[nodict][payment_extension_ability.cpp] StartUIExtensionAbility# StartUIExtensionAbility sessionId 1139957771 [nodict][payment_extension_ability.cpp] StartUIExtensionAbility# end StartUIExtensionAbility [nodict][payment_extension_ability.cpp] ExecuteRequestPayment# end ExecuteRequestPayment [nodict][payment_extension_ability.cpp] RequestPayment# end RequestPayment RSSurfaceNode::Unmarshalling, Node: 81312320848677, Name: com.huawei.hms.paymentAggrUIExtensionAbility RSNode::AddChild, Id: 69432441307937, SurfaceNode:[Id: 81312320848677, name: com.huawei.hms.paymentAggrUIExtensionAbility]
[nodict][payment_error.cpp] CreateBusinessError# CreateBusinessError errCode: 1001930000 errMsg: The operation was canceled by the user.
[nodict][payment_error.cpp] CreateBusinessError# CreateBusinessError exit
error: 支付失败: The operation was canceled by the user.code = 1001930000
[] Background(500): Background ExtensionSession, id: 1139957772, state: 3
error: 给JS回调 : doHWPayxxx('{"reqId":"doHWPayxxx","serviceId":"doHWPay","resp":{"code":1001930000,"message":"The operation was canceled by the user."}}') [nodict][nweb_handler_delegate.cc:1807] NWebHandlerDelegate::ShouldOverrideUrlLoading onOverrideUrlLoading url:https://www.example.com/xxx-h5/pay/xxx-pay-result.html?orderNo=xxxx
onOverrideUrlLoading url:https://www.example.com/xxx-h5/pay/xxx-order.html?key=000000008107405,,&derivation=index
用户取消华为支付时,应用没有跳转到开通付费项目的页面或者未支付订单页面,而是访问与业务无关的url,跳转到“未查询到缴费订单”页面。
需要优化取消华为支付时的页面跳转逻辑,建议使用try-catch捕捉错误码1001930000,使得应用根据业务逻辑正确处理用户取消支付后的页面跳转操作。
import { BusinessError } from '@kit.BasicServicesKit';
import { paymentService } from '@kit.PaymentKit';
import { common } from '@kit.AbilityKit';
@Entry
@Component
struct Index {
context: common.UIAbilityContext = this.getUIContext().getHostContext() as common.UIAbilityContext;
requestCashierPicker() {
const paymentInfo: paymentService.PaymentInfo = {
tradeSummary: '***',
amount: 100,
currency: 'CNY',
extraInfo: '{"***":"***"}'
};
paymentService.cashierPicker(this.context, paymentInfo)
.then((pickerResult: paymentService.PickerResult) => {
// succeeded in paying
console.info('succeeded in paying, picker result: ', pickerResult);
})
.catch((error: BusinessError) => {
// failed to pay
console.error(`failed to pay, error.code: ${error.code}, error.message: ${error.message}`);
if (error.code === 1001930000) {
// 应用侧需要根据业务逻辑,正确处理用户取消支付后的页面跳转操作,避免显示不相关的页面
}
});
}
build() {
Column() {
Button('requestCashierPicker')
.type(ButtonType.Capsule)
.width('50%')
.margin(20)
.onClick(() => {
this.requestCashierPicker();
});
}
.width('100%')
.height('100%');
}
}