Skip to content

A Python library that allows you to quickly and easily add YenePay as a payment method in your project.

License

Notifications You must be signed in to change notification settings

backostech/yenepay.sdk.python

Repository files navigation

ᴘʏᴛʜᴏɴ sᴅᴋ | ᴜɴᴏғғɪᴄɪᴀʟ

test-status linter-status publication-status PyPi Package Version PyPi status Downloads Supported python versions Documentation Status Github issues MIT License

This library allows you to quickly and easily add YenePay as a payment method using Python

We encourage you to read through this document to get the most our of what this library has to offer. We want this library to be community driven and we really appreciate any support we can get from the community.

Getting Started

These instructions will guide you on how to develop and test YenePay's payment method integration with your Python application. YenePay have setup a sandbox environment for you to test and play around the integration process. To learn more about this, please visit yenepay community site: https://community.yenepay.com/

Pre-requisite

To add YenePay to your application and start collecting payments, you will first need to register on YenePay as a merchant and get your seller code. You can do that from https://www.yenepay.com/merchant

Installation

Option 1: Using PyPI

pip install yenepay

Option 2: Directly from GitHub

  • Clone package into local folder and change director
git clone [email protected]:backostech/yenepay.sdk.python.git
cd yenepay.sdk.python/
  • Install using python setuptools
python setup.py .

Basic Usage

Creating client

  • Inorder to use any feature from this package, first you have to create a client instance.
from yenepay import Client

MERCHANT_ID = "0000"

client = Client(MERCHANT_ID) # Return client instance

Creating express checkout

  • Inorder to process a single item you can checkout using express checkout
from yenepay import Client, Item

client = Client(merchant_id="0000", token="abcd")

item = Item("PC", 42_000.00, 1)

express_checkout = client.get_cart_checkout(
    items=[item],
    use_sandbox=True,
)

checkout_url = express_checkout.get_url()

print(checkout_url)

This is the same as the above one

from yenepay import Client, Item, ExpressCheckot

client = Client(merchant_id="0000", token="abcd")

item = Item("PC", 42_000.00, 1)

express_checkout = ExpressCheckot(
    client, item, use_sandbox=True,
)

checkout_url = express_checkout.get_url()

print(checkout_url)

Creating cart checkout

  • Cart checkout are used for multiple items checkout.
from yenepay import Client, Item, Cart

MERCHANT_ID = "0000"

client = Client(MERCHANT_ID)

# Create carts to store items.
cart = Cart(
    Item("PC_1", 50_000.00, 1),
    Item("PC_2", 20_000.00, 3),
    Item("PC_3", 10_000.00, 4),
    Item("PC_4", 150_000.00, 2),
)

print(cart.total_price) # returns total of cart items unit price

cart_checkout = client.get_cart_checkout(items=cart)

checkout_url = cart_checkout.get_url()  # Return link for payment, if success

print(checkout_url)

Or you can use CartCheckout class

from yenepay import Client, Item, Cart, CartCheckout

MERCHANT_ID = "0000"

client = Client(MERCHANT_ID)

# Create carts to store items.
cart = Cart(
    Item("PC_1", 50_000.00, 1),
    Item("PC_2", 20_000.00, 3),
    Item("PC_3", 10_000.00, 4),
    Item("PC_4", 150_000.00, 2),
)

cart_checkout = CartCheckout(client, cart)

checkout_url = cart_checkout.get_url()  # Return link for payment, if success

print(checkout_url)

You can send list of items into a class if you want

items = [
    Item("PC_1", 50_000.00, 1),
    Item("PC_2", 20_000.00, 3),
    Item("PC_3", 10_000.00, 4),
    Item("PC_4", 150_000.00, 2),
]

cart_checkout = client.get_cart_checkout(items=items)

PDT

  • You can check your payment order status using PDT class
from yenepay import Client

client = Client(merchant_id="0000", token="abcd")

merchant_order_id = "0000"  # Give when you create checkout url

transaction_id = "abcd"  # Send from yenepay when payment is successfull

response = client.check_pdt_status(merchant_order_id, transaction_id)

if response.result == "SUCCESS" and response.status == "Paid":
    print("Payment Completed By: {}".format(response.buyer_id))

If you have an instance of checkout, that create a link you can use

from yenepay import Client, Item

client = Client(merchant_id="0000", token="abcd")

merchant_order_id = "0000"

transaction_id = "abcd"

express_checkout = client.get_express_checkout(
        client,
        Item("PC-1", 50_000.00, 1),
        merchant_order_id=merchant_order_id,
        success_url="localhost:8000", # Url, transaction id will be sent,
    )

pdt_response = express_checkout.check_pdt_status(transaction_id)

# The rest of you process can run here.
...

Contact

Don't hesitate to contact us, either in person or through our call centers.

[email protected]

Backos Technologies

+251910900879


                                                  ᴀ ᴛᴇᴄʜ ʏᴏᴜ ᴄᴀɴ ᴛʀᴜsᴛ

© Copyright Backos Technologies. All Rights Reserved

About

A Python library that allows you to quickly and easily add YenePay as a payment method in your project.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages