Created
June 8, 2017 06:44
-
-
Save runemart/1ff98004b32c46cbbd052acb64a482cd to your computer and use it in GitHub Desktop.
Mobile pay simple integration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Click(R.id.povh_mobilepay_view) | |
protected void onMobilePayClick() { | |
if (MobilePay.getInstance().isMobilePayInstalled(getApplicationContext())) { | |
Payment payment = new Payment(); | |
payment.setProductPrice(new BigDecimal(ticketOrderRequest.getSum())); | |
// TODO Add proper payment details | |
payment.setOrderId("foobar"); | |
startActivityForResult(MobilePay.getInstance().createPaymentIntent(payment), REQUEST_MOBILEPAY_PAYMENT); | |
} else { | |
startActivity(MobilePay.getInstance().createDownloadMobilePayIntent(getApplicationContext())); | |
} | |
} | |
@OnActivityResult(REQUEST_MOBILEPAY_PAYMENT) | |
protected void onMobilePayResult(int resultCode, Intent data) { | |
MobilePay.getInstance().handleResult(resultCode, data, new ResultCallback() { | |
@Override | |
public void onSuccess(SuccessResult result) { | |
// TODO: verify with backend and download tickets | |
} | |
@Override | |
public void onFailure(FailureResult result) { | |
Toast.makeText(PaymentActivity.this, result.getErrorMessage(), Toast.LENGTH_SHORT).show(); | |
} | |
@Override | |
public void onCancel() { | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment