-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: Add Android SDK reference snippets
- Loading branch information
1 parent
1a9b9d4
commit 687b92b
Showing
27 changed files
with
182 additions
and
0 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
dist/doc/developer-tools/android-sdk/builder-library-import.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const kt = `import com.paystack.android.core.Paystack` | ||
|
||
const java = `import com.paystack.android.core.Paystack;` | ||
|
||
export {kt, java} |
11 changes: 11 additions & 0 deletions
11
dist/doc/developer-tools/android-sdk/builder-library-usage.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
const kt = `Paystack.builder() | ||
.setPublicKey("pk_domain_xxxxxxxx") | ||
.setLoggingEnabled(true) | ||
.build()` | ||
|
||
const java = `Paystack.builder() | ||
.setPublicKey("pk_domain_xxxxxxxx") | ||
.setLoggingEnabled(true) | ||
.build();` | ||
|
||
export {kt, java} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const gradle = `dependencies { | ||
implementation 'com.paystack.android:paystack-ui:0.0.5' | ||
}` | ||
|
||
export {gradle} |
14 changes: 14 additions & 0 deletions
14
dist/doc/developer-tools/android-sdk/payment-sheet-init.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
const kt = `private lateinit var paymentSheet: PaymentSheet | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
paymentSheet = PaymentSheet(this) { paymentResult -> | ||
// Handle payment result here. | ||
} | ||
}` | ||
|
||
const java = `// TODO: Add snippet` | ||
|
||
export {kt, java} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
const kt = `fun startPayment() { | ||
val accessCode = initializeTransactionOnServer() | ||
paymentSheet.launch(accessCode) | ||
}` | ||
|
||
const java = `// TODO: Add snippet` | ||
|
||
export {kt, java} |
39 changes: 39 additions & 0 deletions
39
dist/doc/developer-tools/android-sdk/payment-sheet-result-full.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
const kt = `private fun paymentComplete(paymentSheetResult: PaymentSheetResult ) { | ||
val message = when (paymentSheetResult) { | ||
PaymentSheetResult.Cancelled -> "Cancelled" | ||
is PaymentSheetResult.Failed -> { | ||
Log.e("Something went wrong", paymentSheetResult.error.message.orEmpty(), paymentSheetResult.error) | ||
paymentSheetResult.error.message ?: "Failed" | ||
} | ||
is PaymentSheetResult.Completed -> { | ||
// Returns the transaction reference PaymentCompletionDetails(reference={TransactionRef}) | ||
Log.d("Payment successful", paymentSheetResult.paymentCompletionDetails.toString()) | ||
"Successful" | ||
} | ||
} | ||
Toast.makeText(this, "Payment $message", Toast.LENGTH_SHORT).show() | ||
}` | ||
|
||
const java = `private void onPaymentResult(PaymentSheetResult paymentResult) { | ||
String message; | ||
if (paymentResult instanceof PaymentSheetResult.Cancelled) { | ||
message = "Cancelled"; | ||
} else if (paymentResult instanceof PaymentSheetResult.Failed) { | ||
PaymentSheetResult.Failed failedResult = (PaymentSheetResult.Failed) paymentResult; | ||
Log.e(TAG, failedResult.getError().getMessage() != null ? | ||
failedResult.getError().getMessage() : "Failed", failedResult.getError()); | ||
message = failedResult.getError().getMessage() != null ? | ||
failedResult.getError().getMessage() : "Failed"; | ||
} else if (paymentResult instanceof PaymentSheetResult.Completed) { | ||
Log.d("Payment successful", paymentSheetResult.paymentCompletionDetails.toString()) | ||
message = "Successful"; | ||
} else { | ||
message = ""; | ||
} | ||
Toast.makeText(this, "Payment " + message, Toast.LENGTH_SHORT).show(); | ||
}` | ||
|
||
export {kt, java} |
9 changes: 9 additions & 0 deletions
9
dist/doc/developer-tools/android-sdk/payment-sheet-result-init.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
const kt = `import com.paystack.android_sdk.ui.paymentsheet.PaymentSheetResult | ||
private fun paymentComplete(paymentSheetResult: PaymentSheetResult ) { | ||
}` | ||
|
||
const java = `// TODO: Add snippet` | ||
|
||
export {kt, java} |
3 changes: 3 additions & 0 deletions
3
src/doc/developer-tools/android-sdk/builder-library-import/config.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
languages: | ||
- kt | ||
- java |
1 change: 1 addition & 0 deletions
1
src/doc/developer-tools/android-sdk/builder-library-import/index.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import com.paystack.android.core.Paystack; |
1 change: 1 addition & 0 deletions
1
src/doc/developer-tools/android-sdk/builder-library-import/index.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import com.paystack.android.core.Paystack |
3 changes: 3 additions & 0 deletions
3
src/doc/developer-tools/android-sdk/builder-library-usage/config.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
languages: | ||
- kt | ||
- java |
4 changes: 4 additions & 0 deletions
4
src/doc/developer-tools/android-sdk/builder-library-usage/index.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Paystack.builder() | ||
.setPublicKey("pk_domain_xxxxxxxx") | ||
.setLoggingEnabled(true) | ||
.build(); |
4 changes: 4 additions & 0 deletions
4
src/doc/developer-tools/android-sdk/builder-library-usage/index.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Paystack.builder() | ||
.setPublicKey("pk_domain_xxxxxxxx") | ||
.setLoggingEnabled(true) | ||
.build() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
languages: | ||
- gradle |
3 changes: 3 additions & 0 deletions
3
src/doc/developer-tools/android-sdk/installation/index.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
dependencies { | ||
implementation 'com.paystack.android:paystack-ui:0.0.5' | ||
} |
3 changes: 3 additions & 0 deletions
3
src/doc/developer-tools/android-sdk/payment-sheet-init/config.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
languages: | ||
- kt | ||
- java |
1 change: 1 addition & 0 deletions
1
src/doc/developer-tools/android-sdk/payment-sheet-init/index.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
// TODO: Add snippet |
10 changes: 10 additions & 0 deletions
10
src/doc/developer-tools/android-sdk/payment-sheet-init/index.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
private lateinit var paymentSheet: PaymentSheet | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
|
||
paymentSheet = PaymentSheet(this) { paymentResult -> | ||
// Handle payment result here. | ||
} | ||
|
||
} |
3 changes: 3 additions & 0 deletions
3
src/doc/developer-tools/android-sdk/payment-sheet-launch/config.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
languages: | ||
- kt | ||
- java |
1 change: 1 addition & 0 deletions
1
src/doc/developer-tools/android-sdk/payment-sheet-launch/index.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
// TODO: Add snippet |
4 changes: 4 additions & 0 deletions
4
src/doc/developer-tools/android-sdk/payment-sheet-launch/index.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
fun startPayment() { | ||
val accessCode = initializeTransactionOnServer() | ||
paymentSheet.launch(accessCode) | ||
} |
3 changes: 3 additions & 0 deletions
3
src/doc/developer-tools/android-sdk/payment-sheet-result-full/config.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
languages: | ||
- kt | ||
- java |
19 changes: 19 additions & 0 deletions
19
src/doc/developer-tools/android-sdk/payment-sheet-result-full/index.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
private void onPaymentResult(PaymentSheetResult paymentResult) { | ||
String message; | ||
if (paymentResult instanceof PaymentSheetResult.Cancelled) { | ||
message = "Cancelled"; | ||
} else if (paymentResult instanceof PaymentSheetResult.Failed) { | ||
PaymentSheetResult.Failed failedResult = (PaymentSheetResult.Failed) paymentResult; | ||
Log.e(TAG, failedResult.getError().getMessage() != null ? | ||
failedResult.getError().getMessage() : "Failed", failedResult.getError()); | ||
message = failedResult.getError().getMessage() != null ? | ||
failedResult.getError().getMessage() : "Failed"; | ||
} else if (paymentResult instanceof PaymentSheetResult.Completed) { | ||
Log.d("Payment successful", paymentSheetResult.paymentCompletionDetails.toString()) | ||
message = "Successful"; | ||
} else { | ||
message = ""; | ||
} | ||
|
||
Toast.makeText(this, "Payment " + message, Toast.LENGTH_SHORT).show(); | ||
} |
17 changes: 17 additions & 0 deletions
17
src/doc/developer-tools/android-sdk/payment-sheet-result-full/index.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
private fun paymentComplete(paymentSheetResult: PaymentSheetResult ) { | ||
val message = when (paymentSheetResult) { | ||
PaymentSheetResult.Cancelled -> "Cancelled" | ||
is PaymentSheetResult.Failed -> { | ||
Log.e("Something went wrong", paymentSheetResult.error.message.orEmpty(), paymentSheetResult.error) | ||
paymentSheetResult.error.message ?: "Failed" | ||
} | ||
|
||
is PaymentSheetResult.Completed -> { | ||
// Returns the transaction reference PaymentCompletionDetails(reference={TransactionRef}) | ||
Log.d("Payment successful", paymentSheetResult.paymentCompletionDetails.toString()) | ||
"Successful" | ||
} | ||
} | ||
|
||
Toast.makeText(this, "Payment $message", Toast.LENGTH_SHORT).show() | ||
} |
3 changes: 3 additions & 0 deletions
3
src/doc/developer-tools/android-sdk/payment-sheet-result-init/config.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
languages: | ||
- kt | ||
- java |
1 change: 1 addition & 0 deletions
1
src/doc/developer-tools/android-sdk/payment-sheet-result-init/index.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
// TODO: Add snippet |
5 changes: 5 additions & 0 deletions
5
src/doc/developer-tools/android-sdk/payment-sheet-result-init/index.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import com.paystack.android_sdk.ui.paymentsheet.PaymentSheetResult | ||
|
||
private fun paymentComplete(paymentSheetResult: PaymentSheetResult ) { | ||
|
||
} |