Generate PaymentUIRequest

TerraCore v0

Usage#

Using PaymentUIRequestBuilder to create a request for opening payment page.

We have a pre-built activity in UI module that contains payment method list, transaction detail and transaction result and also handling process payment.

Client can be open the activity from activity or fragment by providing request data and using the provided method which will look something like this

At first, we need prepare payload, Let's using PaymentUIRequestBuilder as below to make request.

Open available methods screen#

In general, Main app couldn't/unknown define what methods will pay for the order. So The SDK will show available methods as default to make user able to choose any method will pay after call start transaction

// prepare payload
val paymentRequestBuilder = PaymentUIRequestBuilder()
.setOrderCode(orderCode = "yourOrderCode")
.setOrderAmount(orderAmount = 1000)
.setMainMethod(PaymentMainMethodRequest.All(amount = 1000)) // All method mean user can using any available method
// Other way
val paymentRequestBuilder = PaymentUIRequestBuilder()
.setOrderCode(orderCode = "yourOrderCode")
.setOrderAmount(orderAmount = 1100)
.setLoyaltyMethod(LoyaltyMethodRequest(point = 100, amount = 100)) // if has loyalty
.setMainMethod(PaymentMainMethodRequest.All(amount = 1000))

Payment directly (without available methods screen)#

There are some cases the main app has defined what exactly methods will pay for the order, that mean main app want to ignore available methods screen. So We has already provided the solution to solved that problem. Let's see below.

// prepare payload
val paymentRequestBuilder = PaymentUIRequestBuilder()
.setOrderCode(orderCode = "yourOrderCode")
.setLoyaltyMethod(LoyaltyMethodRequest(point = 100, amount = 100)) // optional
.setMainMethod(PaymentMainMethodRequest.VNPayGatewayQR(amount = 1000)) // define VNPayGatewayQR method will payment

Refer to PaymentMainMethodRequest class to get all available methods.


Payment methods metadata config(Optional)#

There are some methods must add more config to payment, For example VNPayEWallet. So you must be passing metadata into paymentRequestBuilder before call startUI.

paymentRequestBuilder
.setMetadata(
PaymentV2Request.Metadata(
methods = arrayListOf(
PaymentV2Request.Metadata.MethodConfig.VNPayEWallet(
partnerId = "0918913795",
phone = "0918913795",
name = "Nguyen Van a",
email = "078langha@gmail.com"
)
)
)
)

Notes: refer to PaymentV2Request.Metadata.MethodConfig to see all metadata

Currently MinervaUI only supports following online payment methods:

  • all(amount: Double, metadata: [MethodMetadata]) // Using it if we wanna using built-in UI with full of allowed payment methods interface
  • vnPayQRMMS(amount: Double)
  • vnPayQRGateway(amount: Double)
  • vnPayATMGateway(amount: Double, route: BankRoute)
  • vnPayInternationalCardGateway(amount: Double)
  • vnPayQRReversal(amount: Double)
  • vnPayEWallet(amount: Double, customer: VNPayEWalletCustomer)
  • mobileBanking(amount: Double)
  • momoGateway(amount: Double)
  • sposApp(amount: Double)
  • cod(amount: Double)
  • cash(amount: Double)
  • refInput(amount: Double, subMethodCode: String)
  • pos(amount: Double)
  • bankTransfer(amount: Double)
  • installment(amount: Double)

References#