Easypost - How to insure and buy shipment together - easypost

I'm using the EasyPost API and I'm having a few blockers along the way. I want to create a Shipment and buy insurance at the same time, but it seems that the API wants you to first purchase the Shipment (the postage), then to buy the insurance, as per this doc: https://www.easypost.com/docs/api/java#shipping-insurance
But the doc of Create Shipment says differently, it takes an insurance amount: https://www.easypost.com/docs/api/java#shipment-object
I came to the conclusion that that the API cannot process them together, even though the Create Shipment says differently, you have to buy the label first and then buy the insurance. But this is counterintuitive for my workflow, I want to use one form to allow the user to set the addresses, the parcel, select if the shipment is insured or not, and buy the label + the insurance in one transaction au lieu of doing two transactions (the postage and the insurance).

Purchasing a shipment is typically a 2 step process:
Create shipment (rates are returned)
Buy shipment (with selected rate)
You can see that insurance amount can be declared when making the buy call. After you have purchased a production shipment, you can confirm that insurance was successfully charged by looking at the objects returned in the "fees" array of the shipment.

Related

Stripe: How to hold a place the payment for A range of price

I wonder to find a solution for payment using Stripe. My clients create an event and we split the bill all members who joins the event. Let's say a football game $100 / 10 players, we hold a place until cancellation term is expired, or the game is canceled. What I am looking for solution and if it is possible to make, for the same event, instead of 10 players, 15 joined or 5 only, which means the bill from each varies from $6.60 to $20. I want these players to see that range of the pricing from $6.60 to $20 and book their spot and agree that when event occurs, they will be charged anything between. I remember that was the same solution with Uber at the beginning. Can anyone share any ideas if it is still possible to create this way, maybe they are new legislation and we need to show the total amount. Thank you for any suggestions.
You can use Stripe to save payment info and then charge your customers later:
The Setup Intents API lets you save a customer’s card without an initial payment. This is helpful if you want to onboard customers now, set them up for payments, and charge them in the future—when they’re offline.
You may also be interested in placing a hold on a card and capturing funds later, assuming the time limits work for your use case.

Odoo12-Accounting Payment

I have an invoice with 500USD after that I have the journal entry with 500USD. While I'm doing payment I can add the amount to 800USD so on odoo it will give an option to keep open or Mark As fully paid. So I'm choosing the keep open option So as per this case odoo has to keep the invoice in an open state with 300USD remaining amount but why it should change the state to pay with the same invoice amount?
So anyone can suggest the functional thing with this case?
Yes you're right this is the default functionality of the Odoo and it is extremely cool thing in Odoo because Odoo is managing outstanding payments of our customer very effectively.
Important Point
If there is an invoice of 500USD and I registered 800USD yes it is
right thing to close the invoice 500USD because customer has paid it.
But what about the remaining 300USD. Odoo has cool feature to manage
outstanding payments. Here you can see in attached image.
I've an invoice of 125USD and I registered 200USD (200-125=65USD) then see how Odoo manage it for my important customer.

How to add VAT in Stripe Checkout?

