#nakasho

1 messages · Page 1 of 1 (latest)

regal schoonerBOT
wide mortar
#

export const refEnrollment3 = async (req, res) => {
try {
// check if course is free or paid
const course = await Course.findById(req.params.courseId)
.populate("instructor")
.exec();
if (!course.paid) return;
const refuser = await User.findOne(req.params.from);
// application fee 30%
const fee = (course.price * 30) / 100;
// referral fee
const referral_fee = Math.round(course.price.toFixed(2) * 3);
// instructor fee
const instructor_fee = Math.round(course.price.toFixed(2) * 3);
// console.log("referral_fee => ", referral_fee);
// console.log("instructor_fee => ", instructor_fee);

const session = await stripe.checkout.sessions.create({
  payment_method_types: ["card"],
  // purchase details
  line_items: [
    {
      price_data: {
        product_data: {
          name: course.name,
        },
        currency: "jpy",
        unit_amount: Math.round(course.price.toFixed(2) * 100),
      },
      quantity: 1,
    },
  ],
  mode: "payment",
  // charge buyer and transfer remaining balance to seller (after fee)

  // redirect url after successful payment
  success_url: ${process.env.STRIPE_SUCCESS_URL}/${course._id},
  cancel_url: process.env.STRIPE_CANCEL_URL,
});
// console.log("SESSION ID => ", session);
// Create a Charge:
const charge = await stripe.charges.create({
  unit_amount: Math.round(course.price.toFixed(2) * 100),
  currency: "jpy",
  source: "tok_visa",
  source_transaction: "REF_ORDER",
});

// console.log("SESSION ID => ", session);
// console.log("charge ID => ", charge);
#

// Create a PaymentIntent:
const paymentIntent = await stripe.paymentIntents.create({
amount: course.price,
currency: "jpy",
transfer_group: "REF_ORDER",
});
// Create a Transfer to the connected account (later):
const transfer = await stripe.transfers.create({
amount: 7000,
currency: "jpy",
destination: course.instructor.stripe_account_id,
transfer_group: "REF_ORDER",
});
// Create a second Transfer to another connected account (later):
const secondTransfer = await stripe.transfers.create({
amount: 2000,
currency: "jpy",
destination: refuser.stripe_account_id,
transfer_group: "REF_ORDER",
});

await User.findByIdAndUpdate(req.user._id, {
  stripeSession: session,
}).exec();
res.send(session.id);
// console.log("paymentIntent=> ", paymentIntent);

} catch (err) {
// console.log("PAID ENROLLMENT ERR", err.message);
return res.status(400).send("Enrollment create failed");
}
};

#

I ran this code and got an error message telling me to contact the community.

eager trail
#

thanks for putting the images here, i'll remove in main channel

wide mortar
#

Hello, I am a member of the board of directors of the company. Best regards.
Is this the right thread to contact you for messages?

eager trail
#

Now we would like to transfer the money to the referrer's Stripe account.

However, the implementation of the code is not working.

#

What is not working at this step?

#

You can create a standalone transfer to another connected account from your platform available balance

wide mortar
#

All is not well.
Of course, the single transfer has been successful.
And the application fee has also been successful.

However, I cannot achieve what I want to do.
I want to distribute and transfer the commissions to the application, the referrer, and the seller at the same time. But this code does not work.

Do you know what is wrong with this code?

eager trail
#

But this code does not work.
What does not work? What fails? Are there errors your can share?

wide mortar
#

Application fees for destination payments on the platform and transfers to the seller have been successful.
We want to transfer the money to the referrer as well, so we have changed to create a separate payment and remittance system. Then it stopped working.

Sorry, please wait while I take a screenshot of the error in the code.

eager trail
wide mortar
#

This paidEnrollment function is the function that transfers the money to the application operator and the content seller.
This paidEnrollment function succeeds.

Now we want to transfer the money to the referrer as well.
We have created a refEnrollment function.
This fails.
I am able to get the referrer's Stripe Id.
For some reason, it does not work.

eager trail
#

That looks like your own API request

#

not a stripe error

#

Is there a stripe request on the server that fails?

wide mortar
#

In that case, a connection error will occur.

The API connection is working.
The Console.log output of the function Fee is being output.

eager trail
#

Sorry, can you say more? There must be something failing somewhere, right?

wide mortar
#

We simply want to change the payment to a function that has been successful so far, so that it can be transferred to the referrer as well.
The error is not detailed for some reason. I get a message to contact the community.

#

referral_fee => 42
instructor_fee => 42
PAID ENROLLMENT ERR Cannot create transfers; please contact us via https://support.stripe.com/contact with details for assistance.

eager trail
#

Where, can you share that?

#

That looks like something is passing along a stripe error, where does that come from?

#

Let's try another approach -- can you share any example payment from your platform?

