Skip to main content

WeAcceptPayments

Make payments using weaccept.co API and Python.

import

from weacceptpayments.weaccept import WeAcceptAuth, WeAcceptOrder, WeAcceptPayment

- specify auth data

auth = WeAcceptAuth.as_instance(api_key='YOUR_API_KEY')

PLEASE NOTE:

  • NEVER STORE YOUR API_KEY IN YOUR .py FILES, STORE IT IN AN ENVIRONMENT VARIABLE OR .env FILE AND USE python-dotenv

- create your order

order = WeAcceptOrder.as_instance(auth=auth,
                                  merchant_id=auth.merchant_id,
                                  amount_cents=20000,
                                  merchant_order_id='gv12c4ttr',
                                   items=[  
                                           {  
                                             'name': 'taz1',  
                                             'amount_cents': 20000  
                                           }])

What kwargs are allowed? ``

_allowed_kwargs = [  
    'delivery_needed', 'merchant_id', 'amount_cents', 'currency', 'merchant_order_id',  
    'items', 'shipping_data', 'auth', 'auth_token', 'merchant_id'  
]

PLEASE NOTE:

  • Specifying auth (takes in a WeAcceptAuth object) is an alternative way of specifying auth_token and merchant_id, Don't specify both at the same time.

Now you've access to order.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.as_instance(auth_token=auth.auth_token,
                                                 order_id=order.order_id,
                                                 amount_cents=200,
                                                 integration_id=16639,
                                                 billing_data={  
                                                               "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": "whatever",  
                                                               "state": "RANDOM"  
                                                               ))

Now we have access to .token Again, What kwargs are allowed?

_allowed_kwargs = [  
    'amount_cents', 'expiration', 'billing_data', 'currency', 'integration_id',  
    'lock_order_when_paid', 'auth', 'auth_token', 'order', 'order_id'  
]
  • What kwargs are a mandatory?
_MANDATORY_KWARGS = [  
    # amount cents must be specified and the server says duplicate order if it's not.  
    'merchant_order_id', 'merchant_id', 'amount_cents'  
]

PLEASE NOTE:

  • Specifying auth (takes in a WeAcceptAuth object) is an alternative way of specifying auth_token, Don't specify both at the same time.
  • Specifying order (takes in a WeAcceptOrder object) is an alternative way of specifying order_id. Don't specify both at the same time.

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.

  • In each of those objects, You have access to .request, .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.

@TODO

  • Verification of merchant_order_id which is an alpha-numeric value.
  • Verification of shipping data if delivery_needed is specified as True.

Feel free to explore.

Metadata

Release files for weacceptpayments 2.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for weacceptpayments 2.4
File Size Uploaded
weacceptpayments-2.4.tar.gz 7.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for weacceptpayments 2.4
File Interpreter ABI Platform
weacceptpayments-2.4-py3-none-any.whl Python 3 none any Details

Total release size: 27.9 kB

Release files / weacceptpayments-2.4.tar.gz

Download URL weacceptpayments-2.4.tar.gz
Size 7.7 kB
Tags Source
SHA-256 checksum
How to use checksums
dd6cdda45002df932834563464cb6bff4338fe59ab34e3c13fc9c79cd1ef9e55
BLAKE2b-256 checksum
How to use checksums
70676d498b2ad1379d133f98c7264d28aee894e6ca849c90527f538385caae7f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2

Release files / weacceptpayments-2.4-py3-none-any.whl

Download URL weacceptpayments-2.4-py3-none-any.whl
Size 20.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9998117ec53dcf40528efe02f7aef3be4906cc97da86abcb6a0042c2c45aec84
BLAKE2b-256 checksum
How to use checksums
eee9e2a60495452dfab644ccdcb7769136343dadffe5e4638020558b610d3751
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2

Release history Release notifications | RSS feed

This release

2.4 This release

2 release files

2.3

2 release files

2.2

2 release files

2.1

2 release files

2.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page