SSLcommerz payment gateway integration (Sandbox)

Step 1 : Go to this link https://developer.sslcommerz.com/registration/ and register .

Step 2 : Login account with https://sandbox.sslcommerz.com/manage/

Step 3 : Go to console and click developer tab . you can now download android sdk file . You will find .aar file . Now follow the steps . You also get a manual but it’s not enough for android studio . or Download it from here : ANDROID_190617

 

  1. Place the ssl-payment-sdk-v4.aar file in your project’s lib folder.
  2. To include the SDK file go to File > New > New Module… > import .JAR/.AAR package > file name (browse the ssl-payment-sdk-v4.aar file) and press enter.
  3. Right click on your Android Studio Project and go to Open Module Settings. Click on your Application Name and then click Press + sign and go to Module Dependency. Click on ssl-payment-sdk-v4 and click ok.

4.     Include the following library to your app label gradel. If your already include any library from the following list , then don’t need to again that particular library. 

5.  compile project(‘:ssl-payment-sdk-v4’) and sync in gradle file project app folder .



 MandatoryFieldModel mandatoryFieldModel = new MandatoryFieldModel("testbox","qwerty","10", "1012", CurrencyType.BDT, SdkType.TESTBOX, SdkCategory.BANK_LIST);/*Mandatory Field For Specific Bank Page*/
 MandatoryFieldModel mandatoryFieldModel = new MandatoryFieldModel("testbox","qwerty","10", "1012", CurrencyType.BDT, SdkType.TESTBOX, SdkCategory.BANK_PAGE, BankName.DBBL_VISA);
 
 /*Optional Fields*/
 CustomerFieldModel customerFieldModel = new CustomerFieldModel("Customer Name","Customer Email Address", "Customer Address 1", "Customer Address 2", "Customer City", "Customer State", "Customer Post Code", "Customer Country", " Customer Phone", "Customer Fax");
 ShippingFieldModel shippingFieldModel = new ShippingFieldModel("Shipping Name", "Shipping Address 1","Shipping Address 2","Shipping City", "Shipping State", "Shipping Post Code", "Shipping Country" );
 AdditionalFieldModel additionalFieldModel = new AdditionalFieldModel();
 additionalFieldModel.setValueA("Value Option 1");
 additionalFieldModel.setValueB("Value Option 1");
 additionalFieldModel.setValueC("Value Option 1");
 additionalFieldModel.setValueD("Value Option 1");
 
 /*Call for the payment*/
 PayUsingSSLCommerz.getInstance().setData(this,mandatoryFieldModel,customerFieldModel,shippingFieldModel,additionalFieldModel,new OnPaymentResultListener() {
 @Override
 public void transactionSuccess(TransactionInfo transactionInfo) {
 // If payment is success and risk label is 0.
 if(transactionInfo.getRiskLevel().equals("0")) {
             Log.d(TAG, "Transaction Successfully completed");
         }
 // Payment is success but payment is not complete yet. Card on hold now.
 else{
             Log.d(TAG, "Transaction in risk. Risk Title : "+transactionInfo.getRiskTitle().toString());
         }
     }
 
 @Override
 public void transactionFail(TransactionInfo transactionInfo) {
 // Transaction failed
 Log.e(TAG, "Transaction Fail");
     }
 
 @Override
 public void error(int errorCode) {
 switch (errorCode){
 // Your provides information is not valid.
 case ErrorKeys.USER_INPUT_ERROR :
                 Log.e(TAG, "User Input Error" );break;
 // Internet is not connected.
 case ErrorKeys.INTERNET_CONNECTION_ERROR :
                 Log.e(TAG, "Internet Connection Error" );break;
 // Server is not giving valid data.
 case ErrorKeys.DATA_PARSING_ERROR :
                 Log.e(TAG, "Data Parsing Error" );break;
 // User press back button or canceled the transaction.
 case ErrorKeys.CANCEL_TRANSACTION_ERROR :
                 Log.e(TAG, "User Cancel The Transaction" );break;
 // Server is not responding.
 case ErrorKeys.SERVER_ERROR :
                 Log.e(TAG, "Server Error" );break;
 // For some reason network is not responding
 case ErrorKeys.NETWORK_ERROR :
                 Log.e(TAG, "Network Error" );break;
         }
     }
 });



