This is my NativeImpl code:

package com.mycompany.myapp;

import com.paypal.android.sdk.payments.PayPalAuthorization;
import com.paypal.android.sdk.payments.PayPalConfiguration;
import com.paypal.android.sdk.payments.PayPalFuturePaymentActivity;
import com.paypal.android.sdk.payments.PayPalPayment;
import com.paypal.android.sdk.payments.PayPalService;
import com.paypal.android.sdk.payments.PaymentActivity;
import com.paypal.android.sdk.payments.PaymentConfirmation;
import android.content.Intent;
import android.net.Uri;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;

import android.widget.Toast;
import android.*;
import android.content.Context;
import com.codename1.impl.android.IntentResultListener; 
import com.codename1.impl.android.AndroidNativeUtil;
import com.codename1.impl.android.CodenameOneActivity;

//import com.codename1.impl.android.LifecycleListener;
//import com.codename1.impl.android.OnInitListener;
import java.math.BigDecimal;


public class MyNativeImpl{
     // private static final String TAG = "paymentdemoblog";
/**
* - Set to PaymentActivity.ENVIRONMENT_PRODUCTION to move real money.
* 
* - Set to PaymentActivity.ENVIRONMENT_SANDBOX to use your test credentials
* from https://developer.paypal.com
* 
* - Set to PayPalConfiguration.ENVIRONMENT_NO_NETWORK to kick the tires
* without communicating to PayPal's servers.
*/
// private static final String CONFIG_ENVIRONMENT =
// PayPalConfiguration.ENVIRONMENT_NO_NETWORK;
private static final String CONFIG_ENVIRONMENT = 
PayPalConfiguration.ENVIRONMENT_SANDBOX;

// note that these credentials will differ between live & sandbox
// environments.
private static final String CONFIG_CLIENT_ID = 
"Aeqc2X1rBIEUtDNqsaRNr0h1neFo9QnNmfgmpA3D32uSLaHpGJu9NV1KfMnFmy7O-_hV47I7ST0SXDW2";

private static final int REQUEST_CODE_PAYMENT = 1;
private static final int REQUEST_CODE_FUTURE_PAYMENT = 2;

private static PayPalConfiguration config = new PayPalConfiguration()
.environment(CONFIG_ENVIRONMENT)
.clientId(CONFIG_CLIENT_ID)
// The following are only used in PayPalFuturePaymentActivity.
.merchantName("Hipster Store")
.merchantPrivacyPolicyUri(
Uri.parse("https://www.example.com/privacy";))
.merchantUserAgreementUri(
Uri.parse("https://www.example.com/legal";));

PayPalPayment thingToBuy;
    private static Activity activity() {
        return com.codename1.impl.android.AndroidNativeUtil.getActivity();
    } 
    
     private static Context context() {
    return 
com.codename1.impl.android.AndroidNativeUtil.getActivity().getApplicationContext();
}   
    public String payPalTest() {
          
        
Intent intent = new Intent(activity(), PayPalService.class);
intent.putExtra(PayPalService.EXTRA_PAYPAL_CONFIGURATION, config);
activity().startService(intent);
thingToBuy = new PayPalPayment(new BigDecimal("10"), "USD",
"HeadSet", PayPalPayment.PAYMENT_INTENT_SALE);
Intent intent1 = new Intent(activity(),
PaymentActivity.class);

intent.putExtra(PaymentActivity.EXTRA_PAYMENT, thingToBuy);

activity().startActivityForResult(intent1, REQUEST_CODE_PAYMENT);
       
         AndroidNativeUtil.startActivityForResult(intent, new 
IntentResultListener(){ 
           public void onActivityResult(int requestCode, int resultCode, 
Intent data) {
if (requestCode == REQUEST_CODE_PAYMENT) {
if (resultCode == Activity.RESULT_OK) {
PaymentConfirmation confirm = data
.getParcelableExtra(PaymentActivity.EXTRA_RESULT_CONFIRMATION);
if (confirm != null) {
try {
System.out.println(confirm.toString());
System.out.println(confirm.toString());
                                               
Toast.makeText(context(), "Order placed",
Toast.LENGTH_LONG).show();

} catch (Exception e) {
e.printStackTrace();
}
}
} else if (resultCode == Activity.RESULT_CANCELED) {
System.out.println("The user canceled.");
} else if (resultCode == PaymentActivity.RESULT_EXTRAS_INVALID) {
System.out
.println("An invalid Payment or PayPalConfiguration was submitted. Please 
see the docs.");
}
} else if (requestCode == REQUEST_CODE_FUTURE_PAYMENT) {
if (resultCode == Activity.RESULT_OK) {
PayPalAuthorization auth = data
.getParcelableExtra(PayPalFuturePaymentActivity.EXTRA_RESULT_AUTHORIZATION);
if (auth != null) {
try {
String authorization_code = auth.getAuthorizationCode();
Log.i("FuturePaymentExample", authorization_code);

sendAuthorizationToServer(auth);
Toast.makeText(context(),
"Future Payment code received from PayPal",
Toast.LENGTH_LONG).show();

} catch (Exception e) {
Log.e("FuturePaymentExample",
"an extremely unlikely failure occurred: ", e);
                                                e.printStackTrace();
}
}
} else if (resultCode == Activity.RESULT_CANCELED) {
Log.i("FuturePaymentExample", "The user canceled.");
} else if (resultCode == PayPalFuturePaymentActivity.RESULT_EXTRAS_INVALID) 
{
Log.i("FuturePaymentExample",
"Probably the attempt to previously start the PayPalService had an invalid 
PayPalConfiguration. Please see the docs.");
}
}
} 
        }); 

        return "test";
    }
    private void sendAuthorizationToServer(PayPalAuthorization 
authorization) {

}
    public void onDestroy() {
// // Stop service when done
// stopService(intent, PayPalService.class));
}
    public boolean isSupported() {
        return false;
    }

}
And i have copied PaypalSdk jar file into native directory, after this i 
have given android build to generate apk, what else am I supposed to do, 
did I miss anything?

On Saturday, July 30, 2016 at 10:32:35 AM UTC+5:30, Shai Almog wrote:
>
> Did you package the SDK into the final APK?
> What did you do besides that and what triggered that error?
>

-- 
You received this message because you are subscribed to the Google Groups 
"CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to codenameone-discussions+unsubscr...@googlegroups.com.
Visit this group at https://groups.google.com/group/codenameone-discussions.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/codenameone-discussions/769d82c9-795a-459c-8e10-56b981d51448%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to