Pls is the code below is enough to handle braintree for payment?
Purchase.startOrder(new Purchase.Callback() {
public String fetchToken() {
return "";
}
public void onPurchaseSuccess(String nonce) {
}
public void onPurchaseFail(String errorMessage) {
}
public void onPurchaseCancel() {
}
});
For the sample test I return the token provided in braintree websites like this
Purchase.startOrder(new Purchase.Callback() {
public String fetchToken() {
return "eyJ2ZXJzaW9uIjoyLCJhdXRob3JpemF0aW9uRmluZ2VycHJpbnQiOiI0ZDFkOWFkOGFhZDFlZDhiZjA4MDMwZGRmNWM0ZWEwZjc0ZDYwY2I4Zjg5MDNkYzVmYTUyNTM1MzhkMWIwYjNkfGNyZWF0ZWRfYXQ9MjAxNy0wNS0yMVQwNzo0MjoxNS4xODgzNDQ0MjIrMDAwMFx1MDAyNm1lcmNoYW50X2lkPTM0OHBrOWNnZjNiZ3l3MmJcdTAwMjZwdWJsaWNfa2V5PTJuMjQ3ZHY4OWJxOXZtcHIiLCJjb25maWdVcmwiOiJodHRwczovL2FwaS5zYW5kYm94LmJyYWludHJlZWdhdGV3YXkuY29tOjQ0My9tZXJjaGFudHMvMzQ4cGs5Y2dmM2JneXcyYi9jbGllbnRfYXBpL3YxL2NvbmZpZ3VyYXRpb24iLCJjaGFsbGVuZ2VzIjpbXSwiZW52aXJvbm1lbnQiOiJzYW5kYm94IiwiY2xpZW50QXBpVXJsIjoiaHR0cHM6Ly9hcGkuc2FuZGJveC5icmFpbnRyZWVnYXRld2F5LmNvbTo0NDMvbWVyY2hhbnRzLzM0OHBrOWNnZjNiZ3l3MmIvY2xpZW50X2FwaSIsImFzc2V0c1VybCI6Imh0dHBzOi8vYXNzZXRzLmJyYWludHJlZWdhdGV3YXkuY29tIiwiYXV0aFVybCI6Imh0dHBzOi8vYXV0aC52ZW5tby5zYW5kYm94LmJyYWludHJlZWdhdGV3YXkuY29tIiwiYW5hbHl0aWNzIjp7InVybCI6Imh0dHBzOi8vY2xpZW50LWFuYWx5dGljcy5zYW5kYm94LmJyYWludHJlZWdhdGV3YXkuY29tLzM0OHBrOWNnZjNiZ3l3MmIifSwidGhyZWVEU2VjdXJlRW5hYmxlZCI6dHJ1ZSwicGF5cGFsRW5hYmxlZCI6dHJ1ZSwicGF5cGFsIjp7ImRpc3BsYXlOYW1lIjoiQWNtZSBXaWRnZXRzLCBMdGQuIChTYW5kYm94KSIsImNsaWVudElkIjpudWxsLCJwcml2YWN5VXJsIjoiaHR0cDovL2V4YW1wbGUuY29tL3BwIiwidXNlckFncmVlbWVudFVybCI6Imh0dHA6Ly9leGFtcGxlLmNvbS90b3MiLCJiYXNlVXJsIjoiaHR0cHM6Ly9hc3NldHMuYnJhaW50cmVlZ2F0ZXdheS5jb20iLCJhc3NldHNVcmwiOiJodHRwczovL2NoZWNrb3V0LnBheXBhbC5jb20iLCJkaXJlY3RCYXNlVXJsIjpudWxsLCJhbGxvd0h0dHAiOnRydWUsImVudmlyb25tZW50Tm9OZXR3b3JrIjp0cnVlLCJlbnZpcm9ubWVudCI6Im9mZmxpbmUiLCJ1bnZldHRlZE1lcmNoYW50IjpmYWxzZSwiYnJhaW50cmVlQ2xpZW50SWQiOiJtYXN0ZXJjbGllbnQzIiwiYmlsbGluZ0FncmVlbWVudHNFbmFibGVkIjp0cnVlLCJtZXJjaGFudEFjY291bnRJZCI6ImFjbWV3aWRnZXRzbHRkc2FuZGJveCIsImN1cnJlbmN5SXNvQ29kZSI6IlVTRCJ9LCJjb2luYmFzZUVuYWJsZWQiOmZhbHNlLCJtZXJjaGFudElkIjoiMzQ4cGs5Y2dmM2JneXcyYiIsInZlbm1vIjoib2ZmIn0=";
}
public void onPurchaseSuccess(String nonce) {
}
public void onPurchaseFail(String errorMessage) {
}
public void onPurchaseCancel() {
}
});
When I buit and install on my phone to test it out. It displays the payment method which include paypal and add debit or credit card.
When I want to integrate my own:
The problem am facing now is that at the server side, I have a code that provides client token
My questions:
1. How do I call this token in codename one, although I have code that says return "";. What am I going to return here? I pointed the url that generated the token inside the return. It didn't work.
2. If I get my own token is that enough to handle the payment? according to the code provided above.
3. Is ssl required on the server side I want to use?
Thanks for your response.
As explained in the post you need to have a server to implement payments. Instructions of implementing the server are in the braintree website which is linked too.
Just look in the server section there and implement that. You then need to return the token generated in the server to your client code.
Related
in application.properties I need to set the OAuth2 keys...
OAuth2AppClientId=AB............................AN
OAuth2AppClientSecret=br................................u8
OAuth2AppRedirectUri=http://localhost:8085/oauth2redirect
Initially I put the keys in "" quotes assuming they should be treated as a string but to get it working I had to remove them. Can someone explain what's happening with
OAuth2AppClientId=AB............................AN when I build the app
and how do I find out more about OAuth2AppClientId?
A Google search is probably the place to start here. Here's a great resource about what a Client ID and Client Secret are:
https://www.oauth.com/oauth2-servers/client-registration/client-id-secret/
I quote:
The client_id is a public identifier for apps.
The client_secret is a secret known only to the application and the authorization server.
Intuit also has a ton of documentation on OAuth2, and how to implement it. You should read it:
https://developer.intuit.com/app/developer/qbo/docs/develop/authentication-and-authorization/oauth-2.0
In summary, the Client ID is how Intuit identifies that it's your app trying to connect to QuickBooks. Nothing is "happening" to the string when you build/compile the app - it's just normal string. But when your app authenticates against QuickBooks Online, your app sends the Client ID to QuickBooks so that QuickBooks knows it's your app trying to authorize a connection to QuickBooks, and not some other app.
If you want to see how to code is loading this, it is only a property being used inside the application
OAuth2PlatformClientFactory
#Service
#PropertySource(value="classpath:/application.properties", ignoreResourceNotFound=true)
public class OAuth2PlatformClientFactory {
#Autowired
org.springframework.core.env.Environment env;
OAuth2PlatformClient client;
OAuth2Config oauth2Config;
#PostConstruct
public void init() {
// intitialize a single thread executor, this will ensure only one thread processes the queue
oauth2Config = new OAuth2Config.OAuth2ConfigBuilder(env.getProperty("OAuth2AppClientId"), env.getProperty("OAuth2AppClientSecret")) //set client id, secret
.callDiscoveryAPI(Environment.SANDBOX) // call discovery API to populate urls
.buildConfig();
client = new OAuth2PlatformClient(oauth2Config);
}
public OAuth2PlatformClient getOAuth2PlatformClient() {
return client;
}
public OAuth2Config getOAuth2Config() {
return oauth2Config;
}
public String getPropertyValue(String propertyName) {
return env.getProperty(propertyName);
}
}
https://github.com/IntuitDeveloper/OAuth2-JavaWithSDK/blob/master/src/main/java/com/intuit/developer/sampleapp/oauth2/client/OAuth2PlatformClientFactory.java
How do I display the UI of the braintree in codename one? I only have this code `
Purchase.startOrder(new Purchase.Callback() {
public String fetchToken() {
}
public void onPurchaseSuccess(String nonce) {
}
public void onPurchaseFail(String errorMessage) {
}
public void onPurchaseCancel() {
}
});`
pls, I need a guide here. thanks
The call to startOrder will show the UI implicitly on the device once you implement the server side functionality that returns the token.
To test this in a mockup go to the braintree getting started guide you will notice code that looks like this:
public void onBraintreeSubmit(View v) {
DropInRequest dropInRequest = new DropInRequest()
.clientToken("long-token-string-that-looks-like-gibberish");
startActivityForResult(dropInRequest.getIntent(this), REQUEST_CODE);
}
You can use that token for debugging some of the process. Notice that price etc. are all determined in the server to prevent tampering so the token includes all of that data. I'd place the debug token here but I'm not sure if this is something that expires/changes.
I'm having trouble following the second step here.
I really don't understand how this sample does anything other than return a simple toast message. How does it utilize the API to display that message?
class EndpointsAsyncTask extends AsyncTask<Pair<Context, String>, Void, String> {
private static MyApi myApiService = null;
private Context context;
#Override
protected String doInBackground(Pair<Context, String>... params) {
if(myApiService == null) { // Only do this once
MyApi.Builder builder = new MyApi.Builder(AndroidHttp.newCompatibleTransport(),
new AndroidJsonFactory(), null)
// options for running against local devappserver
// - 10.0.2.2 is localhost's IP address in Android emulator
// - turn off compression when running against local devappserver
.setRootUrl("http://10.0.2.2:8080/_ah/api/")
.setGoogleClientRequestInitializer(new GoogleClientRequestInitializer() {
#Override
public void initialize(AbstractGoogleClientRequest<?> abstractGoogleClientRequest) throws IOException {
abstractGoogleClientRequest.setDisableGZipContent(true);
}
});
// end options for devappserver
myApiService = builder.build();
}
context = params[0].first;
String name = params[0].second;
try {
return myApiService.sayHi(name).execute().getData();
} catch (IOException e) {
return e.getMessage();
}
}
#Override
protected void onPostExecute(String result) {
Toast.makeText(context, result, Toast.LENGTH_LONG).show();
}
I'm afraid my this sample is too complex for my limited knowledge. How exactly do I "talk" to the Google Endpoints Module when running an app? Specifically, What is EndpointsAsyncTask();?
Are there any resources listing all the methods available to me? Is there a simpler example of an app communicating with a Google Cloud Endpoint?
The service methods available to you are defined by the backend source in section 1.
In the example you posted, this line: myApiService.sayHi(name).execute()
is an actual invocation call to the backend that you defined by annotating #ApiMethod("sayHi") on the method in the MyEndpoint.java class of your backend module.
The reason your Android app defines an EndpointsAsyncTask is because slow operations such as calls that hit the network need to happen off of the UI thread to avoid locking the UI. The demo simply puts the returned value into a Toast but you could modify onPostExecute() to do whatever you'd like with the result.
For more info on Google Endpoints check out:
https://cloud.google.com/appengine/docs/java/endpoints/
And for info about using an Android AsyncTask look here:
http://developer.android.com/reference/android/os/AsyncTask.html
I've tried to setup the following configuration with SQL Server and SignalR
http://www.asp.net/signalr/overview/performance/scaleout-with-sql-server
Everything seems to be setup correctly, if I profile SQL server I can see SignalR making calls to the DB, but when I call the hub to send a message to all the clients connected, the message is never sent to the connected browsers.
any idea what could be the problem?
Thank you #smnbss, you just saved my life with your comment inside your question. Just to make it clear for everyone in the future with the same problem, here is the wrong implementation: I was getting the context only once like:
public class SyncService : ISyncService
{
private IHubContext StatusChangeHub { get; set; }
public GatewaySyncService()
{
StatusChangeHub = GlobalHost.ConnectionManager.GetHubContext<Hub>();
}
public void SyncStatusChange(Status newStatus)
{
StatusChangeHub.Clients.All.onStatusChange(newStatus);
}
}
But somehow this only work while not using a backplane. And the correct implementation: you need to get the context everytime you want to send a message:
public class SyncService : ISyncService
{
public void SyncStatusChange(Status newStatus)
{
var context = GlobalHost.ConnectionManager.GetHubContext<Hub>();
context.Clients.All.onStatusChange(newStatus);
}
}
I am writing a RAP application using Eclipse RAP. The client may be any brower, an iPad or an android tablet (using Tabris). Is there any chance to find out which client has sent a request?
The background for my question is: Tabris does not support SashForms until now. For this reason, I want to render a SashFrom in case I am serving a web client but don't want to create a SashForm if serving the android client. I could do something like this:
public static boolean isAndroid() {
return getUserAgent().contains(Constants.ID_ANDROID);
}
private static String getUserAgent() {
return RWT.getRequest().getHeader(Constants.USER_AGENT);
}
public static boolean isIos() {
return getUserAgent().contains(Constants.ID_IOS);
}
public static boolean isWeb() {
return !isAndroid() && !isIos();
}
But I'd like to avoid this approach, because it uses internal API and since I am using standalone RAP I need to add a the servlet-api.jar to WEB-INF/lib folder to get this running, which is also not very nice.
Thanks in advance for your help and information,
Tobias.
I think this can help: https://github.com/eclipsesource/tabris/blob/master/com.eclipsesource.tabris/src/com/eclipsesource/tabris/ClientDevice.java
One alternative approach instead of using ClientDevice is to use RWT.getClient().
if( RWT.getClient() instanceof WebClient ) {
....
}
This is sometimes useful because ClientDevice can be null if the web client accesses the application. It's a client service that is only valid for the mobile client atm.