-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: Updated documentations and instructions
- Loading branch information
1 parent
d025527
commit 144ee65
Showing
8 changed files
with
194 additions
and
146 deletions.
There are no files selected for viewing
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
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 @@ | ||
# Registration | ||
|
||
To register a new shop, please download [**Tezro**](https://tezro.com/) mobile app or use the web/desktop version. | ||
|
||
## When you open the app you will be asked to sign in: | ||
![Welcome Screen](./screens/authorization_screen.jpg) | ||
|
||
Create a new account or use your existing one. | ||
|
||
## After completing authorization steps, head to the settings tab, then click on **External Shop**: | ||
![Settings Tab](./screens/settings_screen.jpg) | ||
|
||
## This will proceed you to a registration form, enter your shop's data: | ||
![External Shop Screen](./screens/shop_creation_screen.jpg) | ||
|
||
## After completing the form, please click save to receive your `KeyId` and `Secret`: | ||
![External Shop Screen](./screens/shop_details_screen.jpg) | ||
|
||
## That's it! You are now ready to use the api! |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,45 @@ | ||
# Usage - JVM (Desktop/Backend) | ||
Before using this library you have to initialize it using your `KeyId` and `Secret` if you are willing to call private methods. | ||
|
||
Create a new instance of shop service: | ||
```kotlin | ||
val shopService = Shop.initShopService( | ||
keyId = "your-key-id-goes-here", | ||
secret = "your_secret_goes_here", | ||
isTestMode = true | ||
) | ||
``` | ||
|
||
`isTestMode` indicates whether to use development or production API. To get a development `keyId` and `secret` you need to download Tezro-dev version and retrieve them from there. | ||
|
||
`initShopService` will always give you a new instance of `IShopService`. Creating a new instance might not be cheap so it is recommended to implement singleton pattern. | ||
|
||
Once you create an instance of the service, you can call any method depending on the access level you provide `(KeyId + Secret = Full Access`. | ||
|
||
Here's an example of creating a new order: | ||
```kotlin | ||
//Create a request | ||
val request = shopService.createOrder( | ||
orderId = UUID.randomUUID().toString(), | ||
name = "Test order ${Random().nextInt()}", | ||
amount = "1", | ||
currency = Order.Currency.USD, | ||
confirmAmountUrl = "https://www.google.com", | ||
expiryDate = Date(System.currentTimeMillis() + 100000), | ||
photos = listOf("https://prod-buydo.oss-accelerate.aliyuncs.com/9a537dfd2e9a493f8fef4d35d119a43b.jpg"), | ||
attributes = listOf(Attribute("Color", "Red")) | ||
) | ||
|
||
//Set up listeners to your request and enqueue it | ||
request.setSuccessListener { order -> | ||
//Handle your new order | ||
}.setErrorListener { error -> | ||
//Handle errors | ||
}.enqueue() | ||
|
||
//To cancel your request call | ||
request.cancel() | ||
``` | ||
|
||
The request will run on a background thread, so no need to worry about blocking the current thread. | ||
Follow this **[Link](../../docs/shop/shop/com.tezro.api.shop.service/-i-shop-service/index.md)** to check all methods that you can call through this service. |
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,107 @@ | ||
# Usage - Android Widget | ||
|
||
Before using this library you have to initialize it using your `KeyId`. | ||
|
||
Initialization needs to happen only onces during your application's lifetime: | ||
```kotlin | ||
class MyApplication : Application() { | ||
override fun onCreate() { | ||
super.onCreate() | ||
ShopWidget.init(keyId = "your-key-id-goes-here", isTestMode = true) | ||
} | ||
} | ||
``` | ||
|
||
`isTestMode` indicates whether to use development or production API. To get a development `keyId` you need to download Tezro-dev version and retrieve them from there. | ||
|
||
Integrating `TezroPayButton` to your view: | ||
```xml | ||
<com.tezro.api.shop.widget.views.TezroPayButton | ||
android:id="@+id/btnTezroPay" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content"/> | ||
``` | ||
|
||
Customize the button (currently only through code, xml attributes will be available in future updates): | ||
```kotlin | ||
tezroPayButton.apply { | ||
buttonLabel = "1 USD" | ||
isAutomaticRedirectEnabled = true | ||
isQRCodeEnabled = false | ||
isSilentUpdate = false | ||
paymentQRLabel = "Scan this QR and pay!" | ||
} | ||
``` | ||
|
||
Follow this [**Link**](../../docs/shop-android-widget/shop-android-widget/com.tezro.api.shop.widget.views/-tezro-pay-button/index.md) to read more about these properties | ||
|
||
Implement `TezroPayButton.TezroPayButtonDelegate` to listen to events: | ||
```kotlin | ||
override fun onRequestOrderInit() { | ||
//Indicates that user has clicked but no order data was provided | ||
tezroPayButton.initOrder( | ||
orderId = UUID.randomUUID().toString(), | ||
name = "Test order ${Random().nextInt()}", | ||
amount = "1", | ||
currency = Order.Currency.USD, | ||
confirmAmountUrl = "https://www.google.com", | ||
expiryDate = Date(System.currentTimeMillis() + 100000), | ||
photos = listOf("https://prod-buydo.oss-accelerate.aliyuncs.com/9a537dfd2e9a493f8fef4d35d119a43b.jpg"), | ||
attributes = listOf(Attribute("Color", "Red")) | ||
) | ||
} | ||
|
||
override fun onLoadingOrderStart() { | ||
//Called after `tezroPayButton.initOrder`, indicates that loading order has started | ||
showToast("Creating order...") | ||
} | ||
|
||
override fun onNewOrderDataLoaded(order: Order) { | ||
//Called when loading order finishes, this is a suitable place to check for new status | ||
when(order.status) { | ||
Order.Status.CREATED -> TODO() | ||
Order.Status.EXPIRED -> TODO() | ||
Order.Status.ADDRESS_CONFIRMED -> TODO() | ||
Order.Status.CONFIRMED -> TODO() | ||
Order.Status.DELIVERED -> TODO() | ||
Order.Status.RECEIVED -> TODO() | ||
Order.Status.DISPUTED -> TODO() | ||
} | ||
} | ||
|
||
override fun onLoadingOrderError(error: Error) { | ||
//Called when loading order fails, show error to the users | ||
showToast("Something went wrong $error...") | ||
} | ||
``` | ||
|
||
Assign it to your button using: | ||
```kotlin | ||
tezroPayButton.delegate = myDelegateImplementation | ||
``` | ||
|
||
To update button data when users come back to your app, call this in your `onResume`: | ||
```kotlin | ||
override fun onResume() { | ||
super.onResume() | ||
tezroPayButton.updateOrder() | ||
} | ||
``` | ||
|
||
You can manually set orders to this button using: | ||
```kotlin | ||
tezroPayButton.order = myOrder | ||
``` | ||
This is suitable if you want load your data using our JVM implementation while respecting your architecture rules. | ||
|
||
`TezroPayButton` is an open class, all methods and properties are open so you can extend it and customize it the way it suits you. | ||
```kotlin | ||
class CustomTezroButton( | ||
context: Context, | ||
attributeSet: AttributeSet | ||
) : TezroPayButton(context, attributeSet) { | ||
... | ||
} | ||
``` | ||
|
||
`TezroPayButton` uses XML resources for styles, colors and size. You can override these resources to customize your button within your resources. |