]> git.immae.eu Git - perso/Immae/Projets/Puppet.git/commitdiff
Finish payment process for buying vps server
authorIsmaël Bouya <ismael.bouya@normalesup.org>
Mon, 18 Dec 2017 13:42:42 +0000 (14:42 +0100)
committerIsmaël Bouya <ismael.bouya@normalesup.org>
Mon, 18 Dec 2017 13:42:42 +0000 (14:42 +0100)
python/buy_vps_server.py

index 2803e32b3bd7c835c043350e2123142e9c7a6bbe..44ae78627e1e8e5672e0b2a86944655fbd5dfbc7 100644 (file)
@@ -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")