I'm using Stripe Checkout to create a subscription in Stripe Billing. Checkout also auto creates the Stripe customer object.
How can I add right right VAT rate based on where the customer is based? The customer should be able to see the price both including and excluding VAT/GST both in the checkout session itself and on the invoice.
The "create subscription" API call allows you to set the field "default_tax_rates" which sounds like what I need, but the problem is that with Stripe Checkout the subscription (and the customer object) are created automatically by Stripe Checkout so I cannot explicitly pass parameters to these creation calls.
I know how to calculate the VAT rate and I don't want to integrate with another third party vendor just for tax, so I'm not looking for something like Quaderno or Taxamo.
How do people solve this problem? I'm starting to think that maybe I should have integrated with Chargebee instead of Stripe :-(
I'm having that same issue.
Stripe support informed me that Checkout does not support the legacy tax percentage or the new Tax Rates object.
Checkout charges only the exact amount.
On recommendation from stripe I will calculate the tax and charge that as a separate line item.
That way the correct amount is charged and the VAT is clearly visible to the customer.
I'm also creating subscriptions and there I will show the amount incl. VAT. and post fix the plan name with 'incl. VAT' to make it clear to the customer.
After the checkout flow completes I will try to add the Tax Rate to the invoice and subscription as 'Inclusive' using the API. I'm not sure that will work as I think, but we will see.
Check this out https://stripe.com/docs/payments/checkout/taxes
Seems like you're right about the Stripe checkout. Can't be added there.
Adding VAT as Inclusive won't help you, because Inclusive means it's already calculated into the price. Although this can be used to add the VAT to the price (in most cases it's 20%) and set the VAT as Inclusive. But this hack won't work for everybody, though.
I found this to be helpful and it works with Checkout.
https://dominik.sumer.dev/blog/stripe-checkout-eu-vat
You collect the Country and VAT number before creating the customer and checkout, and you add dynamic tax rates prepared via the API in advance.

Orders & Inventory DDD - Where should allocation/reservation be handled?

I am trying to refactor a legacy order handling and stock system with into a cleaner service oriented event-driven architecture. However, I am having some difficulty deciding what service should be responsible for the reservation/allocation of stock.
A brief overview of the current system
Sales orders are placed with us via third party system but we do not necessarily have all order lines in stock.
If an order item is in stock then we allocate/reserve the stock for that order straight away.
However, if we do not have enough stock then we procure the stock from our suppliers via a purchasing system.
When the item arrives from the supplier, the system will search through all open sales orders for the item and reserve/allocate the available stock to them, prioritising by sales order date. ***
I have already identified two services that I think need to be developed
Sales - Responsible for receiving the sales order and inserting into the database. Has domain entities such as Order, OrderLine etc.
Inventory - Responsible for keeping track of how much stock is available in our warehouse. Has domain entities such as StockItem.
However, as the allocation/reservation of stock concerns both inventory and sales I am not sure where the behaviour in point 2 above should be put.
I welcome any help or thoughts on this.
I think you have 2 BCs (bounded contexts): Inventory and Sales. For the integration between them I would probably go for domain events approach.
When a new item arrives at the warehouse, the Inventory BC increments the stock for the item, and publish an event.
Sales BC subscribes to the event, and it updates the opened sales that are waiting for the stock item.
So, behaviour of "point 2" are shared by both BC:
Sales BC search for opened orders waiting for that item. And then it asks Inventory BC to get the number of items it needs (this request is synchronous) and close the order.
Inventory BC receives the request and decrements the stock for the item.
However, as the allocation/reservation of stock concerns both inventory and sales I am not sure where the behaviour in point 2 above should be put.
I've been thinking about this problem (purely academically), and my current conclusion is that reservation management belongs with the inventory system. That keeps the stock source (the loading of items procured from your suppliers) and the stock sink (fulfillment of orders) together.
So the inventory system caches its own copy of the data required to fill the order (allowing it to work autonomously). It should be able to make progress as soon as it is informed that the suppliers have provided new inventory, even if the sales system happens to be down for maintenance.
You mentioned SOA and NServiceBus, so my initial thought was that you've attended Udi Dahan his ADSD training? I'll assume you have. With that, I'll try to answer your question.
So far I don't have a lot of information. But with what we have, I figured we need these properties to store all that you mentioned.
ProductId, one for each available product
InventoryTotal, attached to a ProductId. This number goes up and down
OrderId, to create an order
OrderDate, to make sure we can find the order that should receive incoming stock first.
If you have an OrderId, you can attach one or more ProductId to create an actual order. Different ways of storing this technically. Maybe in a relational database with Order and OrderLine tables, or possibly in a DocumentDb where everything is stored in a single document. That's totally irrelevant at this point.
Assuming we need 4 attributes, I'm not sure why we would create more than 1 service to split this up? This might change when we have more information, but at this moment I don't see the need.
If you want to discuss this, contact us at support#particular.net, mention my name and we can continue the conversation.
You are talking about loosely coupled domain apps, managing your sales orders, managing your inventory and managing your purchase orders.
Inventory must always be up to date, in order to not sell what you can't deliver. So PO en SO app should both talk to inventory via synchronous (inventory) services. To keep everything consistent, events on purchasing side, like receiving less than you expected for a PO, will have an impact on any SO already assigning quantity of that PO, as persisted in inventory. So the same PO pcs for example, in which the event of receiving less as expected, is registered, should synchronously update inventory, to update the quantity available for SOs to assign from, and publish an event, to be picked up, asynchronously, in the So app, so that the user can be notified and talk relevant action. Etc.

Struggling in drawing State machine diagram

Hey there I'm trying to draw state machine diagram for this scenario but It's missing lots of information. If someone here could help out with it.
The Scenario
Tourists will start the journey by selecting the trip using the
Automated Ticketing system (ATS).
The Automated Ticketing System (ATS) will display the trip details.
This Trip details will include the seat-number and destination.
Based on provided trip details, the ATS will compute payment.
The tourist has the option to pay the payment by cash or credit
card.
If the tourist will insert a wrong amount of cash, the ATS will
display "Insert More Cash" message on the screen until the correct
amount will be inserted.
If payment by card was selected by the tourist, the ATS will perform
two parallel tasks. It will validate the expiration date of the card
and check the credit balance. If card is accepted, the bank will
authorize the payment and will update the account of the tourist.
However, if card is not accepted or invalid, the ATS will again ask
for payment option (back to step 5) from the tourist.
After payment is complete, the ticket and receipt are printed by the
ATS.
Cash payment might result in some change, so the change is also
dispensed by the ATS. The tourist will then get the ticket and the
change.
ATS will display the message "Transaction Complete" at the end of
the transaction.
My Drawing:
Ok, so I try to give you some hints. A state machine is always created for a single class, not the overall system under consideration. So let's assume the ATS is a single class (in reality it will probably be more a component consisting of several classes). Now this ATS will in the beginning be idle. It is triggered somehow when a trip is selected. It then has to complete the journey details. It waits for payment and finally it will spit out a ticket. Now (basically!) the state machine looks like this:
This is a scaffold and it was done without reading the details above. Note that instead of the cancel transitions you could use a general exception from an interruptible region which eventually clears payments. In practice you would likely do that since a cancellation should (from a user perspective) be possible at any point. A time out of course would also be possible (what if already some cash had been paid?).
Also I did not include the do/entry/exit actions. For the cash this would be something like add new cash sum so we know when enough money has been paid.

Resources