Google做出回应的动作-“抱歉,出了点问题。请重试。”在交易流程中

时间:2019-03-19 05:56:51

标签: actions-on-google

我已经为涉及交易的Google Assistant开发了一个应用程序。一旦构建好购物车,并且用户通过密码授权了交易,Google就会退回此回复-“对不起,出了点问题。请重试。” 我在下面附上一个屏幕截图,对此需要一些帮助。 Image Link

谢谢。

============================================== >

const tempApp = actionssdk({ clientId: CLIENT_ID});

tempApp.intent('actions.intent.TRANSACTION_DECISION', async (conv) => {
console.log('Transaction decision complete');
const arg = conv.arguments.get('TRANSACTION_DECISION_VALUE');
console.log('arg.userDecision==========>>>>>>>>>>>>>>>', arg.userDecision);
if (arg && arg.userDecision ==='ORDER_ACCEPTED') {
  const finalOrderId = arg.order.finalOrder.id;
  console.log('finalOrderId===============>>>>>>>>>>>>',finalOrderId);
  let stripeToken = JSON.parse(JSON.stringify(Base64.decode(arg.order.paymentInfo.googleProvidedPaymentInstrument.instrumentToken)));
  stripeToken = JSON.parse(stripeToken);

  console.log('arg.order.paymentInfo----------------->>>>>>>', stripeToken);

  // await conv.ask('Your transaction is being processed, please wait.');

  const platformSession = await PlatformSession.findOne({psid: conv.body.user.userId}).select('activeSessionId').lean().exec();    
  const chatSession = await ChatSession.findOne({_id:platformSession.activeSessionId}).exec();

  const charge = await createCharge(stripeToken, chatSession);

  conv.channel = 'ga';
  conv.handshake = {
    query: {
      psid: conv.body.user.userId,
      ver: 1.1,
      brandName: BRAND_NAME,
      channel: 'ga',
      platformName: 'ga'
    },
    headers: {
      'user-agent': '',
      origin: '',
      host: '',
    },
  };

  console.log('conv.data********************&&&&&&&&&&&&&***************', conv.data);
  if(charge && charge.id){
   //some code
    conv.ask('Do you want an email confirmation for the booking?');
  }
  else{
    //some code
    conv.ask('Transaction Failed');
  }
} 
else if (arg && arg.userDecision === 'DELIVERY_ADDRESS_UPDATED') {
  conv.ask(new DeliveryAddress({
    addressOptions: {
      reason: 'To know where to send the order',
    },
  }));
} else {
  conv.close('Transaction failed.');
}

});

0 个答案:

没有答案