configure payment gateway

This commit is contained in:
Steve Waterworth
2018-12-18 12:51:11 +00:00
parent e66160f91a
commit 86bd770415
4 changed files with 9 additions and 4 deletions

2
.env
View File

@@ -1,3 +1,3 @@
# environment file for docker-compose
REPO=robotshop
TAG=0.3.2
TAG=0.3.3

View File

@@ -107,6 +107,9 @@ services:
- rabbitmq
networks:
- robot-shop
# Uncomment to change payment gateway
#environment:
#PAYMENT_GATEWAY: "https://www.worldpay.com"
deploy:
replicas: 1
restart_policy:

View File

@@ -16,6 +16,7 @@ app = Flask(__name__)
CART = os.getenv('CART_HOST', 'cart')
USER = os.getenv('USER_HOST', 'user')
PAYMENT_GATEWAY = os.getenv('PAYMENT_GATEWAY', 'https://paypal.com/')
@app.route('/health', methods=['GET'])
def health():
@@ -28,8 +29,8 @@ def pay(id):
app.logger.info(cart)
# dummy call to Paypal, hope they dont object
req = requests.get('https://paypal.com/')
app.logger.info('paypal returned {}'.format(req.status_code))
req = requests.get(PAYMENT_GATEWAY)
app.logger.info('{} returned {}'.format(PAYMENT_GATEWAY, req.status_code))
# Generate order id
orderid = str(uuid.uuid4())
@@ -82,5 +83,6 @@ if __name__ == "__main__":
sh.setLevel(logging.INFO)
app.logger.addHandler(sh)
app.logger.setLevel(logging.INFO)
app.logger.info('Payment gateway {}'.format(PAYMENT_GATEWAY))
port = int(os.getenv("SHOP_PAYMENT_PORT", "8080"))
app.run(host='0.0.0.0', port=port)

View File

@@ -28,7 +28,7 @@
</tr>
<tr>
<td colspan="3">
<button ng-disabled="data.buttonDisabled" ng-click="pay();">Pay with Paypal</button>
<button ng-disabled="data.buttonDisabled" ng-click="pay();">Pay Now</button>
</td>
</tr>
</table>