How to query the Account Balance of Alice in a substrate node? - rust

Using the polkadot UI, I can see the account Balances of Alice, Bob, displayed in the Accounts tab.
Using Developer> ChainState, I can query the storage on ("Balances" "TotalIssuance"), but there seems to be no content in ("Balances", "Account", alice_account_id)
I'm using substrate branch = "polkadot-v0.9.24"
Alternative, I can get the "Balance", "TotalIssuance" using polkadot.js.org/apps connected locally via browser extension.
So, where is the total balance of accounts like Alice stored if not in ("Balances", "Account")?

You can go in Developer > ChainState > Storage> System > AccountId

It's actually stored in the Storage map
("System", "Account", <alice_account_id>).
AccountInfoGen {
nonce: 3,
consumers: 0,
providers: 1,
sufficients: 0,
data: AccountDataGen {
free: 1142921504349461553,
reserved: 0,
misc_frozen: 0,
fee_frozen: 0,
},
},

Related

How to set products in Stripe Customer Portal

I have a Stripe account for a company selling subscriptions on two websites:
on website A: subscription plans A1, A2, A3 (these are Products in Stripe parlance)
on website B: subscription plans B1, B2 (also Products)
I would like to use the Customer Portal to allow the customers of both websites to manage their plan. I would like to show only show the respective plans on the portals created for each website.
Is it possible? How can I achieve this?
I see that we can provide a configuration built at runtime when creating a portal session, but I don't see how to specify the product set.
You can use the Customer Portal Configuration object’s features.subscription_update.products parameter to specify the products available in the portal session. This is what that would look like in Python:
stripe.billing_portal.Configuration.create(
business_profile={
"headline": None,
"privacy_policy_url": "https://example.com/privacy",
"terms_of_service_url": "https://example.com/tod"
},
features={
"subscription_update": {
"default_allowed_updates": ["price", "quantity", "promotion_code"],
"enabled": True,
"products": [
{
"product": "prod_B1",
"prices": [
"price_123",
"price_456"
]
},
{
"product": "prod_B2",
"prices": ["price_789"]
},
]
},
"payment_method_update": {
"enabled": True
},
},
)
session = stripe.billing_portal.Session.create(
customer="cus_123",
return_url='https://example.com/account',
configuration=configuration.id
)

How to retrive Stripe card ID added via Stripe customer portal?

How to retrive Stripe card ID added via Stripe customer portal?
It is not visible when I try to access it via:
test = stripe.Customer.list_sources(
'cus_Izw...',
object="card",
limit=3,
)
I see this in the response:
{
"data": [],
"has_more": false,
"object": "list",
"url": "/v1/customers/cus_Izw.../sources"
}
Cards that are added through the Customer Portal are PaymentMethods not Sources. In order to list them, you can use the /v1/payment_methods. In Python it would look something like:
stripe.PaymentMethod.list(
customer="cus_xxx",
type="card",
)

getClickwrapAgreements not returning documents

The getClickwrapAgreements call is not returning a list of documents associated with that agreement. According to the API documentation, this call should return a documents array of objects containing e.g. documentBase64, documentName, fileExtension, but that array is always empty.
Example request:
https://demo.docusign.net/clickapi/v1/accounts/<accountid>/clickwraps/<clickwrapId>/users?client_user_id=<userId>
Example response:
{
"userAgreements": [
{
"accountId": "<accountId>",
"clickwrapId": "<clickwrapId>",
"clientUserId": "<userId>",
"agreementId": "<agreementId>",
"documents": [],
"createdOn": "2020-09-25T11:30:26.8230097Z",
"agreedOn": "2020-09-25T11:30:34.5580771Z",
"status": "agreed",
"versionId": "e90d4cb6-868b-48a3-9b1c-5a7f2083102d",
"versionNumber": 8,
"settings": {
"hasDeclineButton": false,
"actionButtonAlignment": "left",
"mustRead": false,
"mustView": false,
"requireAccept": false,
"downloadable": true,
"sendToEmail": false,
"brandId": "68cbc4b1-a78f-4e72-889e-0554141da176",
"format": "inline",
"documentDisplay": "document"
}
}
],
"beginCreatedOn": "2019-01-01T00:00:00Z",
"page": 0,
"pageSize": 40,
"minimumPagesRemaining": 0
}
When I navigate to the Manage Clickwraps page in the Docusign website, I'm able to download the certificate associated with the agreement. If I enabled the recipient to download the agreement, they are also able to download it after agreeing.
For context, I need to store a copy of every user's agreement certificate in the back end.
Thank you for reporting this. This appears to be a bug with Clickwraps -- which I will report internally to have addressed. In the meantime, I was able to reproduce this issue, and can confirm that the document nodes are indeed coming back blank if hitting the user agreement in any form.
However, I was able to find this: In the call you're already making, you can see in the response there's parameter for agreementId. I did some tinkering and found that if I hit this URI:
"https://demo.docusign.net/clickapi/v1/accounts/{ACCOUNTID}/clickwraps/{clickwrapID}/agreements/{agreementId}/download?include_coc=true", I was able to download the PDF associated with that agreement. The url parameter for include coc determines if the additional certificate of completion is added onto the PDF.

