#Atish

1 messages · Page 1 of 1 (latest)

royal tigerBOT
round warren
#

👋 happy to help

noble pendant
round warren
noble pendant
round warren
#

that's also a solution

noble pendant
#

Will you please explain the difference and tradeoffs? I am new to stripe and want the best solution

round warren
noble pendant
#
@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

stuck jewel
#

Hey! Taking over for my colleague. Let me catch up.

noble pendant
stuck jewel
noble pendant
#

@stuck jewel Whats the difference between paymentIntent and checkout. Sorry to ask these basic questions, but I am not understanding these things

stuck jewel
#

Stop using the @ mention please, I'm with you.

noble pendant
#

sorry for that

stuck jewel
#

Checkout Session uses behind PaymentIntent APIs. If you are new I advice you to start working with Checkout Sessions

noble pendant
#

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

stuck jewel
noble pendant
#

I tried with the latest version but was not able to create lineItem in latest version

noble pendant