@Override protected void onRestoreInstanceState(Bundle savedInstanceState) { super.onRestoreInstanceState(savedInstanceState); this.printOrder = savedInstanceState.getParcelable(EXTRA_PRINT_ORDER); this.apiKey = savedInstanceState.getString(EXTRA_PRINT_API_KEY); this.printEnvironment = (KitePrintSDK.Environment) savedInstanceState.getSerializable(EXTRA_PRINT_ENVIRONMENT); KitePrintSDK.initialize(apiKey, printEnvironment, getApplicationContext()); paypalEnvironment = PayPalCard.Environment.LIVE; if (printEnvironment == KitePrintSDK.Environment.STAGING || printEnvironment == KitePrintSDK.Environment.TEST) { paypalEnvironment = PayPalCard.Environment.SANDBOX; } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_ACTION_BAR); setContentView(R.layout.activity_payment); String apiKey = getIntent().getStringExtra(EXTRA_PRINT_API_KEY); String envString = getIntent().getStringExtra(EXTRA_PRINT_ENVIRONMENT); this.printOrder = (PrintOrder) getIntent().getParcelableExtra(EXTRA_PRINT_ORDER); if (apiKey == null) { throw new IllegalArgumentException( "You must specify an API key string extra in the intent used to start the PaymentActivity"); } if (printOrder == null) { throw new IllegalArgumentException( "You must specify a PrintOrder object extra in the intent used to start the PaymentActivity"); } if (savedInstanceState == null) { getFragmentManager() .beginTransaction() .add(R.id.container, new PlaceholderFragment(printOrder)) .commit(); } // KitePrintSDK.Environment env = KitePrintSDK.Environment.LIVE; KitePrintSDK.Environment env = KitePrintSDK.Environment.TEST; this.paypalEnvironment = PayPalCard.Environment.LIVE; if (envString != null) { if (envString.equals(ENVIRONMENT_STAGING)) { env = KitePrintSDK.Environment.STAGING; paypalEnvironment = PayPalCard.Environment.SANDBOX; } else if (envString.equals(ENVIRONMENT_TEST)) { env = KitePrintSDK.Environment.TEST; paypalEnvironment = PayPalCard.Environment.SANDBOX; } } this.apiKey = apiKey; this.printEnvironment = env; KitePrintSDK.initialize(apiKey, env, getApplicationContext()); /* * Start PayPal Service */ Intent intent = new Intent(this, PayPalService.class); intent.putExtra( com.paypal.android.sdk.payments.PaymentActivity.EXTRA_PAYPAL_ENVIRONMENT, printEnvironment.getPayPalEnvironment()); intent.putExtra( com.paypal.android.sdk.payments.PaymentActivity.EXTRA_CLIENT_ID, printEnvironment.getPayPalClientId()); startService(intent); if (getActionBar() != null) { if (this.paypalEnvironment == PayPalCard.Environment.SANDBOX) { getActionBar().setTitle("Payment (Sandbox)"); } else { getActionBar().setTitle("Payment"); } getActionBar().setDisplayHomeAsUpEnabled(true); } }