Search in sources :

Example 1 with PaymentProduct

use of com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.PaymentProduct in project connect-sdk-client-android by Ingenico-ePayments.

the class DetailInputActivityCreditCards method onClick.

/**
 * This method is invoked when the user selects a different payment product from the CoBrand
 * notification view.
 */
@Override
public void onClick(View view) {
    // Retrieve the PaymentProduct from the view
    PaymentProduct paymentProduct = (PaymentProduct) view.getTag();
    // Update the logo in the edit text
    fieldView.renderPaymentProductLogoInCreditCardField(paymentProduct.getId());
    // Update the request to use the new paymentProduct
    inputDataPersister.setPaymentItem(paymentProduct);
    retrieveNewPaymentProduct(paymentProduct.getId());
}
Also used : PaymentProduct(com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.PaymentProduct)

Example 2 with PaymentProduct

use of com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.PaymentProduct in project connect-sdk-client-android by Ingenico-ePayments.

the class FullWalletConfirmationButtonFragment method fetchTransactionStatus.

/**
 * Here the client should connect to their server, process the credit card/instrument
 * and get back a status indicating whether charging the card was successful or not
 */
private void fetchTransactionStatus(FullWallet fullWallet) {
    // / Retrieve the payment product from the paymentRequest
    PaymentProduct androidPay = paymentRequest.getPaymentProduct();
    // Log payment method token, if it exists. This token will either be a direct integration
    // token or a Stripe token, depending on the method used when making the MaskedWalletRequest
    PaymentMethodToken token = fullWallet.getPaymentMethodToken();
    if (token != null && androidPay != null) {
        // getToken returns a JSON object as a String.
        // 
        // For a Stripe token, the 'id' field of the object contains the necessary token.
        // 
        // For a Direct Integration token, the object will have the following format:
        // {
        // encryptedMessage: <string,base64>
        // ephemeralPublicKey: <string,base64>
        // tag: <string,base64>
        // }
        // See the Android Pay documentation for more information on how to decrypt the token.
        paymentRequest.setValue(com.globalcollect.gateway.sdk.client.android.sdk.configuration.Constants.ANDROID_PAY_TOKEN_FIELD_ID, token.getToken());
        paymentRequest.setValue(com.globalcollect.gateway.sdk.client.android.sdk.configuration.Constants.ANDROID_PAY_GOOGLE_TRANSACTION_ID_FIELD_ID, fullWallet.getGoogleTransactionId());
        // Pretty-print the token to LogCat (newlines replaced with spaces).
        Log.d(TAG, "PaymentMethodToken:" + token.getToken().replace('\n', ' '));
        // Prepare the payment request for submission at the connect API. The callback for the
        // preparePayemntRequest method (onPaymentRequestPrepared) should take care of this.
        session.preparePaymentRequest(paymentRequest, getActivity().getApplicationContext(), this);
    } else {
        // Notify the user that an error has occurred
        showTechnicalErrorDialog();
    }
// Send details such as fullWallet.getProxyCard() or fullWallet.getBillingAddress()
// to your server and get back success or failure. If you used Stripe for processing,
// you can get the token from fullWallet.getPaymentMethodToken()
}
Also used : PaymentProduct(com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.PaymentProduct) PaymentMethodToken(com.google.android.gms.wallet.PaymentMethodToken)

Example 3 with PaymentProduct

use of com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.PaymentProduct in project connect-sdk-client-android by Ingenico-ePayments.

the class GetPaymentProductAsyncTaskTest method testGetPaymentProductAsyncTaskWithInvalidRequest.

/**
 * Test that an invalid request for a PaymentProduct will return, but will not contain a PaymentProduct
 */
@Test
public void testGetPaymentProductAsyncTaskWithInvalidRequest() throws InterruptedException {
    initializeInValidMocksAndSession();
    final CountDownLatch waitForAsyncCallBack = new CountDownLatch(1);
    // Create the PaymentProductAsyncTask and then begin the test by calling execute
    List<PaymentProductAsyncTask.OnPaymentProductCallCompleteListener> listeners = new ArrayList<>(1);
    Listener listener = new Listener(waitForAsyncCallBack);
    listeners.add(listener);
    PaymentProductAsyncTask paymentProductAsyncTask = new PaymentProductAsyncTask(getContext(), "1", minimalValidPaymentContext, getCommunicator(), listeners);
    paymentProductAsyncTask.execute();
    // Test that the response is received within 'ASYNCTASK_CALLBACK_TEST_TIMEOUT_SEC' seconds
    assertTrue(waitForAsyncCallBack.await(ASYNCTASK_CALLBACK_TEST_TIMEOUT_SEC, TimeUnit.SECONDS));
    // Retrieve  the response from the callback and test that it is null
    PaymentProduct paymentProduct = listener.getPaymentProduct();
    assertNull(paymentProduct);
}
Also used : PaymentProduct(com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.PaymentProduct) ArrayList(java.util.ArrayList) CountDownLatch(java.util.concurrent.CountDownLatch) PaymentProductAsyncTask(com.globalcollect.gateway.sdk.client.android.sdk.asynctask.PaymentProductAsyncTask) Test(org.junit.Test)

