TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
JOHN JOHNNNY
NA
190
140.8k
Open another ctivity after payment is made in fortumo in-App
Sep 22 2016 6:26 PM
Hi
I have downloaded the sdk and done the integration successfully, but i
want to make my app open GameActivity after a successfull one
time/full upgrade payment.
But my app could not open GameActivity after a successfull payment for
non-consumable item kindly help. see my code below
public class MainActivity extends PaymentActivity {
private static String SERVICE_ID = "
fe57060941a8cad84aa087ad64d015
49";
private static String APP_SECRET = "
9e92352038b5825948db09da892e2c
6e";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(
savedInstanceState);
setContentView(R.layout.
activity_main);
MpUtils.
enablePaymentBroadcast(this,
Manifest.permission.PAYMENT_
BROADCAST_PERMISSION);
// Restoring non-consumable items
new AsyncTask<Void, Void, Integer>() {
@Override
protected Integer doInBackground(Void... params) {
int medalStatus =
MpUtils.
getNonConsumablePaymentStatus(
MainActivity.this, SERVICE_ID,
"
9e92352038b5825948db09da892e2c
6e", "Medal");
return medalStatus;
}
@Override
protected void onPostExecute(Integer result) {
if (result.intValue() == MpUtils.MESSAGE_STATUS_BILLED) {
// We can refresh our UI here to indicate that
"Medal" is billed
// For example unlock some additional level in game
}
}
}.execute();
// TODO Restoring consumable items
// Depends on implementation, we can just save this info on
device or send some request to our server
findViewById(R.id.button1).
setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
PaymentRequest.
PaymentRequestBuilder builder = new
PaymentRequest.
PaymentRequestBuilder();
builder.setService("
fe57060941a8cad84aa087ad64d015
49",
"
9e92352038b5825948db09da892e2c
6e");
builder.setDisplayString("Buy Medal"); // shown
on user receipt
builder.setProductName("Medal"
); //
non-consumable purchases are restored using this value
builder.setType(MpUtils.
PRODUCT_TYPE_NON_CONSUMABLE);
//builder.setConsumable(false)
; //
non-consumable items can be later restored
builder.setIcon(R.drawable.
medal);
makePayment(builder.build());
}
});
findViewById(R.id.button2).
setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
PaymentRequest.
PaymentRequestBuilder builder = new
PaymentRequest.
PaymentRequestBuilder();
builder.setService("
fe57060941a8cad84aa087ad64d015
49",
"
9e92352038b5825948db09da892e2c
6e");
builder.setDisplayString("Buy golden eggs"); //
shown on user receipt
builder.setProductName("
GoldenEggs"); //
non-consumable purchases are restored using this value
builder.setType(MpUtils.
PRODUCT_TYPE_NON_CONSUMABLE);
//builder.setConsumable(true); //
non-consumable items can be later restored
builder.setIcon(R.drawable.
gold);
makePayment(builder.build());
}
});
}
@Override
protected void onPaymentCanceled(
PaymentResponse arg0) {
super.onPaymentCanceled(arg0);
}
@Override
protected void onPaymentFailed(
PaymentResponse arg0) {
super.onPaymentFailed(arg0);
}
@Override
protected void onPaymentPending(
PaymentResponse arg0) {
super.onPaymentPending(arg0);
}
@Override
protected void onPaymentSuccess(
PaymentResponse paymentResponse) {
super.onPaymentSuccess(
paymentResponse);
if (paymentResponse.getServiceId(
).equals(SERVICE_ID)) {
int creditAmount =
Integer.parseInt(
paymentResponse.
getCreditAmount());
// Increase amount of credits related to this service
(maybe coins in game)
// TODO Save purchase data (on device or send request to our server)
startActivity(new Intent(MainActivity.this, GameActivity.class));
} else if (paymentResponse.getServiceId(
).equals(SERVICE_ID)) {
// Unlock functionality related to this service (maybe
additional level in game)
startActivity(new Intent(MainActivity.this, GameActivity.class));
}
}
Reply soon
Reply
Answers (
2
)
my mobile doesn't shows the rsa key finger
Is there any android client library available for performing