Skip to main content

Make payments using weaccept.co API and Python.

Project description

WeAcceptPayments

Make payments using weaccept.co API and Python.

import

from weacceptpayments.weaccept import WeAcceptAuth, WeAcceptOrder, WeAcceptPayment

specify auth data

auth = WeAcceptAuth('YOUR_API_KEY')

start auth process

auth.start()

create your order

order = WeAcceptOrder(auth, {}, 'SPECIFY_A_MERCHANT_ORDER_ID', 200)

Order it

order.order()

Now the order will get an order.id,

DONT TRY TO CREATE THE SAME ORDER TWICE.

In case you did, order.id won't be created and you have to specify it manually. This is not a bug, When you create the order twice, The server returns 'duplicate' in the second time, And order.id is not in the response so you need to specify it manually.

specify payment data

payment = WeAcceptPayment(auth, order, {}, {
         "apartment": "803",
         "email": "test@example.com",
         "floor": "42",
         "first_name": "LeOndaz",
         "street": "Python community",
         "building": "8028",
         "phone_number": "+0123456789",
         "shipping_method": "PKG",
         "postal_code": "01898",
         "city": "Jaskolskiburgh",
         "country": "CR",
         "last_name": "Nicolas",
         "state": "Utah"
    }, 13102, 200)

start payment

payment.start()

print(payment.token) # prints the token

Now, add an iFrame with the integration_id of the card in your payment integrations section and the payment_token you got from here.

Tada! This is magic btw.

API Reference:

  • WeAcceptAuth(api_key)
  • WeAcceptOrder(self,
                     we_accept_auth_object,
                     order_data,
                     merchant_order_id,
                     amount_cents,
                     currency='EGP',
                     shipping_data=None,
                     delivery_needed=False)
  • WeAcceptPayment(self,
                     we_accept_auth_object,
                     order_data,
                     merchant_order_id,
                     amount_cents,
                     currency='EGP',
                     shipping_data=None,
                     delivery_needed=False)

In each of those objects, You have access to .requrest, .response, .headers, other things too (Explore or use intellicode)

In each of those objects, You can access the response as obj[key] BUT after you call .start() otherwise, Exceptions are raised.

Feel free to explore.

Project details


Release history Release notifications

This version

2.0

Download files

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

Files for weacceptpayments, version 2.0
Filename, size File type Python version Upload date Hashes
Filename, size weacceptpayments-2.0-py3-none-any.whl (6.1 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size weacceptpayments-2.0.tar.gz (4.8 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page