Skip to content

The Enzona Payment Embedded is a lightweight Kotlin library designed to simplify integration with the Enzona payment system in Android applications.

Notifications You must be signed in to change notification settings

jdsdhp/enzona-payment-embedded

Repository files navigation

Enzona Logo

Enzona Payment Embedded

JitPack License API X

💸️ The Enzona Payment Embedded is a lightweight Kotlin library designed to simplify integration with the Enzona payment system in Android applications. This library is built on top of several foundational libraries, including:

  • Gson: A library for JSON serialization and deserialization.
  • OkHttp: An HTTP client for making network requests.
  • Kotlin Coroutines: A library for asynchronous programming in Kotlin using coroutines.

Documentation

The development of this library was guided by the official Enzona API documentation, which provides comprehensive information about the Enzona Payment API.

Including in your project

Gradle

dependencyResolutionManagement {
	repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
	repositories {
		mavenCentral()
		maven { url 'https://jitpack.io' }
	}
}

dependencies {
    // Replace 'TAG' with the current version of the library.
    implementation 'com.github.jdsdhp:enzona-payment-embedded:TAG'
}

Usage

1. Initialization

Initialize the Enzona Payment Embedded in your application by calling the initialize method. Provide the appropriate values for the API URL, merchant consumer key, consumer secret, and merchant UUID.

Enzona.getInstance().initialize(
    apiUrl = Enzona.ApiUrl.OFFICIAL,
    merchantConsumerKey = "your_consumer_key",
    merchantConsumerSecret = "your_consumer_secret",
    merchantUUID = "your_merchant_uuid",
)

Note: The authentication step is optional and only required if you want to validate the data during initialization.

2. Authentication (Optional)

Authenticate using Enzona credentials by calling the authenticate method. This step is particularly useful if you want to verify the validity of the provided merchant credentials.

val authenticationResult: ResultValue<Token> = Enzona.getInstance().authenticate()

Note: Handling authentication errors is crucial for ensuring a secure integration.

3. Creating a Payment

Create a payment using the createPayment method. Provide details such as discount, shipping, tip and other necessary parameters.

val paymentResult: ResultValue<Payment> = Enzona.getInstance().createPayment(
    discount = 10.0,
    shipping = 5.0,
    tip = 2.0,
    // ... other parameters
    items = listOf(item1, item2, item3)
)

4. Getting Payment Details

Retrieve payment details using the getPaymentDetails method with the transaction_uuid.

val paymentResult: ResultValue<Payment> = Enzona.getInstance().getPaymentDetails("transaction_uuid")

5.Cancelling a Payment

Cancel a payment using the cancelPayment method with the transaction_uuid.

val paymentResult: ResultValue<Payment> = Enzona.getInstance().cancelPayment("transaction_uuid")

5.Completing a Payment

Complete a payment using the completePayment method with the transaction_uuid.

val completeResult: ResultValue<Payment> = Enzona.getInstance().completePayment("transaction_uuid")

Note: Ensure that you handle the asynchronous nature of some functions appropriately, as indicated by the use of suspend in function signatures.

Sample project

It's very important to check out the sample app. Most techniques that you would want to implement are already implemented in the examples.

View the sample app's source code here

Enzona Logo

Upcoming Features

  • Confirm a payment
  • Obtain details of a refund
  • Obtain a list of refunds
  • Obtain a list of completed payments
  • Perform checkout for a payment
  • Create a receive code
  • List refunds for a payment
  • Pay for a product
  • Create a payment order
  • Initiate a payment refund

License

Copyright (c) 2024 jesusd0897.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

About

The Enzona Payment Embedded is a lightweight Kotlin library designed to simplify integration with the Enzona payment system in Android applications.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages