Android SDK
PaymobSDK
Usage
imports
import com.paymob.paymob_sdk.PaymobSdk
import com.paymob.paymob_sdk.ui.PaymobSdkListener
Implement PaymobSdkListener Interface
class MainActivity : AppCompatActivity(), PaymobSdkListener {
override fun onCreate(savedInstanceState: Bundle?) {...}
override fun onSuccess() {
//If the Payment is successful
}
override fun onFailure() {
//If The Payment is declined
}
}
then create a PaymobSdk instance using PaymobSdk.Builder()
val paymobsdk = PaymobSdk.Builder(
context = this@MainActivity,
clientSecret = "CLIENT_SECRET",//Place Client Secret here
publicKey = "PUBLIC_KEY",//Place Public Key here
paymobSdkListener = this,
maskedPan = "xxxx-xxxx-xxxx-2346",//Optional Field if you have a saved card
savedCardToken = "{SAVED_CARD_TOKEN}"//Optional Field if you have a saved card
)
.build()
You can set the sdk buttons color and buttons text color using this builder object for example:
val paymobsdk = PaymobSdk.Builder(
context = this@MainActivity,
clientSecret = "CLIENT_SECRET",//Place Client Secret here
publicKey = "PUBLIC_KEY",//Place Public Key here
paymobSdkListener = this,
maskedPan = "xxxx-xxxx-xxxx-2346",//Optional Field if you have a saved card
savedCardToken = "{SAVED_CARD_TOKEN}"//Optional Field if you have a saved card
)
.setButtonBackgroundColor(Color.BLACK)//changes the color of button backgrounds throughout the SDK, and set by default to black
.setButtonTextColor(Color.WHITE)//changes the color of button texts throughout the SDK, and set by default to white
.build()
then you can start the sdk by calling
sdk.start()
Updated 7 months ago