Braintree - Android SDK: new credit card or existing one? - java

I'm new to the Android+Braintree world. At the moment I'm using the Drop-In interface.
What I want to do is the following
"If the user is creating/adding a new card, ask him if he wants to save
credit card information".
I need this info because later I will set the storeInVaultOnSuccess option in the transaction's params accordingly.
Now, it seems that there is no way to insert an element in the drop-in GUI to understand if the user wants to save these data or not.
Fine, so I'm going to add an additional step just after the drop-in interface in which I'm only going to ask the user if he wants to save the credit card data or not.
But the problem is that I don't want to ask this question if he choose an already existent credit card, so I need to know if he created a new card or if he selected an existent one.
Is there a way to perform this task (or is there a better alternative)?
WHAT I'VE ALREADY TRIED:
I've tried to see all the information given in the onActivityResult method, more specifically the content of the Intent given as the 3rd parameter.
What I have is, of course, the EXTRA_PAYMENT_METHOD_NONCE, and then the EXTRA_PAYMENT_METHOD (type com.braintreepayments.api.models.Card), but looking at the code of Card.java I'm not able to understand how to retrieve (if possible) this kind of information.
Thanks in advance.

Full disclosure: I work at Braintree. If you have any further questions, feel free to contact support.
The Drop-In UI doesn't support that workflow because at the time of entry the Drop-In automatically vaults the credit card and just provides the nonce (which doesn't contain any information about the card to the client for PCI reasons). In other words, storeInVaultOnSuccess won't apply since it's already there.
As you say, the way to get around this - while still using the Drop-In - would be to keep a reference to the payment method used in the transaction and ask after the transaction goes through. You can get this by examining the response object:
String payment_method_token = "";
TransactionRequest request = new TransactionRequest()
.amount(new BigDecimal("100.00"));
.paymentMethodNonce(nonceFromTheClient);
Result<Transaction> result = gateway.transaction().sale(request);
Transaction transaction = result.getTarget();
if (transaction.getPaymentInstrumentType().equals(PaymentInstrumentType.CREDIT_CARD){
payment_method_token = transaction.getCreditCard.getToken();
}
// ... other payment method types that you support
However, as you say, this is more complicated. You would have to make some selection based on:
a) when the payment method was created (using createdAt), or
a) comparing the arrays of payment methods before and after the checkout experience
This sort of flow really pushes the limits of the Drop-In, and these sorts of constraints often move developers to switch to a custom integration. In that case you would collect their preference - whether they want it stored - as they enter their credit card information.

Related

Best startegy for User navigation on details form

Want to design a form where user fills incremental forms, like first personal info , then click Next and fill employment info click next and so on.
Using AngularJS, do i need to call DB save with every Next button OR Just hiding old section and showing next section will work. If i go with ng-hide\show, values in the old input fields are lost obviously.
Please suggest.
You can use state management like ngrx or any Subject provided by rxjs to keep your state alive. Your data won't be lost. Eg : Use Subject or BehaviourSubject to pass/store the data. Be careful ngrx is a good state management, but not mandatory. If you don't know ngrx, use Subject. Because Subject is pretty much easier than ngrx and ngrx makes your project mess if you don't handle it in a proper way.

FirebaseUser - how to use PhoneAuthCredential parameter for FirebaseUser.updatePhoneNumber(PhoneAuthCredential)

I'm in the middle of developing an Android app using Firebase, and have Phone Number Authentication enabled as a method of user sign-in. This all works fine.
Inside my app, I have an Account Details page that allows the user to edit their information and update their record in the FirebaseDatabase (in a separate node that I have created and called users). I'm able to update this table with no problems, but I need to update the table that Firebase keeps when users register, so that phone numbers don't get out of sync.
In theory, it should be really easy to do. I've done some reading up and seen that a method exists in the FirebaseUser class called updatePhoneNumber(PhoneAuthCredential). The only problem is that I have no idea how the PhoneAuthCredential class works and, after a couple of hours of Googling, haven't been able to find a single example, or many other forms of support for the method.
An example for the FirebaseUser.updateEmail(String) method can be seen here, so I'd guess that it can't be all that different, and should work fine if I can get the PhoneAuthCredential object set up correctly.
Update:
I tried to create an instance using new PhoneAuthCredential(...), but the suggested parameters aren't much help...
Android Studio displays the constructor as public PhoneAuthCredential(String s, String s1, boolean b, String s2, boolean b2, String s3), so I am very much none-the-wiser.
If I can figure out how to use this constructor, I might well be off the ground, hopefully.
If anyone can advise on how to use PhoneAuthCredential, or how the FirebaseUser.updatePhoneNumber() method should be implemented, that would be a huge help!
Thanks in advance,
Mark
Phone auth is quite complicated, so I'd recommend reading this guide. This section is especially relevant to your case. Basically, you'll have to go through the entire phone auth flow again to get a credential and set the user's new phone number.
If you're thinking of the phone number as a part of the user's profile, that's incorrect as you can see from the profile request. The phone number is considered to be a sort of user identifier, like the email which also requires a credential if the user's sign-in action is 5 mins old. Hope this helps!

