Skip to content

Commit

Permalink
add midLabel on create token and create authorization endpoint (#114)
Browse files Browse the repository at this point in the history
* add midLabel on create token and create authorization endpoint

* feat: sdk version update and changelog
  • Loading branch information
stephenthajeb authored Jan 26, 2024
1 parent 8ac88e6 commit 7182c81
Show file tree
Hide file tree
Showing 8 changed files with 468 additions and 117 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# CHANGELOG

## 4.1.1 (20240-01-26)
- Support mid_label in create token and unbundled create authentication

## 4.1.0 (2024-01-25)
- Fix package corruption issues on 4.0.0.

Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,24 @@ Maven:
<dependency>
<groupId>com.xendit</groupId>
<artifactId>xendit-android</artifactId>
<version>4.1.0</version>
<version>4.1.1</version>
<type>pom</type>
</dependency>
```

Gradle:
```
compile 'com.xendit:xendit-android:4.1.0'
compile 'com.xendit:xendit-android:4.1.1'
```

Ivy:
```
<dependency org='com.xendit' name='xendit-android' rev='4.1.0'>
<dependency org='com.xendit' name='xendit-android' rev='4.1.1'>
<artifact name='xendit-android' ext='pom' ></artifact>
</dependency>
```

For more information, visit https://central.sonatype.dev/artifact/com.xendit/xendit-android/4.1.0/versions
For more information, visit https://central.sonatype.dev/artifact/com.xendit/xendit-android/4.1.1/versions

**Note**:

Expand Down
53 changes: 38 additions & 15 deletions app/src/main/java/com/xendit/example/AuthenticationActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class AuthenticationActivity extends AppCompatActivity implements View.On
private EditText tokenIdEditText;
private EditText amountEditText;
private EditText cardCvnEditText;
private EditText midLabelText;
private Button authenticateBtn;
private TextView resultTextView;

Expand All @@ -48,6 +49,8 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
tokenIdEditText = (EditText) findViewById(R.id.tokenIdEditText_AuthenticationActivity);
amountEditText = (EditText) findViewById(R.id.amountEditText_AuthenticationActivity);
cardCvnEditText = (EditText) findViewById(R.id.cardCvnEditText_AuthenticationActivity);
midLabelText = (EditText) findViewById(R.id.midLabelEditText_AuthenticationActivity);

authenticateBtn = (Button) findViewById(R.id.authenticateBtn_AuthenticationActivity);
resultTextView = (TextView) findViewById(R.id.result_AuthenticationActivity);

Expand Down Expand Up @@ -75,22 +78,42 @@ public void onClick(View view) {
String amount = amountEditText.getText().toString();
String cardCvn = cardCvnEditText.getText().toString();
String onBehalfOf = "";
String midLabel = midLabelText.getText().toString();

if (midLabel.isBlank()){
xendit.createAuthentication(tokenId, amount, "IDR", cardCvn, onBehalfOf, new AuthenticationCallback() {
@Override
public void onSuccess(Authentication authentication) {
Gson gson = new Gson();
AuthenticationResponse authenticationResponse = new AuthenticationResponse(authentication);
String json = gson.toJson(authenticationResponse);
resultTextView.setText(json);
Toast.makeText(AuthenticationActivity.this, "Status: " + authentication.getStatus(), Toast.LENGTH_SHORT).show();
}

@Override
public void onError(XenditError xenditError) {
Toast.makeText(AuthenticationActivity.this, xenditError.getErrorCode(), Toast.LENGTH_SHORT).show();
}
});
} else {
xendit.createAuthentication(tokenId, amount, "IDR", cardCvn, onBehalfOf, midLabel ,new AuthenticationCallback() {
@Override
public void onSuccess(Authentication authentication) {
Gson gson = new Gson();
AuthenticationResponse authenticationResponse = new AuthenticationResponse(authentication);
String json = gson.toJson(authenticationResponse);
resultTextView.setText(json);
Toast.makeText(AuthenticationActivity.this, "Status: " + authentication.getStatus(), Toast.LENGTH_SHORT).show();
}

@Override
public void onError(XenditError xenditError) {
Toast.makeText(AuthenticationActivity.this, xenditError.getErrorCode(), Toast.LENGTH_SHORT).show();
}
});
}

xendit.createAuthentication(tokenId, amount, "IDR", cardCvn, onBehalfOf, new AuthenticationCallback() {
@Override
public void onSuccess(Authentication authentication) {
Gson gson = new Gson();
AuthenticationResponse authenticationResponse = new AuthenticationResponse(authentication);
String json = gson.toJson(authenticationResponse);
resultTextView.setText(json);
Toast.makeText(AuthenticationActivity.this, "Status: " + authentication.getStatus(), Toast.LENGTH_SHORT).show();
}

@Override
public void onError(XenditError xenditError) {
Toast.makeText(AuthenticationActivity.this, xenditError.getErrorCode(), Toast.LENGTH_SHORT).show();
}
});
}

@Override
Expand Down
17 changes: 15 additions & 2 deletions app/src/main/java/com/xendit/example/CreateTokenActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public class CreateTokenActivity extends AppCompatActivity implements View.OnCli
private EditText expYearEditText;
private EditText cvnEditText;
private EditText amountEditText;
private EditText midLabelText;
private Button createTokenBtn;
private CheckBox multipleUseCheckBox;
private CheckBox shouldAuthenticateCheckBox;
Expand All @@ -71,6 +72,8 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
expYearEditText = (EditText) findViewById(R.id.expYearEditText_CreateTokenActivity);
cvnEditText = (EditText) findViewById(R.id.cvnEditText_CreateTokenActivity);
amountEditText = (EditText) findViewById(R.id.amountEditText_CreateTokenActivity);
midLabelText = (EditText) findViewById(R.id.midLabelEditText_CreateTokenActivity);

createTokenBtn = (Button) findViewById(R.id.createTokenBtn_CreateTokenActivity);
multipleUseCheckBox = (CheckBox) findViewById(R.id.multipleUseCheckBox_CreateTokenActivity);
shouldAuthenticateCheckBox = (CheckBox) findViewById(R.id.shouldAuthenticate_CreateTokenActivity);
Expand Down Expand Up @@ -161,11 +164,21 @@ public void onError(XenditError xenditError) {
}
};

String midLabel = midLabelText.getText().toString();
if (isMultipleUse) {
xendit.createMultipleUseToken(card, onBehalfOf, billingDetails, customer, callback);
if (midLabel.isBlank()){
xendit.createMultipleUseToken(card, onBehalfOf, billingDetails, customer, callback);
} else {
xendit.createMultipleUseToken(card, onBehalfOf, billingDetails, customer, midLabel, callback);
}
} else {
String amount = amountEditText.getText().toString();
xendit.createSingleUseToken(card, amount, shouldAuthenticate, onBehalfOf, billingDetails, customer, "IDR", callback);

if (midLabel.isBlank()){
xendit.createSingleUseToken(card, amount, shouldAuthenticate, onBehalfOf, billingDetails, customer, "IDR", callback);
} else {
xendit.createSingleUseToken(card, amount, shouldAuthenticate, onBehalfOf, billingDetails, customer, "IDR", midLabel, callback);
}
}
}

Expand Down
9 changes: 9 additions & 0 deletions app/src/main/res/layout/activity_authentication.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@
android:textColorHint="#cccccc"/>
</LinearLayout>

<EditText
android:id="@+id/midLabelEditText_AuthenticationActivity"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:hint="mid_label (switcher merchant only)"
android:textColor="@android:color/black"
android:textColorHint="#cccccc" />

<Button
android:id="@+id/authenticateBtn_AuthenticationActivity"
android:layout_width="wrap_content"
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/res/layout/activity_create_token.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,15 @@
android:textColor="@android:color/black"
android:textColorHint="#cccccc" />

<EditText
android:id="@+id/midLabelEditText_CreateTokenActivity"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:hint="mid_label (switcher merchant only)"
android:textColor="@android:color/black"
android:textColorHint="#cccccc" />

<CheckBox
android:id="@+id/multipleUseCheckBox_CreateTokenActivity"
android:layout_width="match_parent"
Expand Down
4 changes: 2 additions & 2 deletions xendit-android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ apply plugin: 'com.jfrog.bintray'
apply plugin: 'signing'

group 'com.xendit'
version '4.1.0'
version '4.1.1'

ext {
bintrayOrg = 'xendit'
Expand Down Expand Up @@ -38,7 +38,7 @@ android {
minSdkVersion 21
targetSdkVersion 34
versionCode 1
versionName '4.1.0'
versionName '4.1.1'
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}
buildTypes {
Expand Down
Loading

0 comments on commit 7182c81

Please sign in to comment.