Download project


	

EOFException: End of input at line 1 column 1 path $ 

EOFException: End of input at line 1 column 1 path $  or Retofit2 error java.io.EOFException: End of input at line 1 column 1

Reasons:

This error message indicates a completely empty response, not the one you have indicated. If it’s an error you should be using errorBody() to get access to the data. If this is a normal response then you should yell at your server for returning no content when content was expected. But if you cannot change the server, consider using a converter to adapt empty bodies into null using something like this: #1554 (comment)

 

 

Solution : Check api response . Change api and return something and that will solve the problem 🙂

 

 

Retrofit take List data as POST request body in android rest api call

Step 1 : 

create a request model that will take request body data

package com.adn.api.order;

import com.adn.Model.DBModel.AddToCartProductModel;
import com.google.gson.annotations.SerializedName;

import java.util.ArrayList;

public class Order {

@SerializedName("customer_id")
String customer_id;
@SerializedName("firstname")
String firstname;
@SerializedName("lastname")
String lastname;
@SerializedName("email")
String email;
@SerializedName("products")
ArrayList<AddToCartProductModel> products;
@SerializedName("telephone")
String telephone;
@SerializedName("postcode")
String postcode;
@SerializedName("payment_method")
String payment_method;
@SerializedName("total_price")
String total_price;
@SerializedName("address")
String address;
@SerializedName("city")
String city;
@SerializedName("order_status")
String order_status;

//Don't forget to create/generate the getter and setter]

public Order(String customer_id, String firstname, String lastname, String email, ArrayList<AddToCartProductModel> products, String telephone, String postcode, String payment_method, String total_price, String address, String city, String order_status) {
this.customer_id = customer_id;
this.firstname = firstname;
this.lastname = lastname;
this.email = email;
this.products = products;
this.telephone = telephone;
this.postcode = postcode;
this.payment_method = payment_method;
this.total_price = total_price;
this.address = address;
this.city = city;
this.order_status = order_status;
}

public String getCustomer_id() {
return customer_id;
}

public void setCustomer_id(String customer_id) {
this.customer_id = customer_id;
}

public String getFirstname() {
return firstname;
}

public void setFirstname(String firstname) {
this.firstname = firstname;
}

public String getLastname() {
return lastname;
}

public void setLastname(String lastname) {
this.lastname = lastname;
}

public String getEmail() {
return email;
}

public void setEmail(String email) {
this.email = email;
}

public ArrayList<AddToCartProductModel> getProducts() {
return products;
}

public void setProducts(ArrayList<AddToCartProductModel> products) {
this.products = products;
}

public String getTelephone() {
return telephone;
}

public void setTelephone(String telephone) {
this.telephone = telephone;
}

public String getPostcode() {
return postcode;
}

public void setPostcode(String postcode) {
this.postcode = postcode;
}

public String getPayment_method() {
return payment_method;
}

public void setPayment_method(String payment_method) {
this.payment_method = payment_method;
}

public String getTotal_price() {
return total_price;
}

public void setTotal_price(String total_price) {
this.total_price = total_price;
}

public String getAddress() {
return address;
}

public void setAddress(String address) {
this.address = address;
}

public String getCity() {
return city;
}

public void setCity(String city) {
this.city = city;
}

public String getOrder_status() {
return order_status;
}

public void setOrder_status(String order_status) {
this.order_status = order_status;
}

@Override
public String toString() {
return "Order{" +
"customer_id='" + customer_id + '\'' +
", firstname='" + firstname + '\'' +
", lastname='" + lastname + '\'' +
", email='" + email + '\'' +
", products=" + products +
", telephone='" + telephone + '\'' +
", postcode='" + postcode + '\'' +
", payment_method='" + payment_method + '\'' +
", total_price='" + total_price + '\'' +
", address='" + address + '\'' +
", city='" + city + '\'' +
", order_status='" + order_status + '\'' +
'}';
}
}

