We have a requirement to provide UPI payments for our users, we tried the google pay APIs, but it shows the pay button, and also it supports only google pay, we need to support other payment apps as well.
I was planning to generate a QR code with the amount pre-filled.
for example: If I buy a sandwich, the bill might be 100 rs, and the QR code must be generated for that only.
You can generate QR code by creating the QR for specific intent.
upi://pay?pa=&pn=&am=&cu=&tn=
where:
pa = Payee address or business virtual payment address (VPA).
pn = Payee name or business name.
am = Transaction amount.
cu = Currency Code.
tn = Transaction note.
Converting this to QR will enable to make payments using any UPI App.
Eg:
upi://pay?pa=anything%40payu&pn=Foody&tn=Order&am=100.34&cu=INR
Javascript code to generate links:
let upi = {
pa: "anything#payu",
pn: "Foody",
tn: "Order",
am: "100.34",
cu: "INR"
}
let upiLink = new URLSearchParams(upi).toString();
Related
OpenSea allows users to buy and sell NFTs. From OpenSea, you can view the prices of listed NFTs within a project. When an NFT is listed, is the listed price stored on the block chain or is it statically stored only on OpenSea's platform? Ultimately, I am looking for a way to scrape the prices of listed tokens within any NFT project. While I could scrape directly from OpenSea's website, NFT data is lazy loaded which complicates the process of scraping directly from OpenSea.io - I do not wish to use selenium.
tl;dr : Is there any way to determine the price of an NFT token within a project without using OpenSea?
Typically people are "lazy minting" and "listing" via OpenSea website, which means it's not on-chain; you will see on OpenSea that the metadata is "editable" for almost all NFTs listed for sale. Here's an example:
OpenSea listing:
Etherscan address for the person listing: (note: no on-chain transactions). What's the scope of your scraping? Best bet may be to pull via the OpenSea API? https://docs.opensea.io/reference/api-overview
Listing price is different from nft price. Listing price is the fee that you pay for the marketplace. Otherwise everyone would list nft for free and that would cause extra load on the contract and server of website.
When you write an Nft contract, you specify the listing price as:
uint public listingFee=0.025 ether;
Logically listingFee must be on chain since the nft creators are directly interacting with the smart contract.
Price of nft is different. When you create an Nft item, you define a struct:
struct NftItem{
uint tokenId;
uint price;
address creator;
bool isListed;
}
To create an Nft item, define a function:
function _createNftItem(uint tokenId,uint price) private{
require(price > 0, "Price must be at least 1 wei");
// you need to store nft's in a mapping id=>Nft
_idToNftItem[tokenId]=NftItem(
tokenId,
price,
msg.sender,
true
);
// you could emit an nft created event here
}
Price of Nft is determined by you on the fly when you submit the form to create the nft. since nft's are going to be stored on chain as struct, it will include the price
Now you call the mint function:
function mintToken(string memory tokenURI,uint price) public payable returns (uint){
// make sure you dont mint same uri again
require(!tokenURIExists(tokenURI),"Token URI already exists");
// this is where you make sure sender is paying the listig price to use the platform
// this is one time fee. so you can create a mapping and keep track of msg.senders here as bool if they paid the listing price or not
// if they did not pay, you require them to pay
require(msg.value==listingFee,"Price must be equal to listing fee");
.. more logic here
_usedTokenURIs[tokenURI]=true;
return tokenIdOfNewlyCreatetNftItem;
}
I just included the parts that related to your question in mint function.
Me and my team is new to Adobe Audience Manager and we are trying to figure out ways to stitch visitors cookies across devices (of the same visitor) once user does authentication (for ex: logins).
Have setup Adobe Analytics as well and have done integration to send data from Adobe Analytics to Adobe Audience Manager.
Primarily, we are trying to build a unified visitor's journey which as you would know will have endless benefits once we have it.
Any pointers/information or relevant doc will help a lot. Just ensuring we are moving in the right direction.
Regards,
Adwait
You can stitch user devices together (after authentication) by configuring ID sync and profile merge rules.
Here are the steps that you could follow
Configure a Cross device datasource (for merging online & offline data)
Go to Audience Data > Data Sources > Add New
name the data source as Cross Device ID Sync
Enter the following Integration code offlinesyncid, which is your own, unique ID for this data source.
In the ID Type choose Cross Device
In the ID Definition choose Person
In the Data Export Controls tick the No ristriction checkbox and make sure all other checkboxes are unticked.
In the Data Source Settings tick the Inbound checkbox and make sure the Customer ID radio button is chosen
In the Data Source Settings tick the Outbound checkbox
Make sure the Use as Authenticated Profile checkbox is ticked
Tick the Share associated visitor or device IDs across the Audience Manager platform checkbox
Save the datasource
Note the ID of the datasource you just created as we will use it in the following steps. Let's assume it is 123456
Configure an Online ID Sync datasource
Go to Audience Data > Data Sources > Add New
name the data source as Online ID Sync
Enter the following Integration code sitesyncid
In the ID Type choose Cookie
In the Data Export Controls tick the No ristriction checkbox and make sure all other checkboxes are unticked.
In the Data Source Settings tick the Inbound checkbox and make sure the Customer ID radio button is chosen
In the Data Source Settings tick the Outbound, Share Enabled, and Share associated visitor or device IDs across the Audience Manager platform checkboxes.
Save the datasource
Profile Merge Rule Setup
Go to Audience Data > Profile Merge Rules > Add New Rule
Name the new rule as Last Authenticated with Profile Link Device Graph
in the Profile Merge Rule Setup section choose the Last Authenticated Profiles radio button and tick the Cross Device ID Sync - Person datasource
From the Device Options section, choose the Profile Link Device Graph
Build the ID Sync code on your website
Assuming that you are using the dil.js code here is an example of how you can perform the ID sync
var customerID = "<customer ID e.g. 56789142>"; //Replace the text between the double quotes with your own authenticated customer ID
if (customerID) {
var yoursiteDIL = DIL.create({
partner : "<partner name>", //The partner name given to you by Adobe.
uuidCookie : {
name : "aam_uuid",
days : 30
},
visitorService: {
namespace: "XXXXXXXXXXXXXXXXXXXXX#AdobeOrg" //insert adobe org id here.
},
containerNSID: '0', // Recommended to have this set to zero. However, it could change depending on how many completely separate sites you run.
declaredId : {
dpid : "123456" , //This is the ID of the Cross Device datasource that you just created
dpuuid : customerID
}
});
var c = decodeURIComponent('%01');
var cidObject = {
cid_ic : 'sitesyncid' + c + customerID + c + '1' //this is the integration code you set for the Online ID Sync datasource
};
yoursiteDIL.api.signals(cidObject, 'd_');
yoursiteDIL.api.signals({c_sitesyncid: customerID});
} else {
var yoursiteDIL = DIL.create({
partner : "<partner name>",
uuidCookie : {
name : "aam_uuid",
days : 30
},
visitorService: {
namespace: "XXXXXXXXXXXXXXXXXXXXX#AdobeOrg" //insert adobe org id here.
}
});
}
yoursiteDIL.api.signals({ "signalKey": "signalValue"});
You can try setting up the Adobe Analytics s.visitorID based on the login details.
https://marketing.adobe.com/resources/help/en_US/sc/implement/visid_custom.html
Very often, we can find mobile applications which provide in-app purchase store credit card details, allowing users to buy things in a convenient manner. I am planning to implement the same mechanism on the client side. The following points are what I can think of.
First, there are several variables involved:
credit_card_number
The credit card number used for the purchase.
cvc
The CVC of the credit card being used.
expiry_date
The expiry date of the credit card being used.
card_info_key
The key used to encrypt and decrypt the credit card information stored in the client device.
Is it viable to save card_info_key on the server, then use it to encrypt and decrypt credit card information on the client device as follows?
// credit card information entered by user
var credit_card_number = '1234123412341234';
var cvc = '789';
var expiry_date = '12-2020';
// the key is retrieved from server
var card_info_key = getCardInfoKeyFromServer(current_user);
var card_info = {
'number': credit_card_number,
'cvc': cvc,
'expiry': expiry_date
};
// an encrypted token is expected
var encryptedCardInfo = encryptCardInfo(card_info, card_info_key);
// an object containing the same data as card_info should be returned
var decryptedCardInfo = decryptCardInfo(encryptedCardInfo, card_info_key);
Besides, what encryption and decryption algorithm should I use?
This is not a technical issue because you simply aren't allowed to implement such a functionality (unless you make the app PC-DSS compliant).
See How to save credit card data in a database? for more info and links.
We need to track conversions that happen on a 3rd party site. The only thing we can place on that site is an image pixel and maybe some JS logic for when to fire it.
I know it is possible to fire a conversion using the Measurement Protocol: https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#visitor
Ideally, I'd just give the 3rd party an IMG url and that would be it. The problem is the CID (unique client id).
I can try passing the CID from our site to the 3rd party via URL parameter. However, there are many cases where its not available (e.g., IMG pixcel will be in an email, the goal URL is on printed literature) or the 3rd party is not willing to go through the hassle. Is it best practice to pass this CID in this way?
I can try generating a CID, but I can't find a dead simple way of doing that e.g., var CID = generateCID(). The 3rd party site has its own GA on the page. Can I just take their Google Analytics CID and use it in the image pixel URL?
What the best way to do this? Thank you!
If the 3rd-party site has analytics.js already running then using that client ID is probably best. You can get it by doing the following:
var cid;
ga(function(tracker) {
cid = tracker.get('clientId'));
});
If analytics.js is not running, or if you can't access the ga variable for some reason, you can just generate the client ID randomly. This is approximately what Google does. It's a random 31-bit integer with the current date string appended:
var cid = Math.floor(Math.random() * 0x7FFFFFFF) + "." +
Math.floor(Date.now() / 1000);
Only to complement #Philip Walton excellent answer, Google Analytics expects a random UUID (version 4) as the Client ID, according to the official Documentation.
Client ID
Required for all hit types.
This anonymously identifies a particular user, device, or browser
instance. For the web, this is generally stored as a first-party
cookie with a two-year expiration. For mobile apps, this is randomly
generated for each particular instance of an application install. The
value of this field should be a random UUID (version 4) as described
in http://www.ietf.org/rfc/rfc4122.txt
#broofa provided a simple way to generate a RFC4122-compliant UUID in JavaScript here. Quoting it here for the sake of completeness:
'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);
return v.toString(16);
});
I am trying to use the Google Analytics API (v3) in Google Scripts to pull Device Category information from Google Analytics.
Within Analytics under Audience -> Mobile -> Overview there is a Device Category section listing 'tablet', 'mobile' and 'desktop'. I wish to pull these numbers into a Google Sheet that my script is attached to.
The code I believe I should be using is:
ga:deviceCategory==mobile (to pull mobile traffic) and ga:deviceCategory==tablet to pull tablet traffic.
However, I receive the error:
Invalid dimension or metric: ga:deviceCategory==desktop
I'm somewhat confused by this as Google's own documentation says that deviceCategory is a valid dimension
(https://developers.google.com/analytics/devguides/reporting/core/dimsmets#view=detail&group=platform_or_device&jump=ga_devicecategory)
If I remove the device type from the end ('ga:deviceCategory') I get the error:
Unknown metric(s): ga:deviceCategory (line 43, file "Code")
This leads me to believe that I need to include the metric (which I believe is 'pageviews') beforehand. If this is the case, can someone show me how I pull in the figures for mobile/tablet traffic?
I am having no other issues pulling other aspects of my data. For example:
var impressions = Analytics.Data.Ga.get(tableId, startDate, endDate, 'ga:visits').rows.toString();
works fine.
For reference, this is the full code I am using for device Category:
// Get Mobile Visits, this is the number of visits from mobile devices
var mvisits = Analytics.Data.Ga.get(tableId, startDate, endDate, 'ga:deviceCategory==mobile').rows.toString();
mvisits = mvisits;
I would be grateful for any assistance and please let me know if you require any more code from my script.
Thanks in advance.
My app script is a bit rusty but your problem is your == the dimension field is just a column you want to select.
var tableId = 'ga:' + profileId;
var metric = 'ga:visits';
var options = {
'dimensions': 'ga:deviceCategory',
'filters': 'ga:deviceCategory==mobile'
};
var report = Analytics.Data.Ga.get(tableId, startDate, endDate, metric,
options);
What you need to do is add some filters instead. If you think of this like a relational database this would be like saying
select deviceCategory, visits
from tableId
where devicecategory == mobile
Remember you need to add a metric.
Example: shamelessly ripped from Analytics service page.