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