Skip to content
This repository has been archived by the owner on Jun 11, 2021. It is now read-only.

Commit

Permalink
Update SDK to 2.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
mattjacunski committed Apr 10, 2014
1 parent 1d85ce3 commit 7e98c8e
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 54 deletions.
Binary file modified SampleApp/libs/PayPalAndroidSDK.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,22 @@

import java.math.BigDecimal;

/**
* Basic sample using the SDK to make a payment or consent to future payments.
*
* For sample mobile backend interactions, see
* https://github.com/paypal/rest-api-sdk-python/tree/master/samples/mobile_backend
*/
public class SampleActivity extends Activity {

/*
private static final String TAG = "paymentExample";
/**
* - 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 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.
* - 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;

Expand Down Expand Up @@ -61,8 +67,9 @@ public void onBuyPressed(View pressed) {
// PAYMENT_INTENT_SALE will cause the payment to complete immediately.
// Change PAYMENT_INTENT_SALE to PAYMENT_INTENT_AUTHORIZE to only authorize payment and
// capture funds later.
PayPalPayment thingToBuy = new PayPalPayment(new BigDecimal("1.75"), "USD", "hipster jeans",
PayPalPayment.PAYMENT_INTENT_SALE);
PayPalPayment thingToBuy =
new PayPalPayment(new BigDecimal("1.75"), "USD", "hipster jeans",
PayPalPayment.PAYMENT_INTENT_SALE);

Intent intent = new Intent(SampleActivity.this, PaymentActivity.class);

Expand All @@ -73,41 +80,49 @@ public void onBuyPressed(View pressed) {

public void onFuturePaymentPressed(View pressed) {
Intent intent = new Intent(SampleActivity.this, PayPalFuturePaymentActivity.class);

startActivityForResult(intent, REQUEST_CODE_FUTURE_PAYMENT);
}

@Override
protected 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);
PaymentConfirmation confirm =
data.getParcelableExtra(PaymentActivity.EXTRA_RESULT_CONFIRMATION);
if (confirm != null) {
try {
Log.i("paymentExample", confirm.toJSONObject().toString(4));

// TODO: send 'confirm' to your server for verification or consent
// completion.
// see
// https://developer.paypal.com/webapps/developer/docs/integration/mobile/verify-mobile-payment/
// for more details.
Toast.makeText(getApplicationContext(), "PaymentConfirmation info received from PayPal",
Toast.LENGTH_LONG).show();
Log.i(TAG, confirm.toJSONObject().toString(4));
Log.i(TAG, confirm.getPayment().toJSONObject().toString(4));
/**
* TODO: send 'confirm' (and possibly confirm.getPayment() to your server for verification
* or consent completion.
* See https://developer.paypal.com/webapps/developer/docs/integration/mobile/verify-mobile-payment/
* for more details.
*
* For sample mobile backend interactions, see
* https://github.com/paypal/rest-api-sdk-python/tree/master/samples/mobile_backend
*/
Toast.makeText(
getApplicationContext(),
"PaymentConfirmation info received from PayPal", Toast.LENGTH_LONG)
.show();

} catch (JSONException e) {
Log.e("paymentExample", "an extremely unlikely failure occurred: ", e);
Log.e(TAG, "an extremely unlikely failure occurred: ", e);
}
}
} else if (resultCode == Activity.RESULT_CANCELED) {
Log.i("paymentExample", "The user canceled.");
Log.i(TAG, "The user canceled.");
} else if (resultCode == PaymentActivity.RESULT_EXTRAS_INVALID) {
Log.i("paymentExample", "An invalid Payment was submitted. Please see the docs.");
Log.i(
TAG,
"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);
PayPalAuthorization auth =
data.getParcelableExtra(PayPalFuturePaymentActivity.EXTRA_RESULT_AUTHORIZATION);
if (auth != null) {
try {
Log.i("FuturePaymentExample", auth.toJSONObject().toString(4));
Expand All @@ -116,8 +131,10 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
Log.i("FuturePaymentExample", authorization_code);

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

} catch (JSONException e) {
Log.e("FuturePaymentExample", "an extremely unlikely failure occurred: ", e);
Expand All @@ -126,33 +143,40 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
} else if (resultCode == Activity.RESULT_CANCELED) {
Log.i("FuturePaymentExample", "The user canceled.");
} else if (resultCode == PayPalFuturePaymentActivity.RESULT_EXTRAS_INVALID) {
Log.i("FuturePaymentExample",
Log.i(
"FuturePaymentExample",
"Probably the attempt to previously start the PayPalService had an invalid PayPalConfiguration. Please see the docs.");
}
}
}

private void sendAuthorizationToServer(PayPalAuthorization authorization) {

// TODO:
// Send the authorization response to your server, where it can exchange the authorization code
// for OAuth access and refresh tokens.
//
// Your server must then store these tokens, so that your server code can execute payments
// for this user in the future.


/**
* TODO: Send the authorization response to your server, where it can
* exchange the authorization code for OAuth access and refresh tokens.
*
* Your server must then store these tokens, so that your server code
* can execute payments for this user in the future.
*
* A more complete example that includes the required app-server to
* PayPal-server integration is available from
* https://github.com/paypal/rest-api-sdk-python/tree/master/samples/mobile_backend
*/

}

public void onFuturePaymentPurchasePressed(View pressed) {
// Get the Application Correlation ID from the SDK
String correlationId = PayPalConfiguration.getApplicationCorrelationId(this);

Log.i("FuturePaymentExample", "Application Correlation ID: " + correlationId);

// TODO: Send correlationId and transaction details to your server for processing with
// PayPal...
Toast.makeText(getApplicationContext(), "App Correlation ID received from SDK",
Toast.LENGTH_LONG).show();
Toast.makeText(
getApplicationContext(), "App Correlation ID received from SDK", Toast.LENGTH_LONG)
.show();
}

@Override
Expand Down
17 changes: 5 additions & 12 deletions docs/single_payment.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,17 +117,10 @@ The sample app provides a more complete example. However, at minimum, you must:
if (confirm != null) {
try {
Log.i("paymentExample", confirm.toJSONObject().toString(4));
Log.i("paymentExample", confirm.getPayment().toJSONObject().toString(4));

/**
* TODO: send 'confirm' (and possibly confirm.getPayment() to your server for verification
* or consent completion.
* See https://developer.paypal.com/webapps/developer/docs/integration/mobile/verify-mobile-payment/
* for more details.
*
* For sample mobile backend interactions, see
* https://github.com/paypal/rest-api-sdk-python/tree/master/samples/mobile_backend
*/

// TODO: send 'confirm' to your server for verification.
// see https://developer.paypal.com/webapps/developer/docs/integration/mobile/verify-mobile-payment/
// for more details.

} catch (JSONException e) {
Log.e("paymentExample", "an extremely unlikely failure occurred: ", e);
Expand All @@ -138,7 +131,7 @@ The sample app provides a more complete example. However, at minimum, you must:
Log.i("paymentExample", "The user canceled.");
}
else if (resultCode == PaymentActivity.RESULT_EXTRAS_INVALID) {
Log.i("paymentExample", "An invalid payment was submitted. Please see the docs.");
Log.i("paymentExample", "An invalid Payment or PayPalConfiguration was submitted. Please see the docs.");
}
}
```
Expand Down
Binary file modified libs/PayPalAndroidSDK.jar
Binary file not shown.
8 changes: 8 additions & 0 deletions release_notes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
PayPal Android SDK release notes
================================
2.0.3
-----
* Add return of `authorization_id` to SDK's payment response when payment intent is authorization. The `authorization_id` will be used to capture funds via server calls.
* Add `PayPalConfig.getLibraryVersion()`.
* Add support for Arabic and Malay languages.
* Add proper handling of right-to-left languages (Hebrew and Arabic).
* Improve user experience when user must log in again (informational dialog is displayed).

2.0.2
-----
* Minor bug fixes.
Expand Down

0 comments on commit 7e98c8e

Please sign in to comment.