Confusing shippo error during transaction using API - node.js

I keep getting this error when executing a transaction on rate object id's that were created a few days ago.
{
"source": "USPS",
"code": "",
"text": "The selected shipment date must be within 7 days of 02/15/2017, 07:11PM CST."
}
Im integrating shippo with my Node.js web application. I am using shippo node.js library.
shippo.shipment.create({, function(err, shipment) {});
I built a basic store. When user gets to checkout section, I get rates from shippo. I display those rates to the user. The user chooses which rate he wants. I save the rate object id to a database.
shippo.transaction.create({, function(err, transaction) {});
I fulfill the order and print the shipping label. The application goes to the database and retrieves rate object id to execute the transaction with shippo. In return Im suppose to get a tracking # and label information, but instead I get the error.
I first thought that the rate object id only last 7 days and then expires on its own or something. When I checked the rate object id:
https://api.goshippo.com/rates/2a0b50cbc5184362a0ea2385b490bc7b
It shows object was created 2/18. Today is the 2/21. So that cant be. The error says "The selected shipment date must be within 7 days of 02/15/2017, 07:11PM CST."
What does it mean? Why did I get it?
It seems to only happen to rate object id's that were create 2+ days ago. If the rate object id was created yesterday, I could still execute the transaction no problem.
screenshot

It looks like you are using a rate from the past (not the same day) that is causing this error to occur.
When you make a shipment at the /shipments/ endpoint, you are able to specify the submission_date when creating the shipment. If you do not specify the submission_date (you would generally only do this if you know the day you plan on shipping the item out), Shippo automatically sets the submission_date to the date the request is being made.
The reason that you are getting an error, is that you're using a rate for a shipment that has a submission_date in the past. Some carriers will only permit a submission date that is the current date, or some date in the future.
You can find more details here on the shipment object that might help.

Related

How to fetch the Finance Charge Preferences values using SuiteScript in NetSuite?

We need to perform calculations in SuiteScript using the values in Setup/Accounting/Finance Charge Preferences. Which record is this stored on? Specifically, we're looking for these finance charge fields:
Annual Rate
Minimum Finance Charge
Grace Period
We've tried to create saved searches in all of the obvious records but have not been able to find these fields.
Not documented but N/runtime can be used to get this info (at least in the console)
require(['N/runtime'], runtime=>{
const user = runtime.getCurrentUser();
console.log(user.getPreference({
name:'FC_GRACEPERIOD'
}));
});
You can get the field ids by clicking the field help on the Finance Charge Preferences page.
If that doesn't work to get the fields you can see if the fields are available but not documented by creating a server side script (I'd use a suitelet) to get the accounting preferences object and dump the field names.
If the config module was available client side this would be the console version:
require(['N/config'], config=>{
const conf = config.load({type:'accountingpreferences'});
conf.getFields().forEach(f=>console.log(f));
});

Appointment System with Google Calendar API (Timeslots) React/NodeJS

I am currently developing an appointment calendar with React and NodeJS using the Google Calendar API. The goal is to archive the following:
Step 1: User selects the desired Date in Calendar (done)
Step 2: Show Free 30 Minutes Timeslots in between the opening hours (done)
Step 3: Book Appointment and add to Calendar (done)
But now the problem is, that each timeslot can have 10 individual bookings and I want to show how much is left (e.g 3 People booked the slot at 15:30, I want to show that there are 7 Slots left) Currently if one booked the 15:30 slot it is removed. That is because I use a FreeBusy Query, and this only shows me the busy time not how many events there are.
My first thought was to save the bookings also in a database and then look for every timeslot how many people booked before, but this seems like not the best solution.
Do you have any better ideas on how to solve this problem?
Thanks in advance
Just a suggestion but maybe for each of the event placed on the calendar you could attach an extended property to mark the event as booked.
"extendedProperties": {
"shared": {
"booked": "false",}
}
https://developers.google.com/calendar/v3/reference/events#resource
Then whenever someone books an event, you could mark that event as booked by changing the extended property mentioned. To display the amount of event that are free to book you could filter the list of events by timeMin, timeMax of the selected Timeslot and count the number of events that are marked free or booked.

updating Stripe Price object

I had a question that seems to be easy but apparently is not working. I need to update the price for a Price object, but the following does not work. It gives the error that unit_amount is not known, although we use it to define the Price object initially:
stripe.Price.modify(
"price_1Hkb5FHdAaIdH7ntvOhZOyFK",
unit_amount=10,
)
You can not modify the price of a Price in the API. This is not something that is supported as there's no corresponding parameter on the API.
If you want to change the amount associated with a Price, you would create a new Price object and start using it instead. You could also make the old one inactive for example.
Another powerful feature of Stripe's API is the lookup_key on Price (doc). This lets you define a custom alias for your Price in your code. That way instead of hardcoding the price id price_123 in your code and having to update it to use price_abcd, you can transfer the old lookup key from the old price to the new one and have your code seamlessly start using the new one automatically. The idea is that you either cache the Price id associated with a lookup key based on webhooks for example or use the List Prices API and the lookup_keys parameter to quickly find the latest price id associated with a given lookup key!

Stripe: Get card information so customer can update their card

My app uses subscriptions with Stripe.
I want to create a standard "account" page, which will list the customer's current card information (like "MasterCard" and last 4 of card number), and give the customer the option of updating that information.
I'm stuck on the first piece--getting back the current card information. To do this, I need the current card_id. I have tried the "listSources" method, but this returns blank data where the card info is supposed to be. What do I need to do to get that card info?
Here is what I've tried:
(I'm using Node, and running this server side)
The closest method I have found is here:
var stripe = require('stripe')(STRIPE_TOKEN);
stripe.customers.listSources(
CUSTOMER_ID,
{object: 'bank_account', limit: 3},
function(err, cards) {
// asynchronously called
}
);
This returns information (there's no error), but the docs say this method should return a data array of the cards that includes the card id for each. In testing, the data array keeps coming back empty.
I am testing with a customer id that has a valid subscription and a card that I can see on my Stripe dashboard.
Why is the data array coming back empty?
Note: there's also a retrieve source method, which should give back card details, but this method requires you have the id of the card you want info on, and that's what I am not able to get right now.
Converting this to an answer...
Stripe has recently rolled out PaymentMethods, which replace (and are separate from) the older Tokens and Sources API.
OP's issue is that their integration creates PaymentMethod objects, which won't show up in the sources list, but can instead be accessed via stripe.paymentMethods.list.

How to undo receive payment for invoice in quickbook desktop edition using qbfc sdk

I use QBFC v13 and asp.net with c#. I have create one invoice and paid some amount for this invoice, problem is that now i want to undo payment for this invoice.I try this but not working.
ITxnDel txnDelRq = RecPayrequestMsgSet.AppendTxnDelRq();
txnDelRq.TxnDelType.SetValue(ENTxnDelType.tdtReceivePayment);
txnDelRq.TxnID.SetValue(TxnId);
So if you look at the Exception, you can see that you're getting a response from QuickBooks, and it's an error:
Object 339-1507104811 specified in the request cannot be found.
What QuickBooks is telling you here is that, in your request, you referred to a specific object (the object with TxnID = 339-1507104811) and QuickBooks can not find this object.
That means one of two things. Either:
Somebody else already deleted the object
You're using an incorrect TxnID value
Did somebody else already delete the payment? You? Your program on a previous run?
Are you 100% positive you have the correct TxnID value? It should be from the ReceivePaymentAdd request you initially used to create the payment.

Resources