#

Let's see if I can find the error here

wide mortar
#

By something, do you mean this?
PAID ENROLLMENT ERR Cannot create transfers; please contact us via https://support.stripe.com/contact with details for assistance.

#

I'm sorry, what do you mean by examples of payments from your platform?

#

Do you mean pay the seller and the application instead of transferring the money to the referrer?
That is not an error. Success.

eager trail
#

What is your platform account id?

#

Or any ID of an object that belongs to your platform account

wide mortar
#

Sorry, I was trying to output only error messages.
This is the entire error log.

#

Excuse me, where can I find the platform ID?
I have been paying the platform automatically with an application fee.

eager trail
#

You can get your account id here:

#

In the top right corner

wide mortar
#

acct_1LtETRLNEeSdZrBQ

#

This is because I am catching Stripe errors on my server side.

eager trail
wide mortar
#

Does this mean that the first Transfer is failing?
Can I use the Transfer payment to be split and stripe.checkout.sessions.create together?
Which transfer method is appropriate for my business case?
I just want to simply transfer the money to my referrer ID as well.

topaz pine
#

Hi there đź‘‹ taking over for @eager trail

Give me a few minutes to get caught up.

#

Does this mean that the first Transfer is failing?
I'm not sure what you mean by first transfer. Synthrider posted an error log for a failed transer to an account.

Can I use the Transfer payment to be split and stripe.checkout.sessions.create together?
You can, but you need to make sure you're creating transfers to an account that is allowed to receive Transfers. I'd recommend looking at the Account object's requirements hash and checking to see if there are any outstanding requirements.

wide mortar
#

Did the transfer to your account fail?
Or did you fail to create the transfer information to your account?

#

What is a requirement hash for an account object? How can I check it?

topaz pine
#

I have no idea what you're asking. Can you be specific and choose one question at a time?

#

Lets's start here:

What is a requirement hash for an account object? How can I check it?

#

Once you do that, you can look at the requirements hash on the Account object to find out why it might have Transfers disabled

wide mortar
#

I would like to know if you have been successful or unsuccessful in creating Transfer information.
I know that Transfer is failing to transfer.
Is the creation of the Transfer before the Transfer is successful?

#

Thank you. I'll check the hash.

topaz pine
#

Are you asking if the Charge was successful?

wide mortar
#

The account information has been successful.
What is the hash on this?

#

transfers: 'active'.

topaz pine
#

Hmmm, let me take a look

#

Ah, okay. So the account that is creating the Transfer is also known as the platform, which is this account --> (acct_1LtETRLNEeSdZrBQ) . The account that would be receiving the transfer is the destination account, which is this one (acct_1MHFUHPpWI1DmEAz).

You'll want to look at the capabilities hash and the requirements hash on the destination account as well

wide mortar
#

On the forwarding account, what is this one? (acct_1MHFUHPpWI1DmEAz)
Content seller? Referrer?

topaz pine
#

Which account(s) do you own?

wide mortar
#

This is the instructor's (seller's) ID.

topaz pine
#

Right, but which account(s) do you own?

#

I believe you are likely unable to make that transfer due to the verification requirements that are showing in the requirements hash, so you may want to look into satisfying those

wide mortar
#

This one is the referrer's account.

#

What does it mean to meet verification requirements?
Which settings do I need to make?

topaz pine
wide mortar
#

link not working

#

Page not found!
Sorry, the page you are looking for could not be found.
If you cannot find what you are looking for, please check the Stripe website. We also have a support site available if you need assistance.

#

Is this a web app platform submission document?
Which account documentation are you referring to?

Is it the submitted documents that are causing the problem?
Maybe it has nothing to do with that.
Because the normal payments (except for referrals) are WORKING.

#

Stripe payments have been working until now.
We simply want to pay referrals to that feature as well.
I think what we want to do is simple.

worldly zinc
#

All accounts that receive payments must pass KYC (Know Your Customer) and AML (Anti-Money Laundering) identification and Verification. This is required by Law and Regulations. This means both the "seller" Connected account and the "referrer" Connect account must have provided all of the required identification, documents, etc. Stripe's Dev engineers are trying to indicate that the account you are calling "referrer", here, has not completed the process. Your platform can retrieve information about a connected account which is returned to you from the API as a JSON "object", which they call a hash.

maiden patio
worldly zinc
#

As far as paying both a "seller" and a "referrer" at the same time - Stripe Charges are really single-source/single-destination. To split a payment, the general process is "Separate Charges and Transfers" - the Customer charge is created to the Platform, and then two separate transfers are set up, one to each of "seller" and "referrer" (or two "sellers", or whatever your structure is). There are some limitation of transfers depending on Country, so you may need a more complex flow.

wide mortar
#

Thanks for the details.
â‘ Are you saying that Transfer should not be used?
What do you mean by single destination?
I need to transfer the money to 3 people, the referrer, the seller and the app operator. How can I transfer the money in a single destination instead of multiple transfers?

②What exactly are the restrictions on remittances?
Does Japan fit into that category?

③What is the correct remittance flow that is not affected by remittance restrictions?

#

④Regarding the fact that referrals must submit a submission form.
I made a test purchase with the "seller" user as the same user as the "referrer", Stripe account is the same.
Still the error occurs.
Since the "seller" user is verified, shouldn't that work as a "referrer" as well?

maiden patio
#

At this point I think your questions will be best answered by writing in to Support at https://support.stripe.com

worldly zinc
#

I'm of the same opinion as Snufkin, here - I was trying to resolve language differences, but your concerns seem to mix many different concepts together in confusing ways. Support will be better able to help you, especially since they likely can support you directly in your language.
(I don't work for Stripe, btw)

wide mortar
#

Currently, access to additional confirmations is by invitation only. If you would like this feature, please contact us and request an invitation.
We have sent you an email.

#

Isn't the developer team here better than the sales support team?

maiden patio
#

@wide mortar your questions do not seem to be focused on integrations with the API. This makes it hard to answer them in this forum.

wide mortar
#

What does it mean?
I assume the question is about the Stripe API?

maiden patio
#

Could you restate the current state of your question please?

wide mortar
#

Questions 1 through 4 are questions about your answers.
Essentially, I don't know how to modify the code.

maiden patio
#

We have already told you that the accounts are missing additional requirements. You will need to supply additional information to Stripe in order to enable either charges or transfers. That is the first place to start.

wide mortar
#

What is the single destination you are talking about, GiGStartr?
Why is it single, but you can pay multiple people: the referrer, the seller and the app operator?

#

Yes, I am. I understand that we need to verify additional information.
What I am wondering is if there is another, separate, code that needs to be modified.
Because I am currently using Transfer, but am confused since I was told that I should use a single distinction or that I need a complex flow.
First of all what is a single distinction?
Is the current code single-distination? Is it not?

maiden patio
#

I think there are some confusions regard language barriers that are preventing us from communicating clearly. Stripe Support (https://support.stripe.com) will be better able to assist you to ensure we are talking about the same things.

wide mortar
#

What do you mean by language barriers?
Do you not understand English?
Could you change to a staff member who speaks English?

maiden patio
#

Being rude is a violation of our #đź“–rules
However what GigStartr was saying was this:

Stripe Charges are really single-source/single-destination

#

Single destination

#

A Charge collects funds from a single Customer and moves then to a Single Account

wide mortar
#

And I have one more question.
Where in the message do I see that I am being asked to provide documentation verifying my "referral?"

maiden patio
#

If, after that, you wish to move funds to more than 1 account you will need to user the Transfers API

#

When you query the Account API, what do you see in the requirements property?

wide mortar
#

Excuse me, what do you mean by rude?
You are the one who said there is a language barrier, though.
Is it my fault?
You are the one who said there is a language barrier, even though we use the same English, isn't that rude?

#

Which information is the variable for which you are requesting documentation?
This is the referrer's account data.

maiden patio
#

What is the referrer in this case?

#

Who is the Platform and who is the Connected Account?

wide mortar
#

As I have explained many times in the thread.
A referrer is the person who introduced the product.

Which information in the requirements object represents the submittal?

#

Platform is the app operator (Me). They receive a commission.
Referrer. The person who introduced the product. Receive a referral fee.
Seller. Instructor. Sells a product and receives money.

wide mortar
forest ridge
#

đź‘‹ Taking over this thread, catching up now

#

In your case, Separate Charges and Transfers is recommended as:

  • App operator: platform that collects payment with a commission
  • Referrer: connected account that receive a referral fee
  • Seller: connected account that receive the funds for their products
wide mortar
#

Single destination is not what I started to say. I asked the question because the support did.
I see, you can't mix and match. Thank you very much.

The way you are talking about separating them, is this what you mean in terms of the way the code is written?
I would like to ask you to check the code.

#

How should I set up to do a separate Transfer in my case?

forest ridge
#

I can't comment on the first two screenshots as no Stripe API is used. For the last screenshot, after payment intent is created, you'd need to collect the payment method details from the customers to complete the payment, then make the transfers. These APIs are correct. Only additional action for collecting payment details from customer will be required between payment intent creation and transfer creations

wide mortar
#

These three screenshots are of the same function, RefEnrollment.
Can you give us an example of doing a transfer?
It doesn't seem to be mentioned in the documentation.

forest ridge
#

In your last screenshot, stripe.transfers.create is the API to do the transfer

#

Essentially, stripe.paymentIntents.create is the API where you create the payment intent, then your frontend will collect the payment method on this payment intent.

After the payment method is collected and payment is successful, then you make stripe.transfers.create request to transfer the funds to each connected account.

wide mortar
#

I don't understand this because the documentation does not provide an example of code implementation for transferring funds to each of the connected accounts.
Can you please provide me with the source code?

#

// Create a PaymentIntent:
const paymentIntent = await stripe.paymentIntents.create({
amount: 100000,
currency: "jpy",
transfer_group: "REF_ORDER",
});
// Create a Transfer to the connected account (later):
const transfer = await stripe.transfers.create({
amount: 7000,
currency: "jpy",
destination: course.instructor.stripe_account_id,
transfer_group: "REF_ORDER",
});
// Create a second Transfer to another connected account (later):
const secondTransfer = await stripe.transfers.create({
amount: 2000,
currency: "jpy",
destination: refuser.stripe_account_id,
transfer_group: "REF_ORDER",
});

#

What else should I write?

forest ridge
#

This is the code where you transfer the funds to connected accounts

    // Create a Transfer to the connected account (later):
    const transfer = await stripe.transfers.create({
      amount: 7000,
      currency: "jpy",
      destination: course.instructor.stripe_account_id,
      transfer_group: "REF_ORDER",
    });
    // Create a second Transfer to another connected account (later):
    const secondTransfer = await stripe.transfers.create({
      amount: 2000,
      currency: "jpy",
      destination: refuser.stripe_account_id,
      transfer_group: "REF_ORDER",
    });
#

It has been implemented in your code

wide mortar
#

How do I collect payment details from my clients?
Can you please provide me with the source code?

forest ridge
wide mortar
#

What number in this document should I refer to?
What more should I add to my source code...?

forest ridge
#

Step 1 to 7 is where you should refer for collecting payments

wide mortar
#

We know that.
Which more information do I need to add to my source code?
What number do I start with in the documentation?

#

And can this be used in Transfers?

forest ridge
#
  1. Start from Step 1 to 7 in payment guide
  2. Create transfers in separate charges and transfer guide:
    // Create a Transfer to the connected account (later):
    const transfer = await stripe.transfers.create({
      amount: 7000,
      currency: "jpy",
      destination: course.instructor.stripe_account_id,
      transfer_group: "REF_ORDER",
    });
    // Create a second Transfer to another connected account (later):
    const secondTransfer = await stripe.transfers.create({
      amount: 2000,
      currency: "jpy",
      destination: refuser.stripe_account_id,
      transfer_group: "REF_ORDER",
    });
wide mortar
#

â‘ Payment Element in the Payment guide
②Separate Charges and Transfers

Can these be combined in one function?

Is integration easy?

I would like to try it anyway.

forest ridge
#

No! They can't be combined in one single function as they serve different stages and purposes

wide mortar
#

(2) Separate Charges and Transfers
I have already created this for all of them, right?

#

Oh really? That is a difficult story.
How can you tell payment and transfer with the same information?

forest ridge
#

In your current code below, payment intent is only created without collecting payment information from the customer. No payment method or anything. The steps to collect payment method and complete payment has been provided in the payment guide

    // Create a PaymentIntent:
    const paymentIntent = await stripe.paymentIntents.create({
      amount: 100000,
      currency: "jpy",
      transfer_group: "REF_ORDER",
    });
#

How can you tell payment and transfer with the same information?
What do you mean? transfer_group is the field where you set the reference of your order, that you can use for transfers

wide mortar
#

I thought you were gathering information from the first and second screenshots.
I have to re-create them.

forest ridge
#

Your first and second screenshots don't use Stripe API and they are your internal functions, so I'm not too sure what they are for

#

Anyway, the steps should be:

  1. Compute the amount to charge to customer in your system
  2. Follow the payment guide to create the payment intent and collect the payment method from customer and complete the payment with Payment Element
  3. Upon successful payment, follow Separate Charges and Charges guide to transfer successful funds to connected accounts
wide mortar
#

No internal functions are used.
We just do the payment on the client side and get the Stripe user ID from the request.
It does not mean that the Stripe API is not used.

forest ridge
#

After payment intent is created in stripe.paymentIntents.create, you can't transfer the funds immediately as the payment is not successful yet

#

You'd need to use the payment guide to collect the payment method from the customer to complete the payment first, then perform stripe.transfers.create later

#

All these can't be done with one single function

#

You don't have funds to transfer if you don't collect customer's payment method to complete the payment

#

stripe.paymentIntents.create is simply telling stripe that "I want to charge $x" and nothing more (no payment method information). To collect money from customer, getting payment method information from the customer will be required with the steps provided in payment guide

wide mortar
#

I see. I'll give it a try for now.
Thanks for supporting me all these years!
I'll be in touch if you need anything else.