Transaction API Issues Migrating from v2 to v3

google-assistant

#21

I’m confused why all of this is necessary - using Jovo should give us the advantage of not having to do all this extra, very low level custom work, to update our services.

So when this issue happened last year, you said there was an update in the Jovo library that solved it - how come we are still experiencing the issue now, and why doesn’t Jovo itself provide an update for it?

This large band-aid solution may work for us, though after all this time it still hasn’t, but ultimately shouldn’t Jovo provide a formal update to fix this for all developers?


#22

I know there’s a lot to do, but please: “Make it work, make it good, make it great.” In that order.


#23

The band-aid solution is a quick fix for now. Of course, we will also update the official package.
As you know, setting up Google Transaction (with all the things that are necessary for that) is quite tedious. I don’t have a working environment for testing right now and we are working heavily on our v4 release. That’s why I asked for your help.

This should not be an excuse, but I hope you understand this.


#24

I do, I was just trying to understand the full scope of the issue, and why we have to go through all of this, once again, after we had already last year.

I still greatly appreciate your support, and the fact I am able to speak directly with you here has been a help.

Ultimately we have been able to resolve our issues, I will describe the steps taken below:

  1. We followed your advice and we added the hook - I updated it to invoke “before.response”:

app.hook(‘before.response’, (
error, handleRequest, jovo
) => {
if (jovo.$request.getAccessToken()) {
if (jovo.$originalResponse.systemIntent && (jovo.$originalResponse.systemIntent.data[’@type’] === ‘type.googleapis.com/google.actions.v2.TransactionDecisionValueSpec’)) {
jovo.$originalResponse.systemIntent.data[’@type’] = ‘type.googleapis.com/google.actions.transactions.v3.TransactionDecisionValueSpec’;
const newData = {
@type”: ‘type.googleapis.com/google.actions.transactions.v3.TransactionDecisionValueSpec’,
orderOptions: jovo.$originalResponse.systemIntent.data.orderOptions,
paymentParameters: jovo.$originalResponse.systemIntent.data.paymentOptions,
order: jovo.$originalResponse.systemIntent.data.proposedOrder
};

  jovo.$originalResponse.systemIntent.data = newData;
}

}
});

  1. We then updated the JSON we are sending to transactionDecision():

const fullOrder = {
orderOptions: {
requestDeliveryAddress: “false”
},
paymentParameters: {
merchantPaymentOption: {
merchantPaymentMethod: [
{
paymentMethodId: ${userName}${Math.floor(new Date() / 1000)},
paymentMethodDisplayInfo: {
paymentType: “BANK”,
paymentMethodDisplayName: displayName
}
}
]
},
},
presentationOptions: {
actionDisplayName: “PLACE_ORDER”
},
order: {
createTime: new Date().toISOString(),
merchantOrderId: ${userName}${Math.floor(new Date() / 1000)},
transactionMerchant: {
id: “…”,
name: “PSE&G”
},
contents: {
lineItems: [
{
id: ‘…’,
name: ${item},
description: “PSE&G Payment”,
priceAttributes: [
{
type: “TOTAL”,
name: “PSEG Payment”,
state: “ACTUAL”,
amount: {
currencyCode: “USD”,
amountInMicros: ((parseInt(cents) / 100 + parseInt(dollars)) * Math.pow(10, 6))
},
taxIncluded: false
}
],
notes: [
notes
],
purchase: {
quantity: 1,
unitMeasure: {
measure: 1,
unit: “UNIT_UNSPECIFIED”
},
}
}
]
},
buyerInfo: {
email: customerEmail,
firstName,
lastName,
displayName: ${firstName} ${lastName}
},
priceAttributes: [
{
type: “TOTAL”,
name: “Total Price”,
state: “ACTUAL”,
amount: {
currencyCode: “USD”,
amountInMicros: ((parseInt(cents) / 100 + parseInt(dollars)) * Math.pow(10, 6))
},
},
],
purchase: {
status: “CREATED”,
userVisibleStatusLabel: “CREATED”,
type: “PURCHASE_TYPE_UNSPECIFIED”,
purchaseLocationType: “ONLINE_PURCHASE”
}
}
};

With all of this, we were able to successfully implement transactions again


#25

Thank you, this is helpful. We will integrate/fix it within the next week.