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)
Built Distribution
Close
Hashes for weacceptpayments-2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 98a326785a04ffd79ddf2ad80938f2862dac0b635ddcd687cdb383ca6df99a7e |
|
MD5 | b95228f47f9999ade8c2af10a53507fd |
|
BLAKE2b-256 | 5b3c531ce2be08c9ebf2aa649a5905659666404fe060ad3a04a9036f90ee4762 |