Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added hal positivo #38

Draft
wants to merge 1 commit into
base: migration-5.x
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ dependencies {
implementation "br.com.stone:stone-sdk-payment"


implementation "br.com.stone:stone-sdk-posandroid-positivo"
implementation "br.com.stone:stone-sdk-posandroid-ingenico"
implementation "br.com.stone:stone-sdk-posandroid-gertec"
implementation "br.com.stone:stone-sdk-posandroid-sunmi"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@
import android.widget.TextView;
import android.widget.Toast;

import br.com.stone.sdk.android.error.StoneStatus;
import br.com.stone.sdk.core.enums.ErrorsEnum;
import br.com.stone.sdk.core.model.user.UserModel;
import br.com.stone.sdk.core.utils.Stone;
import br.com.stone.sdk.payment.database.models.transaction.TransactionObject;
import br.com.stone.sdk.payment.enums.Action;
import br.com.stone.sdk.payment.enums.InstalmentTransaction;
import br.com.stone.sdk.payment.utils.InstalmentTransaction;
import br.com.stone.sdk.payment.enums.TypeOfTransactionEnum;
import br.com.stone.sdk.payment.providers.interfaces.BaseTransactionProvider;
import br.com.stone.sdk.payment.providers.interfaces.StoneActionCallback;
Expand Down Expand Up @@ -182,8 +183,13 @@ protected boolean providerHasErrorEnum(ErrorsEnum errorsEnum) {
}

@Override
public void onError() {
runOnUiThread(() -> Toast.makeText(BaseTransactionActivity.this, "Erro: " + transactionProvider.getListOfErrors(), Toast.LENGTH_SHORT).show());
public void onError(@Nullable StoneStatus stoneStatus) {
if (stoneStatus != null) {
runOnUiThread(() -> Toast.makeText(BaseTransactionActivity.this, "Erro: " + stoneStatus.getMessage(), Toast.LENGTH_SHORT).show());

} else {
runOnUiThread(() -> Toast.makeText(BaseTransactionActivity.this, "Erro: " + transactionProvider.getListOfErrors(), Toast.LENGTH_SHORT).show());
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@
import android.widget.ListView;
import android.widget.Toast;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import java.util.Set;

import br.com.stone.sdk.android.error.StoneStatus;
import br.com.stone.sdk.core.providers.interfaces.StoneCallbackInterface;
import br.com.stone.sdk.payment.database.models.pinpad.PinpadObject;
import br.com.stone.sdk.payment.providers.BluetoothConnectionProvider;
Expand Down Expand Up @@ -78,16 +80,17 @@ public void onItemClick(AdapterView<?> parent, View view, int position, long id)
bluetoothConnectionProvider.useDefaultUI(false); // Informa que haverá um feedback para o usuário.
bluetoothConnectionProvider.setConnectionCallback(new StoneCallbackInterface() {

@Override
public void onError(@Nullable StoneStatus stoneStatus) {
Toast.makeText(getApplicationContext(), "Erro durante a conexao. Verifique a lista de erros do provider para mais informacoes", Toast.LENGTH_SHORT).show();
Log.e("DevicesActivity", "onError: " + bluetoothConnectionProvider.getListOfErrors());
}

public void onSuccess() {
Toast.makeText(getApplicationContext(), "Pinpad conectado", Toast.LENGTH_SHORT).show();
btConnected = true;
finish();
}

public void onError() {
Toast.makeText(getApplicationContext(), "Erro durante a conexao. Verifique a lista de erros do provider para mais informacoes", Toast.LENGTH_SHORT).show();
Log.e("DevicesActivity", "onError: " + bluetoothConnectionProvider.getListOfErrors());
}
});
bluetoothConnectionProvider.execute(); // Executa o provider de conexão bluetooth.
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@
import android.widget.EditText;
import android.widget.Toast;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;

import java.util.List;

import br.com.stone.sdk.activation.providers.ActiveApplicationProvider;
import br.com.stone.sdk.android.error.StoneStatus;
import br.com.stone.sdk.core.providers.interfaces.StoneCallbackInterface;
import br.com.stone.sdk.hardware.providers.PosPrintProvider;
import br.com.stone.sdk.payment.database.models.transaction.TransactionObject;
Expand Down Expand Up @@ -108,13 +110,13 @@ public void onClick(DialogInterface dialog, int which) {
reversalProvider.setDialogMessage("Cancelando transações com erro");
reversalProvider.setConnectionCallback(new StoneCallbackInterface() {
@Override
public void onSuccess() {
Toast.makeText(MainActivity.this, "Transações canceladas com sucesso", Toast.LENGTH_SHORT).show();
}
public void onError(@Nullable StoneStatus stoneStatus) {
Toast.makeText(MainActivity.this, "Ocorreu um erro durante o cancelamento das tabelas: " + reversalProvider.getListOfErrors(), Toast.LENGTH_SHORT).show();

}
@Override
public void onError() {
Toast.makeText(MainActivity.this, "Ocorreu um erro durante o cancelamento das tabelas: " + reversalProvider.getListOfErrors(), Toast.LENGTH_SHORT).show();
public void onSuccess() {
Toast.makeText(MainActivity.this, "Transações canceladas com sucesso", Toast.LENGTH_SHORT).show();
}
});
reversalProvider.execute();
Expand All @@ -126,19 +128,19 @@ public void onError() {
provider.setDialogTitle("Aguarde");
provider.useDefaultUI(true);
provider.setConnectionCallback(new StoneCallbackInterface() {
@Override
public void onError(@Nullable StoneStatus stoneStatus) {
makeText(MainActivity.this, "Erro na ativacao do aplicativo, verifique a lista de erros do provider", LENGTH_SHORT).show();
/* Chame o metodo abaixo para verificar a lista de erros. Para mais detalhes, leia a documentacao: */
Log.e("deactivateOption", "onError: " + provider.getListOfErrors().toString());
}

/* Metodo chamado se for executado sem erros */
public void onSuccess() {
Intent mainIntent = new Intent(MainActivity.this, ValidationActivity.class);
startActivity(mainIntent);
finish();
}

/* metodo chamado caso ocorra alguma excecao */
public void onError() {
makeText(MainActivity.this, "Erro na ativacao do aplicativo, verifique a lista de erros do provider", LENGTH_SHORT).show();
/* Chame o metodo abaixo para verificar a lista de erros. Para mais detalhes, leia a documentacao: */
Log.e("deactivateOption", "onError: " + provider.getListOfErrors().toString());
}
});
provider.deactivate();
break;
Expand All @@ -163,6 +165,17 @@ public void onError() {
case R.id.posValidateCardOption:
final PosValidateTransactionByCardProvider posValidateTransactionByCardProvider = new PosValidateTransactionByCardProvider(this);
posValidateTransactionByCardProvider.setConnectionCallback(new StoneActionCallback() {
@Override
public void onError(@Nullable StoneStatus stoneStatus) {
runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(MainActivity.this, "Error", Toast.LENGTH_SHORT).show();
Log.e("posValidateCardOption", "onError: " + posValidateTransactionByCardProvider.getListOfErrors());
}
});
}

@Override
public void onStatusChanged(final Action action) {
runOnUiThread(new Runnable() {
Expand All @@ -187,18 +200,6 @@ public void run() {
});

}

@Override
public void onError() {
runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(MainActivity.this, "Error", Toast.LENGTH_SHORT).show();
Log.e("posValidateCardOption", "onError: " + posValidateTransactionByCardProvider.getListOfErrors());
}
});
}

});
posValidateTransactionByCardProvider.execute();
break;
Expand All @@ -211,19 +212,19 @@ public void run() {
customPosPrintProvider.addLine("ATK : 123456789");
customPosPrintProvider.addLine("Signature");
customPosPrintProvider.addBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.signature));
customPosPrintProvider.setConnectionCallback(new StoneCallbackInterface() {
customPosPrintProvider.print(new StoneCallbackInterface() {
@Override
public void onSuccess() {
Toast.makeText(getApplicationContext(), "Recibo impresso", Toast.LENGTH_SHORT).show();
public void onError(@Nullable StoneStatus stoneStatus) {
if(stoneStatus != null) {
runOnUiThread(() -> Toast.makeText(getApplicationContext(), "Erro ao imprimir: " + stoneStatus.getMessage(), Toast.LENGTH_SHORT).show());
}
}

@Override
public void onError() {
Toast.makeText(getApplicationContext(), "Erro ao imprimir: " + customPosPrintProvider.getListOfErrors(), Toast.LENGTH_SHORT).show();
public void onSuccess() {
runOnUiThread(() -> Toast.makeText(getApplicationContext(), "Recibo impresso", Toast.LENGTH_SHORT).show());
}
});
customPosPrintProvider.execute();

default:
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import java.util.List;

import br.com.stone.sdk.activation.providers.ActiveApplicationProvider;
import br.com.stone.sdk.android.error.StoneStatus;
import br.com.stone.sdk.core.model.user.UserModel;
import br.com.stone.sdk.core.providers.interfaces.StoneCallbackInterface;
import br.com.stone.sdk.core.utils.Stone;
Expand Down Expand Up @@ -74,18 +75,18 @@ private void activateStoneCodeButtonOnClickListener() {
activeApplicationProvider.useDefaultUI(true);

activeApplicationProvider.setConnectionCallback(new StoneCallbackInterface() {
@Override
public void onError(@Nullable StoneStatus stoneStatus) {
Toast.makeText(getApplicationContext(), "Error", Toast.LENGTH_LONG).show();
Log.e("ManageStoneCodeActivity", "onError: " + activeApplicationProvider.getListOfErrors());
}

@Override
public void onSuccess() {
stoneCodeListView.setAdapter(populateStoneCodeListView());
((ArrayAdapter) stoneCodeListView.getAdapter()).notifyDataSetChanged();
Toast.makeText(getApplicationContext(), "Success", Toast.LENGTH_LONG).show();
}

@Override
public void onError() {
Toast.makeText(getApplicationContext(), "Error", Toast.LENGTH_LONG).show();
Log.e("ManageStoneCodeActivity", "onError: " + activeApplicationProvider.getListOfErrors());
}
});

activeApplicationProvider.activate(stoneCodeEditText.getText().toString());
Expand All @@ -106,18 +107,18 @@ private void manageStoneCodeListViewOnItemClickListener(int position) {
activeApplicationProvider.useDefaultUI(true);

activeApplicationProvider.setConnectionCallback(new StoneCallbackInterface() {
@Override
public void onError(@Nullable StoneStatus stoneStatus) {
Toast.makeText(getApplicationContext(), "Error", Toast.LENGTH_LONG).show();
Log.e("ManageStoneCodeActivity", "onError: " + activeApplicationProvider.getListOfErrors());
}

@Override
public void onSuccess() {
stoneCodeListView.setAdapter(populateStoneCodeListView());
((ArrayAdapter) stoneCodeListView.getAdapter()).notifyDataSetChanged();
Toast.makeText(getApplicationContext(), "Success", Toast.LENGTH_LONG).show();
}

@Override
public void onError() {
Toast.makeText(getApplicationContext(), "Error", Toast.LENGTH_LONG).show();
Log.e("ManageStoneCodeActivity", "onError: " + activeApplicationProvider.getListOfErrors());
}
});
activeApplicationProvider.deactivate(userModelList.get(position).getStoneCode());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
import android.content.DialogInterface;
import android.widget.Toast;

import androidx.annotation.Nullable;

import br.com.stone.sdk.android.error.StoneStatus;
import br.com.stone.sdk.core.enums.ErrorsEnum;
import br.com.stone.sdk.payment.enums.Action;
import br.com.stone.sdk.payment.enums.ReceiptType;
Expand Down Expand Up @@ -71,8 +74,8 @@ public void run() {
}

@Override
public void onError() {
super.onError();
public void onError(@Nullable StoneStatus stoneStatus) {
super.onError(stoneStatus);
if (providerHasErrorEnum(ErrorsEnum.DEVICE_NOT_COMPATIBLE)) {
Toast.makeText(
this,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import android.widget.Toast;

import androidx.annotation.Nullable;

import br.com.stone.sdk.android.error.StoneStatus;
import br.com.stone.sdk.payment.enums.TransactionStatusEnum;
import br.com.stone.sdk.payment.providers.TransactionProvider;
import br.com.stone.sdk.payment.utils.StonePayment;
Expand Down Expand Up @@ -30,9 +33,4 @@ public void onSuccess() {
Toast.makeText(getApplicationContext(), msg, Toast.LENGTH_LONG).show();
}
}

@Override
public void onError() {
super.onError();
}
}
Loading