Skip to content

Commit 8a18391

Browse files
committed
Changed from masterpass to checkout api
1 parent 2f9ad08 commit 8a18391

File tree

7 files changed

+55
-14
lines changed

7 files changed

+55
-14
lines changed

.idea/gradle.xml

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/jarRepositories.xml

Lines changed: 25 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/src/main/java/com/furahitechpay/selcom/MainActivity.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import androidx.appcompat.app.AppCompatActivity
44
import android.os.Bundle
55
import com.furahitechpay.furahitechpay.FurahitechPay
66
import com.furahitechpay.furahitechpay.FurahitechPay.Companion.PAYMENT_ALL
7+
import com.furahitechpay.furahitechpay.FurahitechPay.Companion.PAYMENT_MOBILE
78
import com.furahitechpay.furahitechpay.callback.PayCallback
89
import com.furahitechpay.furahitechpay.model.BillingInfo
910
import com.furahitechpay.furahitechpay.model.PaymentRequest
@@ -37,11 +38,11 @@ class MainActivity : AppCompatActivity() {
3738
userLastName = "Kileha"
3839
)
3940

40-
furahitechPay.defaultPhoneForCard = "255712000000"
41+
furahitechPay.defaultPhoneForCard = "255712XXXXXX"
4142
furahitechPay.activity = this
4243
furahitechPay.isCardEnglish = true
4344
furahitechPay.isMobileEnglish = false
44-
furahitechPay.paymentType = PAYMENT_ALL
45+
furahitechPay.paymentType = PAYMENT_MOBILE
4546
furahitechPay.paymentRequest = request
4647
furahitechPay.paymentBilling = billing
4748
furahitechPay.authToken = "dummy"

furahitechpay/src/main/java/com/furahitechpay/furahitechpay/card/CardFragment.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ class CardFragment : BaseFragment(), CardView, PayCallback{
329329
override fun onSuccess(tokenResponse: TokenResponse) {
330330
showProgressVisible(false)
331331
val intent = Intent(activity, CardPaymentRedirection::class.java)
332-
intent.putExtra(REDIRECTION_URL, Base64.decode(tokenResponse.instructions, Base64.DEFAULT).decodeToString())
332+
intent.putExtra(REDIRECTION_URL, Base64.decode(tokenResponse.paymentUrl, Base64.DEFAULT).decodeToString())
333333
dismissDialog()
334334
startActivity(intent)
335335
}

furahitechpay/src/main/java/com/furahitechpay/furahitechpay/mobile/MobileFragment.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,11 +260,11 @@ class MobileFragment : BaseFragment(), MobileView, PayCallback {
260260
mainHolder.visibility = VISIBLE
261261
tokenDetailsHolder.visibility = VISIBLE
262262
val instruction: Spanned = if(furahitechPay.isMobileEnglish) Html.fromHtml(
263-
String.format(response.instructions,
263+
String.format(response.instructions?.infoEnglish!!,
264264
"Which is ${response.paymentToken}", "Which is $selectedPrice"
265265
) + "<br/> Your payment token is <big><b> ${response.paymentToken}</b></big>"
266266
) else Html.fromHtml(
267-
String.format(response.instructions,
267+
String.format(response.instructions?.infoSwahili!!,
268268
"Ambayo ni ${response.paymentToken}", "Ambacho ni $selectedPrice"
269269
) + "<br/> Kumbukumbu namba yako ya malipo ni <big><b> ${response.paymentToken}</b></big>"
270270
)

furahitechpay/src/main/java/com/furahitechpay/furahitechpay/mobile/MobilePresenter.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,20 +70,20 @@ class MobilePresenter(view: MobileView) : BasePresenter<MobileView>(view) {
7070
"payment_duration" to paymentRequest.duration,
7171
"payment_email" to billingInfo.userEmail, "payment_amount" to paymentRequest.amount,
7272
"payment_phone" to billingInfo.userPhone, "payment_product" to paymentRequest.productId,
73-
"payment_remarks" to paymentRequest.remarks, "mno" to mno)
73+
"payment_remarks" to paymentRequest.remarks, "payment_name" to "${billingInfo.userFirstName} ${billingInfo.userLastName}")
7474
if(paymentRequest.orderId.isNotEmpty()){
7575
paymentData = paymentData.plus("order_id" to paymentRequest.orderId)
7676
}
7777
GlobalScope.launch {
7878
val (_, _, result) = Fuel
79-
.post("https://apis.furahitech.co.tz/core/v1/payment/auth/mobile", paymentData)
79+
.post("https://api.furahipay.co.tz/v2/payment/create", paymentData)
8080
.header(mapOf("x-api-key" to token))
8181
.awaitObjectResponseResult(TokenResponse.TokenResponseSerializer())
8282
result.fold(
8383
{ data -> view.runOnUiThread(Runnable {
8484
handleButtonEnabling(true)
8585
view.showPaymentResponse(data)
86-
data.instructions = ""
86+
data.instructions = null
8787
payCallback.onSuccess(data)
8888
})},
8989
{ error -> launch(Dispatchers.Main) {payCallback.onFailre(error.message!!) }}

furahitechpay/src/main/java/com/furahitechpay/furahitechpay/model/TokenResponse.kt

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,28 @@ import com.github.kittinunf.fuel.core.ResponseDeserializable
44
import com.google.gson.Gson
55
import com.google.gson.annotations.SerializedName
66

7-
data class TokenResponse (var error: Boolean,
8-
@SerializedName("payment_orderId") var paymentOrderId: String,
9-
@SerializedName("payment_phone") var paymentPhone: String,
10-
@SerializedName("payment_qr") var paymentQr: String,
7+
data class TokenResponse (@SerializedName("request_code") var requestCode: Int,
8+
@SerializedName("request_status") var requestStatus: String,
9+
@SerializedName("request_message") var requestMessage: String,
1110
@SerializedName("payment_status") var paymentStatus: String,
1211
@SerializedName("payment_token") var paymentToken: String,
13-
@SerializedName("payment_instruction") var instructions: String){
12+
@SerializedName("payment_orderId") var paymentOrderId: String,
13+
@SerializedName("payment_url") var paymentUrl: String,
14+
@SerializedName("payment_qr") var paymentQr: String,
15+
@SerializedName("payment_instruction") var instructions: PaymentInstruction?,
16+
var error: Boolean = requestStatus == "SUCCESS"
17+
){
1418
class TokenResponseSerializer : ResponseDeserializable<TokenResponse> {
1519
override fun deserialize(content: String) = Gson().fromJson(content, TokenResponse::class.java)!!
1620
}
1721
}
1822

23+
data class PaymentInstruction(@SerializedName("info_hId") var hoverActionId: String,
24+
@SerializedName("info_swa") var infoSwahili: String,
25+
@SerializedName("info_en") var infoEnglish: String){
26+
27+
class PaymentInstructionSerializer : ResponseDeserializable<PaymentInstruction> {
28+
override fun deserialize(content: String) = Gson().fromJson(content, PaymentInstruction::class.java)!!
29+
}
30+
}
31+

0 commit comments

Comments
 (0)