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


Download files

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

Source Distribution

weacceptpayments-2.0.tar.gz (4.8 kB view hashes)

Uploaded Source

Built Distribution

weacceptpayments-2.0-py3-none-any.whl (6.1 kB view hashes)

Uploaded Python 3

Supported by

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