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

Migrate to checkout endpoints #149

Merged
merged 11 commits into from
Feb 3, 2023
28 changes: 26 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,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 +67,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=developers@paystack.co
POM_DEVELOPER_EMAIL=developers@paystack.co
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:2.2.1'
michael-paystack marked this conversation as resolved.
Show resolved Hide resolved

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 NO_TRANSACTION = new Transaction();
michael-paystack marked this conversation as resolved.
Show resolved Hide resolved

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