use of com.globalcollect.gateway.sdk.client.android.exampleapp.model.MerchantAction in project connect-sdk-client-android by Ingenico-ePayments.
the class PaymentProductSelectionActivity method retrievePaymentProductFieldsBcmc.
private void retrievePaymentProductFieldsBcmc(PaymentItem bcmc) {
if (PAYMENTPRODUCTID_BanContact.equals(bcmc.getId())) {
// Because the BanContact payment product (BCMC, PPid 3012) has, apart from regular
// credit card inputFields, other ways for the customer to complete the transaction, it
// is required that a payment is created first, before rendering the Input Fields. A create
// payment call cannot be made via this Client 2 Server API, but should be made from your
// payment server instead. You should add code here that triggers that payment and then
// have the result sent back to the Client.
// Since this is an example application, we will simply pretend that the call has been
// made and load an example JSON response from the resources. This resource is not the
// full createPaymentResponse, but only the MerchantAction, which contains the fields and
// showdata required to render the qrCode/button for BCMC.
Reader reader = new InputStreamReader(getResources().openRawResource(R.raw.bcmc_merchantaction_example));
MerchantAction bcmcMerchantActionExample = new Gson().fromJson(reader, MerchantAction.class);
// Add the payment product fields from the merchantAction to the payment item, so that the
// DetailInputActivity can render them as usual.
((PaymentProduct) bcmc).setPaymentProductFields(bcmcMerchantActionExample.getFormFields());
Intent bcmcDetailInputActivityIntent = new Intent(this, DetailInputActivityBCMC.class);
bcmcDetailInputActivityIntent.putExtra(Constants.INTENT_SELECTED_ITEM, bcmc);
bcmcDetailInputActivityIntent.putExtra(Constants.INTENT_BCMC_SHOWDATA, ((Serializable) bcmcMerchantActionExample.getShowData()));
startNextActivity(bcmcDetailInputActivityIntent);
} else {
throw new InvalidParameterException("Can not retrieve fields for BCMC, payment item is not BCMC");
}
}
Aggregations