#yordis-tax-calculation

1 messages · Page 1 of 1 (latest)

whole ferryBOT
onyx ledge
#

yordis-tax-calculation

#

I agree it's a bit weird if we let you list the line items so it feels like a miss on our end, I'll flag as a feature request but you can do the same to our support team https://support.stripe.com/contact

vital ocean
#

Oh no no no 😭 I want to copy the original tax amount later on

onyx ledge
#

yeah that's just not possible today

vital ocean
#

I copied the tax_calc_id into the metdata to then use it to attach the tax record but also save it in my side

#

I just copied the amount from the initial workflow step so isnt a big deal

#

being said, scares me out a bit since I am gonna be using it to link the payments to some Tax service you are offering as far as I can tell

#

I wouldnt like my processors to get stuck and you removing the data MonkaSL

onyx ledge
vital ocean
#

eehhh

#
curl https://api.stripe.com/v1/tax/transactions/tax_1NO6wG2eZvKYlo2CsttUiHIE \
  -u sk_test_...:
#

that one you mean?

#

I am a bit confused! Hold on

#

Picture the following,

defmodule Umbrella.Web.Api.Graphql.InitiateCoursePayment do
  def resolve(_, args, resolution) do
    ...
    {:ok, tax_calculation} = get_course_taxes(args.course_id, payment_amount, args.address)

    metadata =
      %{
        # Infrastructure
        workflow_id: "COURSE_PAYMENT:INITIAL_PAYMENT",
        correlation_id: Umbrella.id().new(),
        causation_id: Umbrella.id().new(),
        # Args
        confirmation_code: confirmation_code,
        tax_calculation_id: tax_calculation.id,
        course_id: args.course_id,
        payment_mode: args.payment_mode,
        identity_id: identity.id,
        course_price: course_price.amount,
        course_price_currency: course_price.currency,
        payment_amount: payment_amount.amount,
        payment_amount_currency: payment_amount.currency,
        tax_amount: tax_calculation.tax_amount_exclusive,
        tax_amount_currency: tax_calculation.currency
      }

    Stripe.PaymentIntent.create(%{
      confirm: true,
      amount: tax_calculation.amount_total,
      currency: tax_calculation.currency,
      metadata: metadata,
      # ...
    })
  end
  
  defp get_course_taxes(course_id, payment_amount, address) do
    Stripe.V1.Tax.Calculations.create(%{
      line_items: [
        %{
          tax_code: "txcd_20060052",
          amount: payment_amount.amount,
          reference: "course_id:#{course_id}",
          quantity: 1,
          tax_behavior: "exclusive"
        }
      ],
      customer_details: %{address_source: "billing", address: address},
      currency: payment_amount.currency
    })
  end
end
#

Notice in the metadata I keep copying the original course base payment, and I added the tax_calc_id and also copy at that moment the tax_amount info, just in case

#

Talking about it, I dont get the following

reference
REQUIRED
A custom order or sale identifier, such as ‘myOrder_123’. Must be unique across all transactions, including reversals.

#

That is unique across literally everything, so is my reference kind of broken today?

#

I have reference: "course_id:#{course_id}", as you can see before

onyx ledge
#

I'm sorry I'm struggling to grasp what you're asking

#

Like earlier you asked about retrieve a Tax Calculation, which you shouldn't need. Are you asking something else?

vital ocean
#

I am reading about it, and the reference value got my attention

onyx ledge
#

okay so mostly this is a reference that needs to be unique. I am not sure. I get the question. IF you have a unique string then it's fine it will work. But if it's not unique it won't

vital ocean
#

Right, but unique across what?

#

Like all possible Payments in the system?

onyx ledge
#

unique across every tax transaction you will create forever in your account

#

it's completely unrelated to the PaymentIntent. There isn't really any link betwen a Tax Calculation, a Tax Transaction and a PaymentIntent in our API/systems today

vital ocean
#

Got it, probably a UUID is a safe move here, then. What do you think?