#agarfuin_api

1 messages ยท Page 1 of 1 (latest)

hollow nightBOT
#

๐Ÿ‘‹ 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/1282794323124944981

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

thin flare
#

There are 2 customers sections in the dashboard one is general and the other one is inside a Connected Account instance I can retrieve the general one from api but cant do the same with Connected Accounts one what is the difference between two?

naive wave
#

The difference is which account the Customer objects exist on. Dashboard > Customers are customer objects on your own account and Dashboard > Connected Accounts > Customers would be customers that are on that specific connected account.

#

Can you tell me more about what you are building what you are trying to do here with the customers on each account?

thin flare
#

Im trying to create a education platform like Udemy where people can sign up and buy/sell educational contents

#
public ResponseEntity<?> createCharge(ChargeRequest chargeRequest) throws Exception {

    String myCustomerID = chargeRequest.getVendorCustomerID();
    String vendorCustomerIDToBeCharged = chargeRequest.getCustomerUserID();

    Map<String, Object> params = new HashMap<>();
    params.put("customer", myCustomerID);
    params.put("type", "card");

    String customersDefaultPaymentMethodID = PaymentMethod.list(params).getData().get(0).getId();

    System.out.println("Customer: " + myCustomerID);
    Double doubleChargeValue = chargeRequest.getChargeValue();
    Integer chargeValue = Math.multiplyExact(doubleChargeValue.intValue(), 100);

    Map<String, Object> chargeParams = new HashMap<>();

    chargeParams.put("customer", myCustomerID);
    chargeParams.put("description", chargeRequest.getChargeDescription());

    chargeParams.put("amount", chargeValue.toString());
    chargeParams.put("currency", chargeRequest.getCurrency());
    chargeParams.put("confirm", chargeRequest.getConfirmationStatus());


    chargeParams.put("payment_method", customersDefaultPaymentMethodID);

    PaymentIntent paymentIntent = new PaymentIntent();
    RequestOptions requestOptions;
    // Direct charges
    if (vendorCustomerIDToBeCharged.length() > 0) {
      requestOptions =
    RequestOptions.builder().setStripeAccount(vendorCustomerIDToBeCharged).build();


      Long myPlatformPercentage = Math.multiplyFull(chargeValue, (25 / 100));

      paymentIntent.setApplicationFeeAmount(myPlatformPercentage);
      paymentIntent = PaymentIntent.create(chargeParams, requestOptions);

    } else {
      paymentIntent = PaymentIntent.create(chargeParams);
    }

    System.out.println("Charge: " + chargeParams);

    return new ResponseEntity<>(paymentIntent.toJson(), HttpStatus.OK);
  }
#

I am trying to create charges and when i pass connected account id inside my request body i get errors but otherwise there are no issues.

naive wave
#

Is the error something about one of the objects not existing on your account?

thin flare
#

yes it says there is no such customer

naive wave
#

Gotcha. So what you are running in to is that in Stripe objects only exist on the account that they were created on. If you are getting an error when trying to retrieve the customer when passing the connected account's ID, then it sounds like that Customer only exists on your platform account. There are workarounds but that depends on your exact setup.

thin flare
#

here is the response body:

{
    "message: ": "No such customer: 'cus_QonQOlOJl8Hezq'; code: resource_missing; request-id: req_O1ML4ZVFkhVEAm",
    "timestamp: ": "2024-09-09T23:20:28.577156"
}
naive wave
#

Taking a step back, you are using our direct charges flow here, which is typically only recommended when your connect users have full access to their connect dashboard (as opposed to our express dashboard or no access at all). Are you using connected accounts with their own full dashboard?

thin flare
#

no i dont

#

do you have any recommendation what should i do?

naive wave
#

Actually for that req_O1ML4ZVFkhVEAm call, I see that it was made on acct_1OQ8ZpCb1igCzzWK which isn't connected to the account that owns cus_QonQOlOJl8Hezq. I think I may have jumped to some conclusions.
Can you tell me what your current plan is for your connect platform? Like from this page what type of dashboard access and charge type are you planning on using? https://docs.stripe.com/connect/design-an-integration

thin flare
#

im planning to use direct charges where money being transacted to the user and my platform will collect an application fee out of it

naive wave
#

Gotcha. This guide shows how to clone payment methods down to your connected accounts. So you can use that flow to copy the info from your platform account before charging them. That being said, as I mentioned before, this flow is typically not reccommended unless your users have their own full Stripe account with Dashboard access. It can be very difficult to handle things like disputes and refunds if you are doing the direct charges flow with accounts that have no dashboard access or access to our express dashboard.
https://docs.stripe.com/connect/direct-charges-multiple-accounts#clone-and-create-direct-charges

