Skip to content

Commit

Permalink
PAY-1539 Updated demo app to reference additional Android Pay info.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sven Resch committed Jun 28, 2017
1 parent 7d5c14b commit 5a44c91
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 22 deletions.
53 changes: 43 additions & 10 deletions README.md
Expand Up @@ -63,21 +63,23 @@ $ source venv/bin/activate
(venv) app$ python server.py
```

# iOS Client

The iOS client project was built with XCode 8 and requires Swift 3.0.
# Mobile Payment Clients

<img width="83" height="53" align="right" src="http://images.apple.com/v/apple-pay/f/images/overview/apple_pay_logo_large_2x.png">

The Apple Pay payment request flows from the iOS client and then, if successful, an Apple Pay token is
transmitted to the demo merchant server, which records the payment request and executes the Bambora
Apple Pay or Android Pay payment requests are initiated from mobile clients and then, if successful, an Apple Pay or
Android Pay token is transmitted to the demo payment server, which records the payment request and executes the Bambora
Payments API.

In your production flow, a mobile client might transmit other info such as the customer identifier,
detailed sales/inventory data, and related shipping and billing addresses. This info might be recorded
on a merchants CRM (as an example), and then a request to process the payment using the Apple Pay token
would then be made to the Bambora Payments API. Upon success or failure to process the payment, the
merchant’s CRM could be updated and the originating mobile client would then receive a response.
on a merchants CRM (as an example), and then a request to process the payment using the Apple Pay or
Android Pay token would then be made to the Bambora Payments API. Upon success or failure to process
the payment, the merchant’s CRM could be updated and the originating mobile client would then receive a response.

# iOS Client

The iOS client project was built with XCode 8 and requires Swift 3.0.

<img width="83" height="53" align="right" src="http://images.apple.com/v/apple-pay/f/images/overview/apple_pay_logo_large_2x.png">

For details on how to develop Apple Pay enabled apps please visit:

Expand All @@ -102,6 +104,35 @@ payload = {
}
```

# Android Client

The Android client project was built with Android Studio v2.3.1.

<img width="120" align="right" src="https://www.android.com/static/2016/img/pay/androidpaylogo-outlined.png">

For details on how to develop Android Pay enabled apps please visit:

https://developers.google.com/android-pay/

## Android Pay and the Bambora Payments API

When an Android Pay client makes a payment request, it first gets an Android Pay payment token using standard Android
SDK APIs. It then communicates this info to the Demo Server which is responsible for interacting with the
Bambora Payments API. The Bambora Payments API has been updated to allow for Android Pay transactions
and the following is a sample POST parameter to use with a RESTful invocation of the Payments API.

```
payload = {
'amount': float(<purchase_amount>),
'payment_method': 'android_pay',
'android_pay': {
'apple_pay_merchant_id': <your_android_pay_merchant_id>,
'payment_token': <apple_pay_base64_encoded_token>,
'complete': <true (Defaults to true if omitted. Used for a purchase) | false (Used for a Pre-Auth.)>
}
}
```

---