how to get the Fee Amount for paypal

I am currently looking at a system that implements the PayPal api. As a part of this I need to get the feeAmt() which is the fee that is paid to paypal for processing the payment.
From the documentation that I have looked at it appears that I have to implement the getExpressCheckoutDetailsReq() method in order to get the information that I want however no matter what I have tried I am struggling to do this. I should also let you know that I am currently developing my application using Java so using this is going to be best.
If any more explanation is needed please don't hesitate to ask and I will do my best to amend the post :)
GetExpressCheckoutDetails does not include the fee because at that point no payment has been made yet. That's the 2nd of 3 calls for Express Checkout, and until the final call is made there is no fee.
The fee amount would actually come in that final call's response: DoExpressCheckoutPayment. It will come in the PAYMENTINFO_n_FEEAMT parameter, where n is the number of the payment (0,1,2,etc.) Most likely it'll be 0 unless you're working with parallel payments.
Alternatively, you can use Instant Payment Notification (IPN) to get details about transactions, including the fee, in real-time when transactions are completed on your PayPal account.
Yet another option would be to use the GetTransactionDetails API to pull data for an individual transaction which would include the fee in a FEEAMT parameter. Maybe that's the one you were initially thinking of..??

New user creation notification mails are not going in Alfresco

When Admin creates a new user account, an email should go to the created user's mail id.
How can I enable this? Can I do it in "alfresco-global.properties", If yes, how?
I don't think that is possible out of the box. You could however implement this functionality with a java behavior. Be sure to not interfere with the emails that is sent out when inviting external users though otherwise those will get double emails.
Update after doing some research:
Well, someone made a decision to not make the notification option configurable in the create user gui. I have followed the calls made from the GUI down to the repository and it ends up calling a java method documented like this:
/**
* Create a Person with an optionally generated user name.
* This version doesn't notify them.
*
*/
Which means you have to do some coding to implement notifications in this scenario.

Where do we handle permissions in MVC? At the Controller or Model level?

I'm tinkering with Play! java framework and trying to understand MVC.
Consider this scenario: A blogging app has moderators and users, and both can update posts. Moderators' updates are immediately saved. Users' updates are queued to be approved by a moderator. In MVC, where do we put the logic to determine whether to update or queue the updates?
One way to do it is in the Controller (pseudo-code):
public void function update() {
User user = User.find("byEmail");
if ( user.isModerator() ) {
post.update( args );
}
else {
// save post in a temporary table where it awaits approval.
}
}
Am I right in using this approach or are there better alternatives?
I know that this is quite an old question, but I had the same - so this might be of help:
In my current project, the policy is to layer the authorisation checks. This way, the checks will be done where they fit best:
if it is important for consistancy of the data, checks are done in the model (very rare cases, needs to be set in the API documentation!).
most checks are done at controller level, so most checks are in a single place.
some checks are done in the "View" (this means they controll the JSON output of an API, and this in turn changes behaviour in the front end). These are quite rare, as these are mostly based on data fed from the controller and not querying the user's permissions directly.
I came up with that solution after reading this post. It provides a good summary on why using the controller is a good idea - and what the alternatives are.
The main reason, why I chose the controller as a place for authorisation checks is that it allows the model (and the data it manages) to be independent of application logic - which includes authorisation.
Please keep in mind, that this is totally dependent on what you want to achieve. I just wanted to show what works for me.

Categories