From ef18bb0b9facc2d85db138dd65720c14a33953c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isma=C3=ABl=20Bouya?= Date: Mon, 18 Dec 2017 14:42:42 +0100 Subject: Finish payment process for buying vps server --- python/buy_vps_server.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'python') diff --git a/python/buy_vps_server.py b/python/buy_vps_server.py index 2803e32..44ae786 100644 --- a/python/buy_vps_server.py +++ b/python/buy_vps_server.py @@ -48,7 +48,16 @@ order = client.post('/order/cart/{}/checkout'.format(cart_id), order_id = order["orderId"] print(order_id) -# Suite à tester : -# /me/order/{orderId}/availableRegisteredPaymentMean -# /me/paymentMean ? /me/order/{orderId}/debt/pay ? +payment_mean = client.get('/me/order/{}/availableRegisteredPaymentMean'.format(order_id))[0]['paymentMean'] +payment_mean_id = client.get('/me/paymentMean/{}'.format(payment_mean))[0] +payment_mean_status = client.get('/me/paymentMean/{}/{}'.format(payment_mean, payment_mean_id)) + +if payment_mean_status["state"] != "valid": + raise "Bouh" + +paid_order = client.post('/me/order/{}/payWithRegisteredPaymentMean'.format(order_id), + paymentMean=payment_mean, paymentMeanId=payment_mean_id) + +if 'paymentDate' in paid_order: + print("successful") -- cgit v1.2.3