storing qr code in google pay(google wallet) - google-pay

Is it possible to store information such as QR code in google pay just like apple wallet ? if not is there any alternative ,I have researched certain apps and haven't got any relevant resource yet

Yes, it is possible. Many different types of passes support a Barcode property where type is QR_CODE.
Here is an example on how to set it:
const loyaltyObject = {
id: getLoyaltyId(email),
classId: `${issuerId}.${loyaltyProgram}`,
accountId: email,
accountName: name,
state: 'active',
loyaltyPoints: {
balance: {
int: points,
},
label: 'Points',
},
barcode: {
type: 'qrCode',
value: email,
},
};

Related

Prestashop JS script tracking confirmation order page

I have a problem.
I need to deploy a tracking script for a partner to track orders. He sent me this:
<script>
var dcData = {
event: 'sel',
clear: 1,
price: '<price>',
cdata: {
orderNumber: '<ordernumber>',
email: '<email>',
},
}
digitalCircle('event', dcData);
</script>
It doesn't work after putting it in the confirm page.
Hello,
I have a problem.
I need to deploy a tracking script for a partner to track orders. He sent me this:
var dcData = {
event: 'sel',
clear: 1,
price: '',
cdata: {
orderNumber: '',
email: '',
},
}
digitalCircle('event', dcData);
It doesn't work after putting it in the confirm page.

Shopify buy js sdk addLineItems null

Im using shopify buy sdk to create checkout
I tried bellow
const lineItemsToAdd = [
variantId: 'Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0VmFyaWFudC8yOTEwNjAyMjc5Mg==',
quantity: 1
}
];
const shippingAddress = {
address1: self.selectedAddress.address1,
address2: self.selectedAddress.address2,
city: self.selectedAddress.city,
company: null,
country: self.selectedAddress.country.country_language.name,
firstName: 'Bob',
lastName: 'Norman',
phone: self.selectedAddress.phone,
province: self.selectedAddress.state.state_language.name,
zip: '11001'
};
await client.checkout.updateShippingAddress(checkoutData.id, shippingAddress);
let mainCheckoutId = await client.checkout.addLineItems(checkoutData.id, lineItemsToAdd);
Address works find but cannot add product to line items, it return null as bellow
mainCheckoutId.lineItems = null
Also erro msg
userErrors retuns message ="Variant is invalid";
I tried many products and all are published to online sale channel
And also im sure that variant id is correct
I don't know if you fixed your issue, but it looks like you are missing a brace in lineItemsToAdd :
const lineItemsToAdd = [{variantId: 'Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0VmFyaWFudC8yOTEwNjAyMjc5Mg==', quantity: 1}];

Using nested include on an array

I am trying to verify that an array has 2 elements with the following values:
expect([{
createdAt: 1545588925941,
updatedAt: 1545588925941,
id: '5c1fd0bdd38b1b2bb0875dd9',
readAt: null,
type: 'ResidentCreatedTask',
dataVersion: 0,
data: '{}',
user: '5c1fd0bdd38b1b2bb0875dd6',
home: '5c1fd0bdd38b1b2bb0875dd8'
},
{
createdAt: 1545588925941,
updatedAt: 1545588925941,
id: '5c1fd0bdd38b1b2bb0875dd9',
readAt: null,
type: 'ResidentCreatedTask',
dataVersion: 0,
data: '{}',
user: '5c1fd0bdd38b1b2bb0875dd6',
home: '5c1fd0bdd38b1b2bb0875dd8'
}
]).to.be.an('array').that.has.lengthOf(2).and.to.deep.nested.include({
0: {
type: 'ResidentCreatedTask'
},
1: {
type: 'ResidentCreatedTask'
},
});
But it's not working. I also tried changing the keys to strings with brackets like '[0]' and '[1]'.
I also tried removing the keys and making the val of includes an array like this:
.include([{ type: 'ResidentCreatedTask' }, { type: 'ResidentCreatedTask' }]);
But this also didn't work.
I don't like this solution, but you can wrap it an object.
So our payload is const payload = [{ id: 0 },{ id: 1 }]. Doing the following will not work, this is what I did in original post:
expect(payload).to.nested.include({ '[0].id': 0, '[1].id': 1 });
Work around is:
const wrappedPayload = { a: payload };
expect(wrappedPayload).to.nested.include({ 'a[0].id': 0, 'a[1].id': 1 });
This works, but I don't like having to wrap it. Very much still open to solutions. Is this a bug I should report to chai team?

