Stripe integration with REST

Hi,
I’m implementing a Stripe integration with REST API on an Android app. This is my logic according to the documentation here:

 override suspend fun proceedPayment(
        clientPaymentInfo: ClientPaymentInfo,
        totalAmount: Double,
        dateToPayProvider: String,
        serviceProviderId: Long,
        eventId: Long,
    ): Flow<NetworkResult<String>> = flow {
        emit(NetworkResult.loading(data = null))

        val result = safeApiCall(
            call = {
                //step 1 : Client app sends credit card data to the Stripe servers using the Stripe SDK.
                val cardToken = stripeDatasource.createCardToken(clientPaymentInfo)

                //step 2 & 3 : I retrieve the one-time token in the cardToken.id and I send charge to the 
                Backendless servers using the POST /Stripe/charge route.
                val backendlessCharge = stripeDatasource.sendCharge(
                    StripeChargeRequest(
                        source = cardToken.id,
                        amount = 150.0,//TODO totalAmount,
                        currency = CurrencyEuro
                    )
                )

               //after steps 4 & 5 & 6 I retrieve the transactionId here
                val transactionId = backendlessCharge.id

                //step 7 : I subscribe to the stripe messaging channel
                val subscription = messagingDatasource.subscribeChannel(
                    channelName = StripeMessagingChannelName,
                    request = SubscriptionRequest(null)
                )


                   //step 7 : I retrieve messages from the stripe messaging channel
                val response = messagingDatasource.retrieveMessages(
                    channelName = StripeMessagingChannelName,
                    subscriptionId = subscription.subscriptionId//TODO transactionId
                )
                //if my messages are not empty, I get the last message received and with the status (I'm not yet sure of the "succeed" string) I create an order in my app.
                if (response.messages.isNotEmpty()) {
                    val status = response.messages.sortedByDescending { it.publishedAt }.last().data

                    if (status == "succeed") {
                        datasource.createOrder(
                            Order(
                                id = 0L,
                                orderDate = getTodayDate().convertToStringForBackendless(),
                                amount = totalAmount,
                                hasInsurance = false,
                                hasLitige = false,
                                isPaid = true,
                                isPaymentSent = false,
                                linkedClientId = TokenManager.getUserId(),
                                linkedEventId = eventId,
                                linkedProviderId = serviceProviderId,
                                step = StatusOrderEnum.TO_ACCEPT.status
                            )
                        )
                        //TODO urgent plan the payment for the client to a specific date (no made it only when the provider accept the mission
                    }
                    NetworkResult.success(status)//TODO debago urgent be sure that it will be the good status to show that payment is succeed

                } else {
                    NetworkResult.error(data = "", message = "Error")

                }
            },
            errorMessage = "Payment Error"
        )
        emit(result)

    }

The issue is that when I’m in the step 3, to send Charge, I try to use the way /services/Stripe/charge like in the cloud in backendless. This doesn’t work.
My body:

{
  "token":"myToken",
  "amount":1000
}

In the cloud I have this error:
400 - Invalid currency: €. Stripe currently supports these currencies: usd, aed, afn, all, amd, ang, aoa, ars, aud, awg, azn, bam, bbd, bdt, bgn, bhd, bif, bmd, bnd, bob, brl, bsd, bwp, byn, bzd, cad, cdf, chf, clp, cny, cop, crc, cve, czk, djf, dkk, dop, dzd, egp, etb, eur, fjd, fkp, gbp, gel, gip, gmd, gnf, gtq, gyd, hkd, hnl, hrk, htg, huf, idr, ils, inr, isk, jmd, jod, jpy, kes, kgs, khr, kmf, krw, kwd, kyd, kzt, lak, lbp, lkr, lrd, lsl, mad, mdl, mga, mkd, mmk, mnt, mop, mro, mur, mvr, mwk, mxn, myr, mzn, nad, ngn, nio, nok, npr, nzd, omr, pab, pen, pgk, php, pkr, pln, pyg, qar, ron, rsd, rub, rwf, sar, sbd, scr, sek, sgd, shp, sle, sos, srd, std, szl, thb, tjs, tnd, top, try, ttd, twd, tzs, uah, ugx, uyu, uzs, vnd, vuv, wst, xaf, xcd, xof, xpf, yer, zar, zmw, usdc, btn, ghs, eek, lvl, svc, vef, ltl, sll

