Skip to content

Commit 61343e5

Browse files
Migrate to checkout endpoints (#149)
* Update Android Gradle Plugin to 7.1.3 - Older versions don't work on ARM computers * Add close button to 3DS popup * Update dependencies to fix Jacoco reports * Correct version name * Autoclose 3DS window when complete * TEMP: WEB MESSAGE EXPLORATION * Merge master into update-api-endpoints * Fix TransactionManagerTest.kt * Move pusher library version to ext * Change `NO_TRANSACTION` name to `EMPTY_TRANSACTION`
1 parent 2e67f6c commit 61343e5

File tree

17 files changed

+334
-210
lines changed

17 files changed

+334
-210
lines changed

build.gradle

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ buildscript {
55
ext.versions = [
66
'kotlin' : '1.7.22',
77
'coroutines' : '1.4.2',
8+
'pusher' : '2.2.1',
89
'robolectric' : '4.4',
910
'mockito' : '3.8.0',
1011
'mockito_kotlin': '2.2.0',
@@ -24,7 +25,7 @@ buildscript {
2425
}
2526
}
2627
plugins {
27-
id "org.sonarqube" version "3.1.1"
28+
id "org.sonarqube" version "3.5.0.2730"
2829
}
2930

3031
sonarqube {
@@ -67,4 +68,28 @@ ext {
6768

6869
buildToolsVersion = "29.0.2"
6970
versionName = "3.2.0-alpha02"
70-
}
71+
}
72+
73+
Object getEnvOrDefault(String propertyName, Object defaultValue) {
74+
// Check 'local.properties' first
75+
String propertyValue
76+
77+
def propFile = file('local.properties')
78+
if (propFile.exists()) {
79+
Properties localProps = new Properties()
80+
localProps.load(propFile.newDataInputStream())
81+
propertyValue = localProps.getProperty(propertyName)
82+
if (propertyValue != null) {
83+
return propertyValue
84+
}
85+
}
86+
87+
propertyValue = project.properties[propertyName]
88+
89+
if (propertyValue == null) {
90+
logger.error("Build property named {} not defined. Falling back to default value.", propertyName)
91+
return defaultValue
92+
}
93+
94+
return propertyValue
95+
}

example/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ android {
4242
}
4343
buildTypes {
4444
debug {
45-
testCoverageEnabled true
45+
testCoverageEnabled false
4646
}
4747
release {
4848
minifyEnabled false

example/src/main/java/co/paystack/example/MainActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public class MainActivity extends AppCompatActivity {
3535
// Step 3. Login with your heroku credentials or create a free heroku account
3636
// Step 4. Provide your secret key and an email with which to start all test transactions
3737
// Step 5. Copy the url generated by heroku (format https://some-url.herokuapp.com) into the space below
38-
String backend_url = "https://infinite-peak-60063.herokuapp.com";
38+
String backend_url = "https://charge-sample-service.onrender.com";
3939
// Set this to a public key that matches the secret key you supplied while creating the heroku instance
4040
String paystack_public_key = "pk_test_9eb0263ed776c4c892e0281348aee4136cd0dd52";
4141

gradle.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,5 @@ POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt
3636
POM_LICENCE_DIST=repo
3737
POM_DEVELOPER_ID=paystack
3838
POM_DEVELOPER_NAME=Paystack
39-
POM_DEVELOPER_EMAIL=[email protected]
39+
POM_DEVELOPER_EMAIL=[email protected]
40+
org.gradle.unsafe.configuration-cache=true

paystack/build.gradle

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ android {
4444

4545
buildConfigField 'int', 'VERSION_CODE', "${rootProject.ext.versionCode}"
4646
buildConfigField 'String', 'VERSION_NAME', "\"${rootProject.ext.versionName}\""
47+
buildConfigField 'String', 'PUSHER_KEY', "\"${getEnvOrDefault("PUSHER_KEY", "")}\""
4748
}
4849
buildTypes {
4950
debug {
@@ -74,12 +75,13 @@ dependencies {
7475
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$versions.coroutines"
7576
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$versions.coroutines"
7677

78+
implementation "com.pusher:pusher-java-client:$versions.pusher"
79+
7780
testImplementation "org.robolectric:robolectric:$versions.robolectric"
7881
testImplementation "org.mockito:mockito-core:$versions.mockito"
7982
testImplementation "com.nhaarman.mockitokotlin2:mockito-kotlin:$versions.mockito_kotlin"
8083
testImplementation "androidx.test.ext:junit-ktx:$versions.junit_ext"
8184
testImplementation "org.jetbrains.kotlin:kotlin-test-junit:$versions.kotlin"
82-
8385
}
8486

8587
apply from: "https://raw.githubusercontent.com/PaystackHQ/publish-mavencentral/main/maven-publish.gradle"
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package co.paystack.android
2+
3+
object AuthType {
4+
const val PIN = "pin"
5+
const val OTP = "otp"
6+
const val THREE_DS = "3DS"
7+
const val PHONE = "phone"
8+
const val ADDRESS_VERIFICATION = "avs"
9+
}

paystack/src/main/java/co/paystack/android/Paystack.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ private void chargeCard(Activity activity, Charge charge, String publicKey, Tran
6868
.getTransactionManagerFactory()
6969
.create();
7070

71-
transactionManager.chargeCard(activity, charge, transactionCallback);
71+
transactionManager.chargeCard(activity, PaystackSdk.getPublicKey(), charge, transactionCallback);
7272

7373
} catch (Exception ae) {
7474
assert transactionCallback != null;

paystack/src/main/java/co/paystack/android/PaystackSdkComponent.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ internal object PaystackSdkModule : PaystackSdkComponent {
1212

1313
override val transactionManagerFactory: Factory<TransactionManager> = object : Factory<TransactionManager> {
1414
override fun create(): TransactionManager {
15-
return TransactionManager(apiComponent().apiService)
15+
return TransactionManager(apiComponent().paystackRepository)
1616
}
1717
}
1818
}

paystack/src/main/java/co/paystack/android/Transaction.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ public class Transaction {
66
private String id;
77
private String reference;
88

9+
public static Transaction EMPTY_TRANSACTION = new Transaction();
10+
911
void loadFromResponse(TransactionApiResponse t) {
1012
if (t.hasValidReferenceAndTrans()) {
1113
this.reference = t.reference;
@@ -21,6 +23,14 @@ public String getReference() {
2123
return reference;
2224
}
2325

26+
void setReference(String reference) {
27+
this.reference = reference;
28+
}
29+
30+
void setId(String id) {
31+
this.id = id;
32+
}
33+
2434
boolean hasStartedOnServer() {
2535
return (reference != null) && (id != null);
2636
}

0 commit comments

Comments
 (0)