PayPal Express Checkout: Setting logo_image and name using REST API

PayPal's Express Checkout documentation says that you can customize the checkout using the Experience API. And when you go to the Experience API documentation, you see the ability to set a custom name, logo_image, and more.
In our implementation, hiding the shipping fields (no_shipping: 1) works - and that uses the Experience API - but setting the name and logo_image does not.
Code below. Does anyone know if there's a way to set name and/or logo_image?
payment: function(data, actions) {
return actions.payment.create({
payment: {
transactions: [
{
amount: { total: '9.99', currency: 'USD' }
}
]
},
experience: {
name: 'Custom Name',
presentation: {
logo_image: 'https://i.imgur.com/customimage.png'
},
input_fields: {
no_shipping: 1
}
}
});
},

Validation of fetched data from API Redux React

So, I will go straight to the point. I am getting such data from api:
[
{
id: 123,
email: asd#asd.com
},
{
id: 456,
email: asdasd.com
},
{
id: 789,
email: asd#asd
},
...
]
and I should validate email and show this all info in a list, something like this:
asd#asd.com - valid
asdasd.com - invalid
asd#asd - invalid
...
My question is what is the best way to store validation data in a store? Is it better to have something like "isValid" property by each email? I mean like this:
store = {
emailsById: [
123: {
value: asd#asd.com,
isValid: true
},
456: {
value: asdasd.com,
isValid: false
},
789: {
value: asd#asd,
isValid: false
}
...
]
}
or something like this:
store = {
emailsById: [
123: {
value: asd#asd.com
},
456: {
value: asdasd.com
},
789: {
value: asd#asd
}
...
],
inValidIds: ['456', '789']
}
which one is better? Or maybe there is some another better way to have such data in store? Have in mind that there can be thousands emails in a list :)
Thanks in advance for the answers ;)
I recommend reading the article "Avoiding Accidental Complexity When Structuring Your App State" by Tal Kol which answers exactly your problem: https://hackernoon.com/avoiding-accidental-complexity-when-structuring-your-app-state-6e6d22ad5e2a
Your example is quite simplistic and everything really depends on your needs but personally I would go with something like this (based on linked article):
var store = {
emailsById: {
123: {
value: '123#example.com',
},
456: {
value: '456#example.com',
},
789: {
value: '789#example.com',
},
// ...
},
validEmailsMap: {
456: true, // true when valid
789: false, // false when invalid
},
};
So your best option would be to create a separate file that will contain all your validations methods. Import that into the component you're using and then when you want to use the logic for valid/invalid.
If its something that you feel you want to put in the store from the beginning and the data will never be in a transient state you could parse your DTO through an array map in your reducer when you get the response from your API.
export default function (state = initialState, action) {
const {type, response} = action
switch (type) {
case DATA_RECIEVED_SUCCESS:
const items = []
for (var i = 0; i < response.emailsById.length; i++) {
var email = response.emailsById[i];
email.isValid = checkEmailValid(email)
items.push(email)
}
return {
...state,
items
}
}
}
However my preference would be to always check at the last moment you need to. It makes it a safer design in case you find you need to change you design in the future. Also separating the validation logic out will make it more testable
First of all, the way you defined an array in javascript is wrong.
What you need is an array of objects like,
emails : [
{
id: '1',
email: 'abc#abc.com',
isValid: true
},
{
id: '2',
email: 'abc.com',
isValid: false;
}
];
if you need do access email based on an id, you can add an id property along with email and isValid. uuid is a good way to go about it.
In conclusion, it depends upon your use case.
I believe, the above example is a good way to keep data in store because it's simple.
What you described in your second example is like maintaining two different states. I would not recommend that.