#hamid_api

1 messages ¡ Page 1 of 1 (latest)

tall hareBOT
#

👋 Welcome to your new thread!

⏲️ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

🔗 This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1403364876860264559

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

tall mesa
#

Hey synthrider!

civic summit
#

hello!

#

So this is known as "separate charges and transfers" and does have some restrictions on where those transfers can be sent, primarily cross-border

#

This requires creating the connected account with a recipient service agreement, which is related to the error you're encountering

#

So the flow you describe is supported, broadly, but the accounts need to be created/onboarded slightly differently.

#

(Different restrictions, different information collected etc)

tall mesa
#

okie, kindly tell more

#

here, are you talking about connected accounts?

civic summit
#

Yes, the connected account you're trying to create the transfer to

tall mesa
#

okie, so no need to change anything in platform account?

Also, this is how i am creating an account for connect.
It works for US to US but not US to MX.

account_params = {
        type: 'express',
        country: country_code,
        email: account_info[:email],
        business_type: account_type,
        capabilities: {
          card_payments: { requested: true },
          transfers: { requested: true }
        }
      }

      common_address = account_info[:address]

      if account_type == 'individual'
        account_params[:individual] = {
          first_name: user.first_name,
          last_name: user.last_name,
          phone: clean_phone,
          address: common_address
        }
      else
        account_params[:company] = {
          name: account_info[:business_name],
          phone: clean_phone,
          address: common_address
        }
      end

      account = Stripe::Account.create(account_params)
#

After creation account I use this to link the account.

def create_account_link(return_url, refresh_url)
    return { error: "No Stripe account found" } unless @carrier_company.stripe_account_id.present?

    begin
      account_link = Stripe::AccountLink.create({
        account: @carrier_company.stripe_account_id,
        return_url: return_url,
        refresh_url: refresh_url,
        type: 'account_onboarding'
      })

      Rails.logger.info "Created account link for company #{@carrier_company.name}"

      {
        success: true,
        url: account_link.url
      }
    rescue Stripe::StripeError => e
      Rails.logger.error "Account link creation failed: #{e.message}"
      { error: "Failed to create account link: #{e.message}" }
    rescue => e
      Rails.logger.error "Account link creation failed: #{e.message}"
      { error: "Failed to create account link: #{e.message}" }
    end
  end
civic summit
#

So you need to change that account creation step

#

Since you're using the legacy account type (express), switching to recipient agreement is done by adding tos_acceptance: {service_agreement: 'recipient'}, to the account creation params (in Ruby).

#

Note that this will mean you cannot collect payments with on_behalf_of in case that is relevant. That and cross border recipient flows are mutually exclusive patterns

tall mesa
#

now i have two main questions.

  1. so to make transfer happen i need to change, following.

while account creation.

FROM

#
  1. As per for my business flow, I authorize the amount in first step, by this.
        amount: @order.amount_cents,
        currency: @order.currency,
        customer:    customer.id,
        capture_method: 'manual',
        metadata: {
          order_id: @order.id,
          job_request_id: @order.job_request_id,
          shipper_user_id: @order.shipper_user_id
        },
        description: "Job Request Publication Fee - #{@order.job_request.company_name}"
      })```


Question: Can I split this authorized payment in one go, to platform and connected account?
civic summit
#

Question: Can I split this authorized payment in one go, to platform and connected account?

What do you mean by that? Can you say more?

#

You can use a destination charge with either an application_fee_amount or transfer_amount instead of the separate transfers, if thats what you mean.

tall mesa
#

see, I have two users.

one is Shipper
second is Carrier

Shipper basically authorize amount, lets say 130 usd(pasted code above, payment intent creation)

Carrier completes a certain job, and upload proof to our webiste.

We as a platform want to transfer funds to carrier 88% and then take our cut like 12%.

#

But at the time of authorization I don't have destination account, I got that later.

#

can I still split amount?

civic summit
tall mesa
#

no no, i just have platform and connected account to split

civic summit
# tall mesa But at the time of authorization I don't have destination account, I got that la...

I don't really understand how you would not have this up front, but if thats your model then destination charges will not work. You can change the amount to transfer later, but not the destination account.
https://docs.stripe.com/api/payment_intents/update#update_payment_intent-transfer_data-amount

tall mesa
#

but have you see my this message?

But at the time of authorization I don't have destination account, I got that later.

Payment Intent is already created.

I need to just charge and split

civic summit
#

Right, if you don't know that when you create/confirm the payment intent, then you can't use destination charge patterns, you'll have to manage manual transfers to the account when you know it.

tall mesa
#

see this

        amount: @order.amount_cents,
        currency: @order.currency,
        customer:    customer.id,
        capture_method: 'manual',
        metadata: {
          order_id: @order.id,
          job_request_id: @order.job_request_id,
          shipper_user_id: @order.shipper_user_id
        },
        description: "Job Request Publication Fee - #{@order.job_request.company_name}"
      })```
#

okie question 2, is clear, thanks. So i am doing the correct thing. but doing

  1. Authorizing (payment intent manual)
  2. Capture(goes to platform)
  3. Transfer to Shipper(this is what failing, cross border thing)

Now Question 1.
Let me paste here again for you.

#

So to make corss border transfer happen i need to change, following. Coz for the US -> US my code works but fails when I do US -> MX, and the error I already pasted, when I started the discussion.

while account creation.

FROM

#

Updated message above.

civic summit
#

Yes, that seems right, using transfers and recipient service agreement.

#

Yes, this separate transfer restriction is only applicable to cross-border flows

#

You can already transfer to your US connected accounts because they are in the same country (region) as your platform

tall mesa
#

just to double check, this will fix following error.

Funds can't be sent to accounts located in MX when the account is under the `full` service agreement. To learn more, see https://stripe.com/docs/connect/service-agreement-types

civic summit
#

Yes, because you'll instead use recipient agreement type for those MX accounts

tall mesa
#

Thanks a lot for the detailed, help, Let me work on it and I will get back to you if anything require. thanks again. really appreciated.

civic summit
#

NP!