Skip to content

Commit

Permalink
configure payment gateway
Browse files Browse the repository at this point in the history
  • Loading branch information
steveww committed Dec 18, 2018
1 parent e66160f commit 86bd770
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# environment file for docker-compose
REPO=robotshop
TAG=0.3.2
TAG=0.3.3
3 changes: 3 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 4 additions & 2 deletions payment/payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

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():
Expand All @@ -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())
Expand Down Expand Up @@ -82,5 +83,6 @@ def queueOrder(order):
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)
2 changes: 1 addition & 1 deletion web/static/payment.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ <h3>Review your order</h3>
</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>
Expand Down

0 comments on commit 86bd770

Please sign in to comment.