Skip to content

Commit

Permalink
Migrate to checkout endpoints (#149)
Browse files Browse the repository at this point in the history
* 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`
  • Loading branch information
michael-paystack authored Feb 3, 2023
1 parent 2e67f6c commit 61343e5
Show file tree
Hide file tree
Showing 17 changed files with 334 additions and 210 deletions.
29 changes: 27 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ buildscript {
ext.versions = [
'kotlin' : '1.7.22',
'coroutines' : '1.4.2',
'pusher' : '2.2.1',
'robolectric' : '4.4',
'mockito' : '3.8.0',
'mockito_kotlin': '2.2.0',
Expand All @@ -24,7 +25,7 @@ buildscript {
}
}
plugins {
id "org.sonarqube" version "3.1.1"
id "org.sonarqube" version "3.5.0.2730"
}

sonarqube {
Expand Down Expand Up @@ -67,4 +68,28 @@ ext {

buildToolsVersion = "29.0.2"
versionName = "3.2.0-alpha02"
}
}

Object getEnvOrDefault(String propertyName, Object defaultValue) {
// Check 'local.properties' first
String propertyValue

def propFile = file('local.properties')
if (propFile.exists()) {
Properties localProps = new Properties()
localProps.load(propFile.newDataInputStream())
propertyValue = localProps.getProperty(propertyName)
if (propertyValue != null) {
return propertyValue
}
}

propertyValue = project.properties[propertyName]

if (propertyValue == null) {
logger.error("Build property named {} not defined. Falling back to default value.", propertyName)
return defaultValue
}

return propertyValue
}
2 changes: 1 addition & 1 deletion example/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ android {
}
buildTypes {
debug {
testCoverageEnabled true
testCoverageEnabled false
}
release {
minifyEnabled false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class MainActivity extends AppCompatActivity {
// Step 3. Login with your heroku credentials or create a free heroku account
// Step 4. Provide your secret key and an email with which to start all test transactions
// Step 5. Copy the url generated by heroku (format https://some-url.herokuapp.com) into the space below
String backend_url = "https://infinite-peak-60063.herokuapp.com";
String backend_url = "https://charge-sample-service.onrender.com";
// Set this to a public key that matches the secret key you supplied while creating the heroku instance
String paystack_public_key = "pk_test_9eb0263ed776c4c892e0281348aee4136cd0dd52";

Expand Down
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt
POM_LICENCE_DIST=repo
POM_DEVELOPER_ID=paystack
POM_DEVELOPER_NAME=Paystack
POM_DEVELOPER_EMAIL=[email protected]
POM_DEVELOPER_EMAIL=[email protected]
org.gradle.unsafe.configuration-cache=true
4 changes: 3 additions & 1 deletion paystack/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ android {

buildConfigField 'int', 'VERSION_CODE', "${rootProject.ext.versionCode}"
buildConfigField 'String', 'VERSION_NAME', "\"${rootProject.ext.versionName}\""
buildConfigField 'String', 'PUSHER_KEY', "\"${getEnvOrDefault("PUSHER_KEY", "")}\""
}
buildTypes {
debug {
Expand Down Expand Up @@ -74,12 +75,13 @@ dependencies {
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$versions.coroutines"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$versions.coroutines"

implementation "com.pusher:pusher-java-client:$versions.pusher"

testImplementation "org.robolectric:robolectric:$versions.robolectric"
testImplementation "org.mockito:mockito-core:$versions.mockito"
testImplementation "com.nhaarman.mockitokotlin2:mockito-kotlin:$versions.mockito_kotlin"
testImplementation "androidx.test.ext:junit-ktx:$versions.junit_ext"
testImplementation "org.jetbrains.kotlin:kotlin-test-junit:$versions.kotlin"

}

apply from: "https://raw.githubusercontent.com/PaystackHQ/publish-mavencentral/main/maven-publish.gradle"
9 changes: 9 additions & 0 deletions paystack/src/main/java/co/paystack/android/AuthType.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package co.paystack.android

object AuthType {
const val PIN = "pin"
const val OTP = "otp"
const val THREE_DS = "3DS"
const val PHONE = "phone"
const val ADDRESS_VERIFICATION = "avs"
}
2 changes: 1 addition & 1 deletion paystack/src/main/java/co/paystack/android/Paystack.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ private void chargeCard(Activity activity, Charge charge, String publicKey, Tran
.getTransactionManagerFactory()
.create();

transactionManager.chargeCard(activity, charge, transactionCallback);
transactionManager.chargeCard(activity, PaystackSdk.getPublicKey(), charge, transactionCallback);

} catch (Exception ae) {
assert transactionCallback != null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ internal object PaystackSdkModule : PaystackSdkComponent {

override val transactionManagerFactory: Factory<TransactionManager> = object : Factory<TransactionManager> {
override fun create(): TransactionManager {
return TransactionManager(apiComponent().apiService)
return TransactionManager(apiComponent().paystackRepository)
}
}
}
10 changes: 10 additions & 0 deletions paystack/src/main/java/co/paystack/android/Transaction.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ public class Transaction {
private String id;
private String reference;

public static Transaction EMPTY_TRANSACTION = new Transaction();

void loadFromResponse(TransactionApiResponse t) {
if (t.hasValidReferenceAndTrans()) {
this.reference = t.reference;
Expand All @@ -21,6 +23,14 @@ public String getReference() {
return reference;
}

void setReference(String reference) {
this.reference = reference;
}

void setId(String id) {
this.id = id;
}

boolean hasStartedOnServer() {
return (reference != null) && (id != null);
}
Expand Down
Loading

0 comments on commit 61343e5

Please sign in to comment.