Skip to main content

Unofficial Python SDK for YenePay (https://yenepay.com) payment integration

Project description

ᴘʏᴛʜᴏɴ 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 git@github.com: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.

info@backostech.com

Backos Technologies

+251910900879


𝔹𝕒𝕔𝕜𝕠𝕤 𝕋𝕖𝕔𝕙𝕟𝕠𝕝𝕠𝕘𝕚𝕖𝕤

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

© Copyright Backos Technologies. All Rights Reserved

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

yenepay-0.3.0a0.tar.gz (15.2 kB view details)

Uploaded Source

File details

Details for the file yenepay-0.3.0a0.tar.gz.

File metadata

  • Download URL: yenepay-0.3.0a0.tar.gz
  • Upload date:
  • Size: 15.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.10

File hashes

Hashes for yenepay-0.3.0a0.tar.gz
Algorithm Hash digest
SHA256 0ac2109081b21dcb18b5654c00dbe401e1432af320117eaa836ce86ebf018895
MD5 08d9b72b9af8cb0ae78e0727a2bab0f5
BLAKE2b-256 44a01cccbf9ea4bd143243edcb91fd02d6b6cc26cfc89397cbdd11b92dad9ad6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page