Stripe.net upcoming invoice id is null when fetching with .Net library - asp.net-mvc

I'm fetching my next upcoming invoice for a customer so that I can charge them immediately.
So I fetch the next/upcoming invoice object and I see the data being returned (see pic), but then in order to pay/charge the upcoming invoice I need to pass the invoice id on to the 'StripeInvoiceService' method 'Pay'. But there is no id for the upcoming invoice, the value is null! Am I misunderstanding something here? As far as I'm aware, when I create invoice items for a customer under a subscription an invoice is automatically generated for the next billing cycle containing all of the invoice items...
Here is my code to fetch the upcoming invoice and then pay it
// get upcoming invoice
StripeInvoice upcomingInvoice = new StripeInvoiceService().Upcoming(profile.StripeCustomerId);
// charge card
StripeInvoice invoice = new StripeInvoiceService().Pay(upcomingInvoice.Id);
Here is the data that is returned, it shows the invoice but no id.

This is expected behavior on Stripe's end. The Retrieve Upcoming Invoice API allows you to visualize what the next invoice for a customer's subscription will look like. You can use this API to tell your user how much they will pay next time or simulate an upgrade/downgrade of the subscription.
This invoice does not exist yet, it's just a preview of what will happen when your subscription renews. Since it does not exist, it does not have an id and can't be retrieved directly. You also can not pay this invoice in advance. It can only be paid on the day the subscription renews.

Related

Twilio completed room - can it be rejoined/recreated?

I'm using the REST API to create rooms. In the docs, it says a room will end when empty for 5 minutes. I would like to know what this means when trying to reuse the same room. Can participants rejoin that room again?
My use case is that users make request to join a room via a server endpoint. A check by UniqueName is performed to see if this room exists. If it does not, it is then created using the UniqueName.
There will certainly be cases where a room is created but is empty for more than 5 minutes, and I would like to re-use the same UniqueName to join the room (empty, completed or otherwise). But it's not clear to me that this can be done once a room is completed.
E.g., if another user tries to join the completed room, will the logic from above still work, or will it break b/c the room is in completed status can cannot be joined or re-created? My goal is to always have access to a room with the same UniqueName.
Please advise, thanks.
Edit
I just had a thought to instead retrieve a list of rooms by UniqueName, which would show me a room that has already been created, regardless of its status. However, I would still need to be able to use the same room if its status is completed.
Can the status be updated from completed to in-progress?
Update
It would seem that the status cannot be updated from completed to in-progress. So, when a room is completed, how I can I continue to use the same UniqueName for another room if one already exists with that unique name?
Answering my own question here as I think I have a solution.
After tinkering with the Twilio quickstart app, I discovered that the UniqueName is unique in the context of rooms that are in-progress. I verified this by joining and leaving a room multiple times within a few seconds. A new room was created every time I left. I wasn't aware of this, but rooms created via client SDK will close instantly after all participants leave. As stated in the docs, rooms created via the REST API remain open for 5 minutes.
When I say "created", I mean that a new room with a new SID is created and can be viewed in the Twilio console, even if the UniqueName has not changed. So you can in fact have multiple rooms with the same UniqueName, but only the room with status in-progress is evaluated against when making REST API calls.
Thus, the answer would be to simply try to create a room with a unique name. Doing so when the room exists results in a 404 error as stated in the docs. Ie:
{ [Error: Room exists]
status: 400,
message: 'Room exists',
code: 53113,
moreInfo: 'https://www.twilio.com/docs/errors/53113',
detail: undefined }
However, if a room with that unique name was already completed, a new room with the same unique name can be created. The simplest approach would be to try/catch on creating a room and handle the error.
let room;
try {
room = await client.video.rooms.create({uniqueName: 'test'})
} catch (e) {
console.log(e);
}

Not able to fetch Delayed data

I have set reqMarketDataType(MarketDataType.DELAYED). But then I am getting
"Requested market data is not subscribed"
error while fetching delayed data.
// API Version 9.72 and later Launch EReader Thread
m_reader = new EReader(client, m_signal);
m_reader.start();
new Thread() {
#Override
public void run() {
processMessages();
}
}.start();
Contract contract = new Contract();
contract.symbol("GOOG");
contract.exchange("SMART");
contract.secType("STK");
contract.currency("USD");
// Create a TagValue list
Vector<TagValue> mktDataOptions = new Vector<>();
// Make a call to start off data retrieval
client.reqMarketDataType(MarketDataType.DELAYED);
client.reqMktData(1001, contract, null, false, mktDataOptions);
}
Based on your market data type and error displayed, it is USA equity, you need to subscribe the market data. Please refer to the follow link:
The procedure to subscribe the market Data in IB
To use the market data page
Click Manage Account > Trade Configuration >Market Data.
Your current market data subscriber status (Professional or Non-Professional) is displayed in the page title. Market data subscriptions are organized by region (North America, Europe, Asia-Pacific).
The Market Data page appears.
To sign up for additional market data subscriptions, click the tab for the region you want, click the check box for each subscription you wish to add, then click Back.
If you have additional linked, duplicate or consolidated accounts, the Billable Account section appears on the page. Use this section to change the account that is billed for market data.
Select the account you want to be billed for market data, then click Change Billing Account. Beginning with the next billing cycle, your market data subscriptions will be billed to the account you selected.
To unsubscribe from market data, click the check box for the subscription to clear the check mark, then click Back.Read and complete any Subscriber Agreement that appears, then click Back.
The Market Data page opens again, with your new selections updated and any pending subscriptions identified as such. Market Data subscription updates take effect immediately under normal circumstances.
https://www.interactivebrokers.com.hk/en/software/am/am/manageaccount/marketdatasubscriptions.htm
Subscription considerations for U.S. market data (Non-Professionals)
Generally speaking, clients trading a broad variety of product classes should consider the basic bundled subscription referred to as the US Securities Snapshot and Futures Value Bundle which costs USD 10 per month and provides quotes for a variety of U.S. stocks, stock indices, bonds, futures and futures options. The monthly fee for this subscription is waived for any month in which the account generates at least USD 30 in commissions.
https://ibkr.info/node/2840

Update boolean and create new records simultaneously - Rails

I need to update a Boolean and also create new records at the same time.
I have a controller called Bank, and Bank has 3 attributes, namely account:string, amount:decimal and withdrawn:Boolean, a customer can invest an amount for a specific number of days, after those days are reached they can then withdraw the amount with interest. I need that when the customer clicks withdraw the withdrawn Boolean is updated to true, and the amount+interest for example amount+10% is created and saved, the amount+10% result will also have a Boolean/flag paid which the “bank teller” can change to paid:, true after the cash payment is done.
How can I achieve the above, should I create a new controller and model for the Withdrawal, and how would that code look like?
No need to create a new controller. Just create a withdraw method in your controller. Not sure exactly what you mean with the amount+interest but I guess you're talking about another column in your database. Just add something like amount_with_interest as an attribute in the database. Also, add another column for paid, as a boolean.
def withdraw
the_bank = Bank.find(params[:id]) #or something similar to get the account one way or another
the_bank.withdrawn = true
the_bank.amount_with_interest = the_bank.amount * 1.1
the_bank.save
end
The teller can then press some other button somewhere after the payment has been sent that simply changes the_bank.paid to true

Fetch a list of portfolio positions from a brokerage account?

Use case which we want to built is a user will be presented with a list of financial institutions and when he selects anyone of it he needs to provide credentials to authenticate for selected institutions. Then brokerage account will be shown, clicking on it results into fetching of all portfolio positions.
So far what we have achieved:
Fetching list of all institutions, this we can achieve using
API method: getInstitutions
Selects an institution and authentication is performed (I am not sure this is the correct way of doing, if there is another way to do it then please let me know)
API method: discoverAndAddAccounts
Get all accounts associated with it and using Brokerage account id fetch all positions:
API method: getInvestmentPositions
Using above will return all positions but we can not differentiate between 'buy' and 'sell' action of a position.
Note: We are using this gem for the same: https://github.com/cloocher/aggcat
Thanks in advance.
First you have to know the definition of an option:
DEFINITION of 'Option'
A financial derivative that represents a contract sold by one party (option writer) to another party (option holder). The contract offers the buyer the right, but not the obligation, to buy (call) or sell (put) a security or other financial asset at an agreed-upon price (the strike price) during a certain period of time or on a specific date (exercise date).
Then by looking at the Intuit documenation we can see that:
positionType string
This is used to explain how long a position is held and differentiate between writers and holders of an option or other security.
E.g. SHORT = Writer for options,
Short - Write for all other securities,
LONG = Holder for options,
Long = Holder for all other securities. For Bonds, it is always "LONG".

Eventbrite VenueID is missing

I am making a call to;
https://www.eventbrite.com/xml/organizer_list_events?id=MYID
and getting a collection of event returned. I am integrating this data into an internal event system.
However, periodically I will get a venue without an ID. This means I cant add the venue into the system as I have no way of checking for duplicates before it is imported.
Show the VenueID always be returned? If not, under what circumstances would it not be returned?
The venue Id will not be returned if there is no venue, e.g. if the event is a webinar / online only event or the venue is not yet chosen

Resources