<a name="contributing"/>
Expand All @@ -120,3 +151,5 @@ payload = {
* [Getting Started with Apple Pay](https://developer.apple.com/apple-pay/get-started/)
* [Apple Pay Programming Guide](https://developer.apple.com/library/content/ApplePay_Guide/)
* [Apple Pay Sandbox Testing](https://developer.apple.com/support/apple-pay-sandbox/)
* [Android Pay @ Bambora](https://dev.na.bambora.com/docs/guides/android_pay/)
* [Getting Started with Android Pay](https://www.android.com/pay/)
Expand Up @@ -35,9 +35,9 @@ MIT License (MIT)

public class PaymentHelper {

// For a sample Merchant Server implementation check out:
// https://github.com/bambora/na-merchant-api-demo
private static String baseURL = "https://your.merchant.server.com";
// For a sample Payment APIs Server implementation check out:
// https://github.com/bambora/na-payment-apis-demo
private static String baseURL = "https://your.payment.server.com";

public interface PaymentService {
@POST("/payment/mobile/process/android-pay")
Expand Down
2 changes: 1 addition & 1 deletion server/Dockerfile
@@ -1,4 +1,4 @@
# Bambora na-merchant-api-demo
# Bambora na-payment-apis-demo

FROM python:3.6.0-alpine

Expand Down
2 changes: 1 addition & 1 deletion server/Makefile
@@ -1,7 +1,7 @@
REPO_BASE=056252067802.dkr.ecr.us-west-2.amazonaws.com
APP_NAME=na-merchant-api-demo
IMAGE_NAME=bambora/$(APP_NAME)
VERSION=0.0.8
VERSION=1.0.0
EB_BUCKET=eb-docker-deploy
EB_APP_ENV_NAME=$(APP_NAME)
ZIP=$(EB_APP_ENV_NAME).zip
Expand Down
6 changes: 3 additions & 3 deletions server/app/blueprints/mobile.py
Expand Up @@ -69,7 +69,7 @@ def process_payment(wallet_type):
# name = request.json.get('name')
transaction_type = request.json.get('transaction-type')
apple_merchant_id = 'merchant.com.beanstream.apbeanstream'
android_app_id = 'com.bambora.na.mobilepay'
android_merchant_id = 'com.bambora.na.mobilepay'
payment_token = request.json.get('payment-token')

if transaction_type != "purchase" and transaction_type != "pre-auth":
Expand All @@ -79,7 +79,7 @@ def process_payment(wallet_type):
if amount is None \
or transaction_type is None \
or (payment_method == db.WalletType.apple_pay and apple_merchant_id is None) \
or (payment_method == db.WalletType.android_pay and android_app_id is None) \
or (payment_method == db.WalletType.android_pay and android_merchant_id is None) \
or payment_token is None:

return error400('Expected params not found.')
Expand Down Expand Up @@ -112,7 +112,7 @@ def process_payment(wallet_type):
'amount': float(amount),
'payment_method': 'android_pay',
'android_pay': {
'android_pay_app_id': android_app_id,
'android_pay_merchant_id': android_merchant_id,
'payment_token': payment_token,
'complete': complete
}
Expand Down
2 changes: 1 addition & 1 deletion server/app/server.py
Expand Up @@ -21,7 +21,7 @@


# Setup a logger
logger = logging.getLogger('Merchant-API-Demo')
logger = logging.getLogger('Payment-APIs-Demo')
logger.setLevel(logging.WARNING)

# Create a Flask app.
Expand Down
2 changes: 1 addition & 1 deletion server/app/templates/3ds.html
Expand Up @@ -11,7 +11,7 @@ <h1>Payment APIs Demo</h1>
<p>This payment form is for demo purposes only. It will not charge any cards.
The UI is intended to demonstrate the different payment experiences for end user.
The open code base is intended to act as a sample integration for developers to reference.
You can view the source <a href="https://github.com/bambora/na-merchant-api-demo" target="_blank">here</a>.
You can view the source <a href="https://github.com/bambora/na-payment-apis-demo" target="_blank">here</a>.
</p>

<form>
Expand Down
2 changes: 1 addition & 1 deletion server/app/templates/checkout.html
Expand Up @@ -11,7 +11,7 @@ <h1>Payment APIs Demo</h1>
<p>This payment form is for demo purposes only. It will not charge any cards.
The UI is intended to demonstrate the different payment experiences for end user.
The open code base is intended to act as a sample integration for developers to reference.
You can view the source <a href="https://github.com/bambora/na-merchant-api-demo" target="_blank">here</a>.
You can view the source <a href="https://github.com/bambora/na-payment-apis-demo" target="_blank">here</a>.
</p>

<form id="order-form">
Expand Down
2 changes: 1 addition & 1 deletion server/app/templates/index.html
Expand Up @@ -11,7 +11,7 @@ <h1>Payment APIs Demo</h1>
<p>This payment form is for demo purposes only. It will not charge any cards.
The UI is intended to demonstrate the different payment experiences for end user.
The open code base is intended to act as a sample integration for developers to reference.
You can view the source <a href="https://github.com/bambora/na-merchant-api-demo" target="_blank">here</a>.
You can view the source <a href="https://github.com/bambora/na-payment-apis-demo" target="_blank">here</a>.
</p>

<form>
Expand Down

0 comments on commit 5a44c91

Please sign in to comment.