Step 2 :

Add GSON on retrofit client call


package com.adn.api;

import com.adn.interfaces.URLs;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

import java.util.concurrent.TimeUnit;

import okhttp3.OkHttpClient;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

public class RetrofitClient implements URLs {
private static Retrofit getRetrofitInstance() {

Gson gson = new GsonBuilder()
.setLenient()
.create();

final OkHttpClient okHttpClient = new OkHttpClient.Builder()
.readTimeout(30, TimeUnit.SECONDS)
.connectTimeout(30, TimeUnit.SECONDS)
.build();

return new Retrofit.Builder()
.baseUrl(ROOT_URL)
.client(okHttpClient)
.addConverterFactory(GsonConverterFactory.create(gson))
.build();
}

/**
* Get API Service
*
* @return API Service
*/
public static AllApiCall getApiService() {
return getRetrofitInstance().create(AllApiCall.class);
}
}

Step 3 :

Call api like this in interface class


@POST("placeOrder")
Call<OrderContent> placeOrder(@Body Order order);

Step 4 :
Now Callback the api like this

Order order = new Order(userInfo.getId().toString(),userInfo.getFirstname().toString(),userInfo.getLastname(),userInfo.getEmail(),productModels,userInfo.getPhoneNumber(),postcode.getText().toString(),"cash in","45",address.getText().toString(),city.getText().toString(),"1");

Retrofit retrofit = new Retrofit.Builder()
.baseUrl("http://mobileteam.adnarchive.com/opencartAPI/public/api/")
.addConverterFactory(GsonConverterFactory.create())
.build();

AllApiCall service = retrofit.create(AllApiCall.class);

Call<OrderContent> orderContentCall = service.placeOrder(order);

orderContentCall.enqueue(new Callback<OrderContent>() {
@Override
public void onResponse(Call<OrderContent> call, Response<OrderContent> response) {
Toast.makeText(context, response.body().toString(), Toast.LENGTH_SHORT).show();
}

@Override
public void onFailure(Call<OrderContent> call, Throwable t) {

Toast.makeText(context, t.toString(), Toast.LENGTH_SHORT).show();

}
});

.

Done 🙂

How to remote git repository from xCode project completely and create new repository

Git keeps all of its files in the .git directory. Just remove that one and init again.

If you can’t find it, it’s because it is hidden.

  • In Windows 7, you need to go to your folder, click on Organize on the top left, then click on Folder and search options, then click on the View tab and click on the Show hidden files, folders and drives radio button.
  • On a Mac OS:
    • Open a Terminal (via Spotlight: press CMD + SPACE, type terminal and press Enter) and do this command: defaults write com.apple.finder AppleShowAllFiles 1 && killall Finder.
    • Or you could also type cd (the space is important), drag and drop your git repo folder from Finder to the terminal window, press return, then type rm -fr .git, then return again.
  • On Ubuntu, use shortcut Ctrl + H.
To make new git repository first run  git init 

Rest api development with lumen – part 1 : Environment setup

Step 1 :

Open command line tool or terminal for mac/ linux  and run this command for lumen installer . If you have not composer installed then download and install it from here ;
https://getcomposer.org/

and install lumen intaller globally

[java]
composer global require "laravel/lumen-installer"
[/java]

Step 2 :
Create a lumen project with following command

[java]
 composer create-project –prefer-dist laravel/lumen restapi
[/java]

Step 3 :
Go the project directory and run the project

[java]
php -S localhost:8000 -t public
[/java]

Step 4 : 

Database file setup . Open .env file and setup database file . For mysql it looks like –
If you have no database create database for localhost . You need to install XAMP/WAMP .

[java]
APP_ENV=local
APP_DEBUG=true
APP_KEY=
APP_TIMEZONE=UTC

LOG_CHANNEL=stack
LOG_SLACK_WEBHOOK_URL=

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=lumen_api
DB_USERNAME=root
DB_PASSWORD=

CACHE_DRIVER=file
QUEUE_DRIVER=sync
[/java]

change the database name , password and username . And Environment and database setup done .