Skip to content

Commit

Permalink
Merge pull request #74 from pokepay/feature/add-cardholder-name-verit…
Browse files Browse the repository at this point in the history
…rans

Add cardholderName param to GetVeritransToken
  • Loading branch information
DanRidh authored Aug 7, 2024
2 parents ef47067 + 144696c commit 4673738
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 10 deletions.
4 changes: 2 additions & 2 deletions pokepaylib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ android {
minSdkVersion 26
targetSdkVersion 32
versionCode 0
versionName "2.0.15"
versionName "2.0.16"

testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'

Expand Down Expand Up @@ -66,7 +66,7 @@ uploadArchives {
repositories {
mavenDeployer {
repository url: "file://${repo.absolutePath}"
pom.version = '2.0.15' // version
pom.version = '2.0.16' // version
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }

repository(url: "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@ public class GetVeritransToken extends ExternalServiceRequest {
public String securityCode;
@NonNull
public String tokenApiKey;
@NonNull
public String cardholderName;

public GetVeritransToken(@NonNull String cardNumber, @NonNull String cardExpiryDate, @NonNull String securityCode, @NonNull String tokenApiKey) {
public GetVeritransToken(@NonNull String cardNumber, @NonNull String cardExpiryDate, @NonNull String securityCode, @NonNull String tokenApiKey, @NonNull String cardholderName) {
this.cardNumber = cardNumber;
this.cardExpiryDate = cardExpiryDate;
this.securityCode = securityCode;
this.tokenApiKey = tokenApiKey;
this.cardholderName = cardholderName;
}

protected final String path() {
Expand All @@ -45,6 +48,7 @@ protected final Map<String, Object> parameters() {
put("card_expire", cardExpiryDate);
put("security_code", securityCode);
put("token_api_key", tokenApiKey);
put("cardholder_name", cardholderName);
}};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ private String fetchVeritransMdkToken() {
final String testTokenApiKey = "9ad14759-7082-457e-a874-864c78edc05a";

try {
VeritransToken response = new GetVeritransToken(testCardNumber, "12/23", "123", testTokenApiKey).send();
VeritransToken response = new GetVeritransToken(testCardNumber, "12/23", "123", testTokenApiKey, "FOO BAR").send();
return response.token;
} catch (Exception e) {
fail();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class GetVeritransTokenTest {
@Test
public void MDKTokenCanGet() throws ProcessingError {
try {
new GetVeritransToken(testCardNumber, "12/23", "123", testTokenApiKey).send();
new GetVeritransToken(testCardNumber, "12/23", "123", testTokenApiKey, "FOO BAR").send();
} catch (ExternalServiceRequestError e) {
fail(e.toString());
}
Expand All @@ -25,7 +25,7 @@ public void MDKTokenCanGet() throws ProcessingError {
@Test
public void ThrowErrorIfdExpireDateIsInvalid() throws ProcessingError, ExternalServiceRequestError {
try {
new GetVeritransToken(testCardNumber, "1223", "123", testTokenApiKey).send();
new GetVeritransToken(testCardNumber, "1223", "123", testTokenApiKey, "FOO BAR").send();
fail();
} catch (VeritransRequestError e) {
assertEquals("failure", e.error.status);
Expand Down
11 changes: 7 additions & 4 deletions sample/src/main/java/jp/pokepay/pokepay/CreditCardActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class CreditCardActivity extends AppCompatActivity {
final String accountId = "7a226542-feb2-4614-9e87-907745ff5342";
final String accessToken = "55nF6HJRyGCHgvEQZP7Pd5K33ggX-C5ZH_q3eqqe5Cg1dGeV_G2-CZ0rmChJ1OcN";
final String tokenApiKey = "9ad14759-7082-457e-a874-864c78edc05a";
final String cardholderName = "FOO BAR";

final int json = 1;
final int html = 2;
Expand All @@ -48,9 +49,9 @@ public class CreditCardActivity extends AppCompatActivity {
return true;
});

private String fetchVeritransMdkToken(String cardNumber, String cardExpireDate, String securityCode, String tokenApiKey) {
private String fetchVeritransMdkToken(String cardNumber, String cardExpireDate, String securityCode, String tokenApiKey, String cardholderName) {
try {
VeritransToken response = new GetVeritransToken(cardNumber, cardExpireDate, securityCode, tokenApiKey).send();
VeritransToken response = new GetVeritransToken(cardNumber, cardExpireDate, securityCode, tokenApiKey, cardholderName).send();
return response.token;
} catch (Exception e) {
throw new RuntimeException(e);
Expand Down Expand Up @@ -89,7 +90,8 @@ protected void onCreate(Bundle savedInstanceState) {
final String cardNumber = "4111111111111111";
final String cardExpireDate = "12/23";
final String securityCode = "123";
final String token = fetchVeritransMdkToken(cardNumber, cardExpireDate, securityCode, tokenApiKey);
final String cardholderName = "FOO BAR";
final String token = fetchVeritransMdkToken(cardNumber, cardExpireDate, securityCode, tokenApiKey, cardholderName);

final CreditCard response;
try {
Expand All @@ -110,7 +112,8 @@ protected void onCreate(Bundle savedInstanceState) {
final String cardNumber = "4111111111111111";
final String cardExpireDate = "12/28";
final String securityCode = "123";
final String token = fetchVeritransMdkToken(cardNumber, cardExpireDate, securityCode, tokenApiKey);
final String cardholderName = "FOO BAR";
final String token = fetchVeritransMdkToken(cardNumber, cardExpireDate, securityCode, tokenApiKey, cardholderName);
final int amount = 42;

final String text;
Expand Down

0 comments on commit 4673738

Please sign in to comment.