Example 4 with PaymentProduct

use of com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.PaymentProduct in project connect-sdk-client-android by Ingenico-ePayments.

the class InputValidationPersister method storeInputFieldDataInPaymentRequest.

private void storeInputFieldDataInPaymentRequest(InputDataPersister inputDataPersister) {
    PaymentProduct paymentProduct = (PaymentProduct) inputDataPersister.getPaymentItem();
    for (PaymentProductField field : paymentProduct.getPaymentProductFields()) {
        String value = inputDataPersister.getValue(field.getId());
        // Null elements should not be stored in the payment request, empty values however can occur
        if (value == null) {
            value = "";
        }
        paymentRequest.setValue(field.getId(), field.removeMask(value));
    }
    paymentRequest.setTokenize(inputDataPersister.isRememberMe());
}
Also used : PaymentProduct(com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.PaymentProduct) PaymentProductField(com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.PaymentProductField)

Example 5 with PaymentProduct

use of com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.PaymentProduct in project connect-sdk-client-android by Ingenico-ePayments.

the class GcSessionPreparePaymentRequestTest method constructValidPaymentRequest.

private PaymentRequest constructValidPaymentRequest(boolean shouldHaveAccountOnFile, boolean tokenize) {
    PaymentProduct paymentProductVisa = GsonHelper.fromResourceJson("paymentProductVisa.json", PaymentProduct.class);
    PaymentRequest paymentRequest = new PaymentRequest();
    paymentRequest.setPaymentProduct(paymentProductVisa);
    if (shouldHaveAccountOnFile) {
        paymentRequest.setAccountOnFile(paymentProductVisa.getAccountOnFileById("0"));
    } else {
        paymentRequest.setValue("cardNumber", "4567350000427977");
    }
    paymentRequest.setValue("expiryDate", "0820");
    paymentRequest.setValue("cvv", "123");
    paymentRequest.setTokenize(tokenize);
    assertTrue(paymentRequest.validate().isEmpty());
    return paymentRequest;
}
Also used : PaymentProduct(com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.PaymentProduct) PreparedPaymentRequest(com.globalcollect.gateway.sdk.client.android.sdk.model.PreparedPaymentRequest) CreatePaymentRequest(com.ingenico.connect.gateway.sdk.java.domain.payment.CreatePaymentRequest) PaymentRequest(com.globalcollect.gateway.sdk.client.android.sdk.model.PaymentRequest)

Aggregations

PaymentProduct (com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.PaymentProduct)11 PaymentProductAsyncTask (com.globalcollect.gateway.sdk.client.android.sdk.asynctask.PaymentProductAsyncTask)5 ArrayList (java.util.ArrayList)5 BasicPaymentProduct (com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.BasicPaymentProduct)3 CountDownLatch (java.util.concurrent.CountDownLatch)3 Test (org.junit.Test)3 Intent (android.content.Intent)2 InvalidParameterException (java.security.InvalidParameterException)2 MerchantAction (com.globalcollect.gateway.sdk.client.android.exampleapp.model.MerchantAction)1 OnPaymentProductCallCompleteListener (com.globalcollect.gateway.sdk.client.android.sdk.asynctask.PaymentProductAsyncTask.OnPaymentProductCallCompleteListener)1 PaymentItemCacheKey (com.globalcollect.gateway.sdk.client.android.sdk.model.PaymentItemCacheKey)1 PaymentRequest (com.globalcollect.gateway.sdk.client.android.sdk.model.PaymentRequest)1 PreparedPaymentRequest (com.globalcollect.gateway.sdk.client.android.sdk.model.PreparedPaymentRequest)1 IinDetail (com.globalcollect.gateway.sdk.client.android.sdk.model.iin.IinDetail)1 BasicPaymentItem (com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.BasicPaymentItem)1 BasicPaymentProductGroup (com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.BasicPaymentProductGroup)1 PaymentProductField (com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.PaymentProductField)1 PaymentProductGroup (com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.PaymentProductGroup)1 PaymentMethodToken (com.google.android.gms.wallet.PaymentMethodToken)1 Gson (com.google.gson.Gson)1