issue in stripe connected account to bank transfer

i have an issue in transfer.
my stripe connected account available bal is $200.00 and i have an transfer my $200.00 and pandding balance is $150.00 balance to my bank account.
to showing error insuficient funds in your stripe connected account
see my code:
\Stripe\Stripe::setApiKey($_REQUEST['secret_id']);
$transfer = \Stripe\Transfer::create(array(
"amount" => 20000,
"currency" => "usd",
"destination" => "default_for_currency",
"description" => $_REQUEST['description'],
"source_type" => "bank_account"
));
see output :
{
msg = "You have insufficient funds in your Stripe account for this transfer. Your ACH balance is too low. You can use the the /v1/balance endpoint to view your Stripe balance (for more details, see stripe.com/docs/api#balance).";
status = 0;
}
i need solution please.
Your account actually has more than one balance -- funds are split by payment source type.
If you send a balance retrieval request, you will get a result similar to this:
{
"available": [
{
"amount": 20000,
"currency": "usd",
"source_types": {
"card": 12000,
"bank_account": 8000
}
}
],
"livemode": false,
"object": "balance",
"pending": [
{
"amount": 0,
"currency": "usd",
"source_types": {
"card": 0,
"bank_account": 0
}
}
]
}
When you create a transfer, you should specify the source type via the source_type attribute. E.g. in PHP, you'd do something like this:
\Stripe\Transfer::create(array(
"amount" => 8000,
"currency" => "usd",
"destination" => "default_for_currency",
"source_type" => "bank_account"
));
On an unrelated note, it seems you're setting the API key via a client-side parameter:
\Stripe\Stripe::setApiKey($_REQUEST['secret_id']);
You should never share the secret API key with your client-side code. It would be very easy for an attacker to retrieve it and use it to issue API requests on your behalf. They'd be able to look at your transactions, delete saved customers, etc.
When any charge is succeeded in stripe, it takes some time to actually available it in stripe account.
If You want to create the transfer based on any amount collected by any charge, then you can directly use the charge id.
So your code should be like:
\Stripe\Stripe::setApiKey("your_secret_key");
$transfer = \Stripe\Transfer::create(array(
"amount" => 1000,
"currency" => "usd",
"source_transaction" => "{CHARGE_ID}",
"destination" => "{CONNECTED_STRIPE_ACCOUNT_ID}",
));
By using source_transaction, the transfer request succeeds regardless of your available balance and the transfer itself only occurs once the charge’s funds become available.
It is documented here

Is reading whole object from DocumentDb faster and more efficient?

I'm trying to understand if it would actually be more efficient to read the entire document from Azure DocumentDb than it is to read a property that may have multiple objects in it?
Let's use this basketball team object as an example:
{
id: 123,
name: "Los Angeles Lakers",
coach: "Byron Scott",
players: [
{ id: 24, name: "Kobe Bryant" },
{ id: 3, name: "Anthony Brown" },
{ id: 4, name: "Ryan Kelly" },
]
}
If I want to get only a list of players, is it more efficient/faster for me to read the entire team document from which I can extract the players OR is it better to send SQL statement and try to read only the players from the document?
Returning only the players will be more efficient on the network, as you're returning less data. And, you should also be able to look at the Request Units burned for your query.
For example, I put your document into one of my collections and ran two queries in the portal (and if you do the same, and look at the bottom of the portal, you'll see the resulting Request Unit cost). I slightly modified your document with unique ID and quotes around everything, so I could load it via the portal:
{
"id": "basketball123",
"name": "Los Angeles Lakers",
"coach": "Byron Scott",
"players": [
{ "id": 24, "name": "Kobe Bryant" },
{ "id": 3, "name": "Anthony Brown" },
{ "id": 4, "name": "Ryan Kelly" }
]
}
I first selected just player data:
SELECT c.players FROM c where c.id="basketball123"
with an RU cost of 2.2:
I then asked for the entire document:
SELECT * FROM c where c.id="basketball123"
with an RU cost of 2.24:
Note: Your document size is very small, so there's really not much difference here. But at least you can see that returning a subset costs less than returning the entire document.

Resources