|
Hello to all! Hope you are fine. I am developing an e-commerce android app and integrating Stripe payment gateway in it and using Google Fire base as real time database.
I browsed the official website of stripe and took the source code from there. I used my test key from there. I successfully generated Stripe Token and saved it on my server (i-e Fire base). But I am unable to make an actual charge by using that token. That means no transaction shows on my stripe account. I am pasting my code, guide me what should i do to create/make charge?
Card cardToSave = cardInputWidget.getCard();
if (cardToSave == null) {
Toast.makeText(getActivity(),"Invalid Card Data",Toast.LENGTH_LONG).show();
// mErrorDialogHandler.showError("Invalid Card Data");
}
else{
Stripe stripe = new Stripe(MainActivity.mcont,
"pk_test_XZFc6CW7wmDMl4WWESxtvWd300ibs1wr85");
stripe.createToken(
cardToSave,
new TokenCallback() {
public void onSuccess(final Token token) {
// Send token to your server
customer_ref =
database.getReference("Customers").child(MainActivity.user.getUid());
final String tokenid = token.getId();
//saving the tokenID on my server(i-e fiebase)
final Map<String, Object> params = new HashMap<>();
params.put("amount", paid);
params.put("currency", "usd");
params.put("description", "Example charge");
params.put("source", tokenid);
HashMap map = new HashMap();
map.put("StripeToken",tokenid);
customer_ref.updateChildren(map);
try {
// creating charge object
Charge charge = Charge.create(params);
} catch (AuthenticationException e) {
e.printStackTrace();
} catch (InvalidRequestException e) {
e.printStackTrace();
} catch (APIConnectionException e) {
e.printStackTrace();
} catch (CardException e) {
e.printStackTrace();
} catch (APIException e) {
e.printStackTrace();
}
|
|
|
|
|
The Stripe developers hang out here.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
--Android Code
--============
<pre>private class UploadData extends AsyncTask<String, Void, String>
{
@Override
protected void onPreExecute()
{
progressDialog.setMessage("Wait !!! Transferring SQLite Data into SQL Server DB.");
progressDialog.setIndeterminate(false);
progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
progressDialog.setCancelable(false);
progressDialog.show();
}
@Override
protected void onPostExecute(String result)
{
progressDialog.dismiss();
AlertDialog YesNo1 = DialogYesNo();
YesNo1.setMessage("Hh Count Tablet: " + HhTablet + " , Hh Count Server: " + HhServer + "\n" + " -- has been transferred to SQL server DB !!! ");
YesNo1.setCancelable(false);
YesNo1.show();
HhServer = 0;
}
@Override
protected String doInBackground(String... params)
{
String result = "";
httpclient = new DefaultHttpClient();
httppost = new HttpPost("http://172.16.15.13/testing/datasync.php");
try
{
try
{
cursor = ConnectionDB.SelectRecord("Select HH,PartM,GISID,Mohalla from HH");
HhTablet = cursor.getCount();
if (cursor != null)
{
cursor.moveToFirst();
while (!cursor.isAfterLast())
{
for (int k = 0; k < HhTablet; k++)
{
nameValuePairs = new ArrayList<NameValuePair>(4);
nameValuePairs.add(new BasicNameValuePair("HH", cursor.getString(cursor.getColumnIndex("HH"))));
nameValuePairs.add(new BasicNameValuePair("PartM", cursor.getString(cursor.getColumnIndex("PartM"))));
nameValuePairs.add(new BasicNameValuePair("GISID", cursor.getString(cursor.getColumnIndex("GISID"))));
nameValuePairs.add(new BasicNameValuePair("Mohalla", cursor.getString(cursor.getColumnIndex("Mohalla"))));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HhServer = HhServer + 1;
}
ResponseHandler<String> responseHandler = new BasicResponseHandler();
String responseBody = httpclient.execute(httppost, responseHandler);
JSONObject json = new JSONObject(responseBody);
JSONArray jArray = json.getJSONArray("posts");
ArrayList<HashMap<String, String>> mylist = new ArrayList<HashMap<String, String>>();
for (int i = 0; i < jArray.length(); i++)
{
HashMap<String, String> map = new HashMap<String, String>();
JSONObject e = jArray.getJSONObject(i);
String s = e.getString("post");
JSONObject jObject = new JSONObject(s);
map.put("HH", jObject.getString(cursor.getString(cursor.getColumnIndex("HH"))));
map.put("PartM", jObject.getString(cursor.getString(cursor.getColumnIndex("PartM"))));
map.put("GISID", jObject.getString(cursor.getString(cursor.getColumnIndex("GISID"))));
map.put("Mohalla", jObject.getString(cursor.getString(cursor.getColumnIndex("Mohalla"))));
mylist.add(map);
cursor.moveToNext();
}
}
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
finally
{
cursor.close();
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
return result;
}
}
--PHP code
--==========
<?php
include ("dbconnection.php");
$json = file_get_contents('php://input');
$obj = json_decode($json);
$HH=$_POST[HH];
$PartM=$_POST[PartM];
$GISID=$_POST[GISID];
$Mohalla=$_POST[Mohalla];
$query = "INSERT INTO HH(HH,PartM,GISID,Mohalla) VALUES ('$HH','$PartM','$GISID','$Mohalla')";
$stmt = $conn->query( $query );
if ($query)
{
$response["success"] = 1;
$response["message"] = "Record is successfully created.";
echo json_encode($response);
}
else
{
$response["success"] = 0;
$response["message"] = "Sorry! An error occurred.";
echo json_encode($response);
}
$posts = array(1);
header('Content-type: application/json');
echo json_encode(array('posts'=>$posts));
$stmt = null;
$conn = null;
?>
modified 6-May-19 6:12am.
|
|
|
|
|
What exactly happens when you run this code? What is the data sent in the URL, and what is the response from the server?
|
|
|
|
|
Data is sending properly from this code but I am having problem in the loop. In my SQLite DB I am having 5 records but I am getting only one record when I am sending from the TAB.
|
|
|
|
|
Sorry but your descrikption is not clear. Please edit your question and explain exactly where the problem occurs, and what happens.
|
|
|
|
|
|
So I have created my first mobile app with xamarin cross platform. I only use the Android part.
I have tested my app extensively and all works very fine.
I also have a server and all the data comes from this server by APIs.
All the CRUD is working
After that I created an apk-file and send it to my tablet and Phone.
The pages/View are presented but with a very small font.
But that's not my problem. The problem is: no data. It looks like nothing is returned but, there are also no messages of network problems.
So, what's going on?
|
|
|
|
|
At a guess, there is a bug somewhere in your code.
|
|
|
|
|
I'm now checking it...But it runs fine on my development computer. And the server is somewehere in the world. I have no idea but it is not a local server.
I'll get back
|
|
|
|
|
Found it. No bugs.
I used just a very small font (6). On my virtual device it looks fine but on my tablet it wasn't readable.
I'm very happy it works, but I'm very sorry for posting here. I was too hasty
Thanks for the reply.
|
|
|
|
|
What was the problem with the data connection?
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
|
speech to text and text to speech android application code
|
|
|
|
|
|
In my react native app I am trying to get URL with the highlighted text from
any browser, I used ShareMenu to get highlighted text but failed to get URL, If any user highlighted any text from any website in a browser I want that website URL also, how can I achieve this I have tried many ways but failed, please suggest any solution.
|
|
|
|
|
The only thing happening ASAP is the removal of your ad.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Hi how to read or write data on SD card on Android phone
Thank
|
|
|
|
|
getExternalStorageDirectory() looks like a good starting spot. Then you can move to either FileInputStream or FileReader .
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Hi, i want to build a website and android app.But i don't know how to sync database so that same database is used for website and android app.
Thanks
|
|
|
|
|
It really depends on what you are trying to do with the two applications. What will the Android app do that cannot be done through the website, and vice versa ?
|
|
|
|
|
you can use and online Mysql database for this purpose
|
|
|
|
|
You need to create below :
1)website <--->Middleware Webservice<-->Central Database
2)Android Application <-->Middleware Webservice<-->Central Database
|
|
|
|
|
Hi,
I want to root my sony Xperia
how it works ?
Can someone help me ?
|
|
|
|
|
Wrong site: this is for development, not users who want to root phones
Try Google - a very basic search should get you what you want: Root SONY XPERIA - Google Search[^]
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|