Save payment details on your platform and clone them to connected accounts for making direct charges.

thin flare
#

Understand. Is it better if every user in my own platform to also create their stripe account?

hollow nightBOT
wispy cradle
#

๐Ÿ‘‹ Stepping in for my teammate

thin flare
#

Sure go ahead

wispy cradle
#

Your platform should create a connected account for every person who will sell their educational classes

#

The buyers/customers of these educational classes should not need a connected account. They will be represented by Customer objects on Stripe instead

thin flare
#

we are talking about PaidCustomer object in java right?

#

I mean for ex. PaidCustomer.create() creates the customer object etc.

wispy cradle
thin flare
#

Oh ok my bad thats what im refering to as well

#

I'm already doing this in my platform so how can i create application fees in charges?

wispy cradle
#

Just to be clear, you're making Direct charges?

thin flare
#

yes

#

this is my method for creating direct charges:

public ResponseEntity<?> createCharge(ChargeRequest chargeRequest) throws Exception {

    String myCustomerID = chargeRequest.getVendorCustomerID();
    String vendorCustomerIDToBeCharged = chargeRequest.getCustomerUserID();

    Map<String, Object> params = new HashMap<>();
    params.put("customer", myCustomerID);
    params.put("type", "card");

    String customersDefaultPaymentMethodID = PaymentMethod.list(params).getData().get(0).getId();

    Double doubleChargeValue = chargeRequest.getChargeValue();
    Integer chargeValue = Math.multiplyExact(doubleChargeValue.intValue(), 100);

    Map<String, Object> chargeParams = new HashMap<>();

    chargeParams.put("customer", myCustomerID);
    chargeParams.put("description", chargeRequest.getChargeDescription());
    chargeParams.put("amount", chargeValue.toString());
    chargeParams.put("currency", chargeRequest.getCurrency());
    chargeParams.put("confirm", chargeRequest.getConfirmationStatus());


    chargeParams.put("payment_method", customersDefaultPaymentMethodID);

    PaymentIntent paymentIntent = new PaymentIntent();
    RequestOptions requestOptions;
    // Direct charges
    if (vendorCustomerIDToBeCharged.length() > 0) {

      requestOptions =
          RequestOptions.builder().setStripeAccount(vendorCustomerIDToBeCharged).build();

      Long myPlatformPercentage = Math.round(chargeValue * 0.25);

      paymentIntent.setApplicationFeeAmount(myPlatformPercentage);
      paymentIntent = PaymentIntent.create(chargeParams, requestOptions);

    } else {
      paymentIntent = PaymentIntent.create(chargeParams);
    }

    return new ResponseEntity<>(paymentIntent.toJson(), HttpStatus.OK);
  }
#

when i pass this request body:

{
    "customerUserID": "acct_1Px9KKCeAP4grCrH",
    "vendorCustomerID": "cus_QZof3amGuLxehL",
    "chargeDescription": "test desc",
    "chargeValue": "100",
    "currency": "USD",
    "confirmationStatus": "true",
    "isRecurring": false
}

i get this response:

{
    "message: ": "No such PaymentMethod: 'card_1PknNFCb1igCzzWKpzycEzea'; OAuth key or Stripe-Account header was used but API request was provided with a platform-owned payment method ID. Please ensure that the provided payment method matches the specified account.; code: resource_missing; request-id: req_G2e2Ap4DJFH1FC",
    "timestamp: ": "2024-09-09T23:53:34.273601"
}
wispy cradle
#

Right, okay, this gets back to the issue of where these objects are saved

#

The card you're passing (payment_method: "card_1PknNFCb1igCzzWKpzycEzea" in your request) is stored on the platform account, not the connected account. When using Direct charges, the customer and payment method need to be on the connected account

thin flare
#

I am getting the payment method from the customer id that I'm passing through the request body. So the payment method is a card assigned to a customer. Is this wrong?

#

So the card "card_1PknNFCb1igCzzWKpzycEzea" has to be assigned to this customer "cus_QZof3amGuLxehL"

wispy cradle
#

Customer cus_QZof3amGuLxehL exists on the platform account though

thin flare
#

hmm ok understand

#

how can i create a customer and payment method on the connected account then?

thin flare
#

alright i will check this out

#

thanks