#Atish
1 messages · Page 1 of 1 (latest)
I need in marketplace model. When the buyer pays some amount, application fee must be deducted and remaining amount needs to be sent to the seller.
What about below option?
that's also a solution
Will you please explain the difference and tradeoffs? I am new to stripe and want the best solution
first you need to choose which type of charges you want to put in place https://stripe.com/docs/connect/charges#types
In my scenario, buyer pays the total cost and we deduct some platform fee and remaining amount is sent to the seller. So I think destination charge will be the best? What you would recommend for such case?
@RestController
class PaymentController {
@Value("\${stripe.apikey}")
lateinit var stripeApiKey: String
@PostMapping("/create-checkout-session")
fun createCheckoutSession(): Map<String, Any> {
Stripe.apiKey = stripeApiKey
val params = mutableMapOf<String, Any>()
val paymentMethodTypes = mutableListOf<String>()
paymentMethodTypes.add("card")
params.put("payment_method_types", paymentMethodTypes)
val lineItems = mutableListOf<Map<String, Any>>()
val lineItem = mutableMapOf<String, Any>()
lineItem.put("name", "Documents")
lineItem.put("amount", 1500)
lineItem.put("currency", "USD")
lineItem.put("quantity", 1)
lineItems.add(lineItem)
params.put("line_items", lineItems)
val paymentIntentData = mutableMapOf<String, Any>()
paymentIntentData.put("application_fee_amount", 100)
val transferData = mutableMapOf<String, Any>()
transferData.put("destination", "acct_1MYl6BRfEAHzyOVs")
paymentIntentData.put("transfer_data", transferData)
params.put("payment_intent_data", paymentIntentData)
params.put("success_url", "https://dashboard.stripe.com/test/connect/accounts/acct_1MYk27ECDV4nt1Rv/activity");
params.put("cancel_url", "https://dashboard.stripe.com/test/connect/accounts/acct_1MYk27ECDV4nt1Rv/activity");
val session = Session.create(params)
val responseData = mutableMapOf<String, Any>()
responseData.put("sessionId", session.id)
return responseData
}
}
I used this code to create a checkout session and its working fine
{
"sessionId": "cs_test_a1AcGtapA2V1FUAFY8R6ztBBdjzp896FCutWv97nJr5eqiUH7w7fdh4j6N"
}
It provides a session Id
In the frontend I need to redirect to this session for the payment. I don't know how to do that. Will you please help @round warren
Hey! Taking over for my colleague. Let me catch up.
Its been 2 days I am trying to integrate stripe for payment. Please help me integrate stripe so I can move to other components of my project.
In my scenario, buyer pays the total cost and we deduct some platform fee and remaining amount is sent to the seller. So I think destination charge will be the best?
Yes agree.
Here is an example of the flow funds:
https://stripe.com/docs/connect/destination-charges#flow-of-funds-app-fee
In the frontend I need to redirect to this session for the payment. I don't know how to do that.
Check this quickstart in order to see how you redirect your customer to that Checkout Session
https://stripe.com/docs/checkout/quickstart?client=next
Or you do a serverside redirection with your Spring boot
https://stripe.com/docs/api/checkout/sessions/object#checkout_session_object-url
@stuck jewel Whats the difference between paymentIntent and checkout. Sorry to ask these basic questions, but I am not understanding these things
Stop using the @ mention please, I'm with you.
sorry for that
The Checkout Session is a Stripe Product that allow you to get a low-code integration to accept payments
https://stripe.com/docs/payments/checkout
meanwhile dealing with the PaymentIntent APIs is for building complex payment flows:
https://stripe.com/docs/payments/payment-intents
Checkout Session uses behind PaymentIntent APIs. If you are new I advice you to start working with Checkout Sessions
So I was able to create a checkout session, I need to redirect to that session and we can do a payment right?
Let me try that, If I won't be able to do it, I will get back here
I don't have url field in session, is it because I am using some lower version of stripe-java?
My version: com.stripe:stripe-java:10.0.2
Yes. as this is a new integration, use the latest Stripe Java SDK version 22.8.0
https://github.com/stripe/stripe-java
I tried with the latest version but was not able to create lineItem in latest version
Can I get sample code like this for the lastest version?