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());
}
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()
}
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);
}
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());
}
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;
}
Aggregations