Last active
March 11, 2017 15:12
-
-
Save v3ss0n/cf572ad18a752a97496effdd9d49aaae to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.hexyn.hover; | |
import android.content.Context; | |
import android.content.Intent; | |
import android.webkit.WebView; | |
import android.widget.Toast; | |
import com.hover.sdk.main.HoverParameters; | |
import com.hover.sdk.onboarding.HoverIntegrationActivity; | |
import com.hover.sdk.operators.Permission; | |
import org.apache.cordova.*; | |
import org.json.JSONArray; | |
import org.json.JSONException; | |
import static android.app.Activity.RESULT_CANCELED; | |
import static android.app.Activity.RESULT_OK; | |
/** | |
* Created by boggy on 3/10/17. | |
*/ | |
public class BuyNow extends CordovaPlugin{ | |
@Override | |
public void initialize(CordovaInterface cordova, CordovaWebView webView) { | |
super.initialize(cordova, webView); | |
// Intent integrationIntent = new Intent(cordova.getActivity(), HoverIntegrationActivity.class); | |
// integrationIntent.putExtra(HoverIntegrationActivity.SERVICE_IDS, new int[] { 11 }); | |
// integrationIntent.putExtra(HoverIntegrationActivity.PERM_LEVEL, Permission.NORMAL); | |
// cordova.getActivity().startActivityForResult(integrationIntent, 200); | |
} | |
@Override | |
public boolean execute(String action, final JSONArray args, final CallbackContext callbackContext) throws JSONException { | |
if(action.equals("buy")) | |
{ | |
Context con=cordova.getActivity().getApplicationContext(); | |
Intent i = new HoverParameters.Builder(con).request("send","100", "MMK", "09799112781").from(11).buildIntent(); | |
cordova.getActivity().startActivityForResult(i,200); | |
callbackContext.success(); | |
} | |
return true; | |
} | |
@Override | |
public void onActivityResult (int requestCode, int resultCode, Intent data) { | |
if (requestCode == 200 && resultCode == RESULT_CANCELED) { | |
Toast.makeText(cordova.getActivity().getApplicationContext(), "Error: " + data.getStringExtra("error"), Toast.LENGTH_LONG).show(); | |
} else if (requestCode == 200 && resultCode == RESULT_OK) { | |
Toast.makeText(cordova.getActivity().getApplicationContext(), "Success! ServiceId: " + data.getIntExtra("serviceId", -1) + ", Service Name: " + data.getStringExtra("serviceName") + ", Currency: " + data.getStringExtra("currency") + ", Country Name: " + data.getStringExtra("countryName") + ", Operator: " + data.getStringExtra("opSlug"), Toast.LENGTH_LONG).show(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment