bKash Payment Integration with App
Monotosh Roy
Head of Enterprise Application & Management @ BRAC Bank PLC | Business Analysis, Solution Architect, Project Implementation
Integrating Bkash payment system into an Android application requires a basic understanding of the Bkash API and Android development. Here are the steps to integrate Bkash in an Android app:
1. Sign up for Bkash Developer Account: Before integrating Bkash into your Android app, you'll need to sign up for a Bkash Developer account. You can sign up for the developer account at the following link: https://developer.bkash.com/
2. Get API Key: Once you have signed up for the developer account, you'll need to get an API Key to access the Bkash APIs. Login to your Bkash Developer account and follow the instructions to create a new app and get an API Key.
3. Integrating Bkash API in Android: Once you have the API Key, you can integrate the Bkash API in your Android app. To do this, you can use Retrofit, a popular HTTP client for Android, to make API calls to the Bkash servers
4. Create Payment Request: To create a payment request, you'll need to pass the following information to the Bkash API:
Amount: The amount that needs to be paid
Invoice Number: A unique identifier for the payment
Callback URL: The URL that will be called when the payment is complete
Intent URL: The URL that will be opened in the Bkash app when the user clicks on the payment link.
5. Verify Payment: After the payment has been made, you'll need to verify the payment by calling the Bkash API to check if the payment was successful.
This is a high-level overview of the steps involved in integrating Bkash into an Android app. You can find more detailed information and code examples in the Bkash Developer documentation.
I am using retrofit2 Lib. Please find the belwo link for details : https://square.github.io/retrofit/
import retrofit2.Call;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.POST;
public class BkashApiClient {
??private static final String BASE_URL = "https://checkout.bka.sh/v1.2.0-beta/checkout/";
??private static BkashApiClient instance;
??private BkashApiService bkashApiService;
??private BkashApiClient() {
????Retrofit retrofit = new Retrofit.Builder()
????????.baseUrl(BASE_URL)
????????.addConverterFactory(GsonConverterFactory.create())
领英推荐
????????.build();
????bkashApiService = retrofit.create(BkashApiService.class);
??}
??public static BkashApiClient getInstance() {
????if (instance == null) {
??????instance = new BkashApiClient();
????}
????return instance;
??}
??public BkashApiService getBkashApiService() {
????return bkashApiService;
??}
??public interface BkashApiService {
????@FormUrlEncoded
????@POST("payment/submit")
????Call<PaymentResponse> submitPayment(
????????@Field("amount") String amount,
????????@Field("invoiceNumber") String invoiceNumber,
????????@Field("callbackUrl") String callbackUrl,
????????@Field("intentUrl") String intentUrl
????);
????@FormUrlEncoded
????@POST("payment/verify")
????Call<PaymentVerificationResponse> verifyPayment(
????????@Field("token") String token
????);
??}
}
This code uses Retrofit to create an instance of the BkashApiService interface, which defines the API calls that can be made to the Bkash server. The submitPayment method is used to create a payment request, and the verifyPayment method is used to verify a payment.
To use this code in your Android app, you'll need to pass in the required information (e.g. amount, invoice number, callback URL, intent URL) and make the API call using Retrofit. You can find more detailed information and code examples in the Bkash Developer documentation(https://developer.bka.sh/)
CS Student @ IUT | Cybersecurity Enthusiast | Spring Boot Developer | Exploring CS Domains
5 个月Thank you so much , sir . This is life saving for me.