Search in sources :

Example 1 with MerchantAction

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");
    }
}
Also used : InvalidParameterException(java.security.InvalidParameterException) PaymentProduct(com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.PaymentProduct) BasicPaymentProduct(com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.BasicPaymentProduct) Serializable(java.io.Serializable) InputStreamReader(java.io.InputStreamReader) Reader(java.io.Reader) InputStreamReader(java.io.InputStreamReader) Gson(com.google.gson.Gson) Intent(android.content.Intent) MerchantAction(com.globalcollect.gateway.sdk.client.android.exampleapp.model.MerchantAction)

Aggregations

Intent (android.content.Intent)1 MerchantAction (com.globalcollect.gateway.sdk.client.android.exampleapp.model.MerchantAction)1 BasicPaymentProduct (com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.BasicPaymentProduct)1 PaymentProduct (com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.PaymentProduct)1 Gson (com.google.gson.Gson)1 InputStreamReader (java.io.InputStreamReader)1 Reader (java.io.Reader)1 Serializable (java.io.Serializable)1 InvalidParameterException (java.security.InvalidParameterException)1