So do I need a currency field in my body? Could you try the step of the documentation to be sure it’s always ok?
Other question : In the subscription on the messaging/stripe/subscribe I receive a subscriptionId. Do I need to send this subscriptionId when I want to retrieveMessage or only the transactionId?

Thanks you for your response

Please, make clear one thing for me. Do you use our integration plugin or do you implement your own solution?
Our solution contains the config, and currency comes from it.

As for the error, I see you add the currency field, but ‘€’ should be changed to ‘eur’ I assume.

In the subscription on the messaging/stripe/subscribe I receive a subscriptionId. Do I need to send this subscriptionId when I want to retrieveMessage or only the transactionId?

Could you clarify what do mean here?

Regards, DIma.

Hi
I use the integration plugin
As it didn’t worked, in my code is true that I tried to use the stripe implementation for charge (with the currency but do not take it into account (but my question is about your integration plugin 'cause I tried to use it in postman and in the cloud directly in backendless and it’s in cloud that I had the currency error message with the body in the question)

For the subscriptionId, in the documentation to integrate stripe to backendless it’s said that

Additionally, the plugin implementation sends out the payload of the event through Backendless Real-Time Messaging. To receive the messages, the client application must subscribe to the stripe messaging channel. To receive a message for a specific transaction, the following selector must be used: id = 'transaction id' For example, id = 'ch_1Cmms9I56A1133zjexAcwndb'

And in the documentation of backendless, for messaging it’s said that

With subscriptionId the parameter. I would know where I need to precise the transactionId to retrieve message and if transactionId replace subscriptionId for the retrieveMessage api call.
Thanks you

I’ve created a ticket for our developer. He will answer when investigate your question.

Hello @Dima Have you any update about this topic?

Hello @Indevers!

Our team is working on a solution and we’ll update you in this thread as soon as there’s new information.

Regards,
Alexander

Hello @Alexander_Pavelko this question is about almost three month, do you have any update about this or alternative to use stripe with backendless? Thanks you

Hello @Indevers

Unfortunately, the ticket is still in open status. I will check with the team to see if they will be able to take care of this ticket soon.

Regards,
Inna

Ok thanks you for your response @Inna_Shkolnaya but If I understand, by waiting for your response I don’t have any other way to accept payment with backendless and stripe? I saw that I need a backend to do this, do you have another solution for me for the moment?

We’ve escalated this task. Will post here about the result – when smb. start working on it.

Hello @Indevers,

It looks like when you installed the service, you specified the wrong configuration. On the page with the list of services, select your service, then in the toolbar at the top, click on the gear icon. The popup will contain your service’s configuration (secret keys and so on). There will also be a field for the currency configuration. You will need to replace the euro sign € with the code - eur.

1 Like

You need transactionId only.
Please try it and if you have any problems, let us know. Thanks.

Ok Thanks you @stanislaw.grin
For the currency it’s ok. Now for the transaction Id I have an issue.
I subscribe with a selector like this (id is the transactionId)

Then I retrieve message with this

But I have an empty message. I repeat this call 20 times, with a delay of 500ms, but I always have the messages empty. So I never retrieve the status of the payment process.

However, When I launch the charge I retrieve the status “succeeded”

Did I done something wrong ? Why this my retrieve message always give me an empty messages list?
Can I just get the status after the charge to know to the status of the payment process?

Thanks you for you response !

Hello @Indevers,

sorry for the delayed response. We need some time to investigate this issue.
Thank you for your patience!

Hello @Alexandra_Gnimadi!

I apologize for the extended wait. I’m trying to reproduce your issue, but after subscribing to the channel and performing a transaction, I’m able to receive a message.


One way I was able to reproduce your problem is by disabling the webhook in Stripe, which results in an empty array being returned. Please make sure that this webhook is added and its status is set to “Enabled,” and also ensure that all necessary events are being listened to.

If the webhook is configured correctly and enabled, please let me know. Additionally, if there are any other details you think might help in resolving this issue, please share them as well.

Regards,
Alexander