stripe.subscriptions.retrieve not working - Stripe Nodejs - javascript

When trying to retrieve a Stripe subscription I get
Logged Error: Cannot read properties of undefined (reading 'retrieve')
Here's how I'm trying to retrieve a subscription:
const stripeSubscription = await stripe.subscriptions.retrieve(
subId
);
console.log(stripeSubscription);
Reference: Retrieve subscription Stripe docs
I was using version:
"stripe": "^8.222.0"
Then upgraded to version
"stripe": "^10.10.0"
Still not working. What am I missing or doing anything wrong?
Any help or guide is appreciated. Thanks.

It looks like you're not fully initializing the client as it looks like a secret key is not being provided to it.
Where you currently have:
const stripe = require("stripe")
can you try updating that line to include your secret key as shown in line 1 of the snippet within the documentation that you referenced, so that it looks like this, but with your actual secret key:
const stripe = require("stripe")("sk_test_XXX")

Related

Get the list of all Modules inside the Project on ThirdWeb

I was ultimately trying to get the list of all the modules I created inside my Project over the ThirdWeb.com dashboard and filter out the NFT collections out of it. So I asked on discord and someone told me to use the getAllModulesMetadata() to do so, I did something like this
const sdk = new ThirdwebSDK();
const NftModules = sdk
.getAppModule("<Project Address>")
.getAllModuleMetadata([ModuleType.NFT]);
I also did something like this but getting the same issue.
const sdk = new ThirdwebSDK();
async function getAllModules() {
const NftModules = await sdk
.getAppModule("<Project Address>")
.getAllModuleMetadata([ModuleType.NFT]);
}
getAllModules();
Now it gives this error
Unhandled Runtime Error
Error: call revert exception (method="getAllModulesOfType(uint256)", errorArgs=null, errorName=null, errorSignature=null, reason=null, code=CALL_EXCEPTION, version=abi/5.5.0)
Is something wrong? Any help will be appreciated :)
You need to pass in an RPC url or a signer in the ThirdwebSDK() constructor before you can use modules:
An RPC URL (which means the sdk is in read-only mode, you won't be able to change state of things on-chain, only fetch it). You can either use something like alchemy or use a public RPC for that particular chain.
A valid ethers signer (which could be connected from metamask, magiclink, coinbase wallet, etc)
A valid ethers.Wallet object, which can be initialised from a private key
const sdk = new ThirdwebSDK("your_rpc_url_or_signer");
Let me know if you still face any issues!

Add Meta Data To Solana Token with #solana/web3.js

I am trying to create an NFT using web3.js and spl-token.js.
However, i need to add meta data (like the name of the token or other attributes), otherwise it just shows up as "Unknown Token" in my wallet.
This is the relevant part of the code where I am minting the token:
let mint = await splToken.Token.createMint(
connection,
fromWallet,
fromWallet.publicKey,
null,
0,
splToken.TOKEN_PROGRAM_ID
);
Otherwise the code is similar to the answers on this question: I would like to mint a new token on solana. How can I do this using solana-web3.js?
There does not seem to be any documentation whatsoever, except for the structure of the meta data (which I found here: https://docs.phantom.app/integrating/tokens/on-chain-metadata).
If anyone could point me in the right direction with an example or documentation it would be really much appreciated. Thank you!
In order to add metadata to NFT you need to invoke this program spl_token_metadata::instruction::create_metadata_accounts. You can find the documentation here.
PS: The example above is in Rust. To do it in JavaScript is like that:
import { Metaplex, keypairIdentity } from "#metaplex-foundation/js";
const metaplex = new Metaplex(connection);
metaplex.use(keypairIdentity(keypair));
const mintNFTResponse = await metaplex.nfts().create({
uri: "https://ffaaqinzhkt4ukhbohixfliubnvpjgyedi3f2iccrq4efh3s.arweave.net/KUAIIbk6p8oo4XHRcq0U__C2r0mwQaNl0gQow4Qp9yk",
maxSupply: 1,
});
Like described here is another exemple.
Create a metadata for an NFT token in Solana is quite complicated. It is because in Solana SPL-token account would not carry the Metadata. Instead, you have to create another account to carry such data. So, I suggest you to use Metaplex's Candy Machine to make your own NFT with Metadata. You may get more information from their github:
https://github.com/metaplex-foundation/metaplex/

Firebase user authentication trigger that writes to realtime database

exports.setupDefaultPullups = functions.auth.user()
.onCreate(
async (user) => {
const dbRef= functions.database.ref;
let vl= await (dbRef.once('value').then( (snapshot) => {
return snapshot.ref.child('userInfo/'+user.uid).set(18);
}));
return vl;
}
);
I am trying to write a trigger for some initial set-up for a new user, in Firebase. However, the above code does not work. What is wrong with it?
Basically, upon registering a new user, I would like to set up his/her property "defaultPullUps" to, say, 18, using the above path.
EDIT: I am sorry for not giving details. Initially, there was an issue with the "async" keyword, that has been fixed by updating the node.js engine. Now, I get various error messages depending on how I tweak the code. Sometimes it says "... is not a function".
EDIT': Although I agree my question is not up to par, but there is a value in it: in online documentation of Firebase authentication triggers, how to access the "main" database is not shown https://firebase.google.com/docs/functions/auth-events
EDIT'': here is the entire message:
TypeError: Cannot read property 'child' of undefined
at exports.setupDefaultPullups.functions.auth.user.onCreate.user (/srv/index.js:15:36)
at cloudFunctionNewSignature (/srv/node_modules/firebase-functions/lib/cloud-functions.js:105:23)
at /worker/worker.js:756:24
at <anonymous>
at process._tickDomainCallback (internal/process/next_tick.js:228:7)
This line makes no sense:
const dbRef= functions.database.ref;
If you want to use the Firebase Realtime Database in a Cloud Function that is triggered from another source (such as Firebase Authentication in your case), you can do so by using the Firebase Admin SDK.
For an example of this, see the Initialize Firebase SDK for Cloud Functions section of the Get started with Cloud Functions documentation. Specifically, you'll need to import and initialize is using:
// The Cloud Functions for Firebase SDK to create Cloud Functions and setup triggers.
const functions = require('firebase-functions');
// The Firebase Admin SDK to access the Firebase Realtime Database.
const admin = require('firebase-admin');
admin.initializeApp();
And then can access the database from your function using:
const dbRef= admin.database().ref();

Retrieving data from Firebase (web) not working

I just got into Firebase and I´m trying to retrieve data from the realtime database, but I can't get anything to show up on the webpage.
This is what I got, before the JS I got the initialize Firebase code. (IF I delete the val() I receive [object Object] so something is at least working).
JS:
var heading = document.getElementById("head");
var firebaseHeadingRef = firebase.database().ref().child("Heading");
firebaseHeadingRef.on('value', function(datasnapshot) {
heading.innerText = datasnapshot.val();
});
HTML:
<div id="table_body"> <h1 id="head">Some Text</h1>
This is a screenshot from the database:
I appreciate all help :)
The Realtime Database is case sensitive. In your DB screenshot you have Heading but your JS code has .child('heading'). Try making those the same case and it should work. Note that you must also have appropriate Security Rules to allow access for unauthenticated users.
I sort of faced a similar issue, everything was fine including the database rules but no data was being fetched.
My solution
My configuration containing the apiKey & projectId was missing the databaseURL portion, so I recopied the correct configuration & it worked.
P.S
Try checking your console for any warnings from Firebase

GitHub API (Octokat.js): Cannot get Projects

I'm trying to access projects of a repository through GitHub API using Octokat.js.
The API guide says I need to use preview header, which I am using:
https://developer.github.com/v3/projects/
I'm getting error for property fetchAll of undefined (= projects).
I'm not sure what I'm doing wrong here - does anybody have an experience with this?
var Octokat = require('octokat')
var octo = new Octokat({
// put your own token here
token: 'XXX',
acceptHeader: 'application/vnd.github.inertia-preview+json'
})
octo.repos('YYY', 'ZZZ').projects.fetchAll((e, val) => {
this.projectsList = val
})
OK, turns out the API preview isn't implemented in the library yet.
https://github.com/philschatz/octokat.js/issues/144

Categories