├── .github └── ISSUE_TEMPLATE.md ├── .gitignore ├── CHANGELOG.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── SampleApp-Kotlin ├── .gitignore ├── README.md ├── build.gradle ├── debug.keystore ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── paypal │ │ └── example │ │ └── paypalandroidsdkexample │ │ └── SampleActivity.kt │ └── res │ ├── drawable-hdpi │ └── ic_launcher.png │ ├── drawable-mdpi │ └── ic_launcher.png │ ├── drawable-xhdpi │ └── ic_launcher.png │ ├── drawable-xxxhdpi │ └── ic_launcher.png │ ├── layout │ └── activity_main.xml │ ├── values-sw600dp │ └── dimens.xml │ ├── values-sw720dp-land │ └── dimens.xml │ └── values │ ├── dimens.xml │ └── strings.xml ├── SampleApp ├── .gitignore ├── README.md ├── build.gradle ├── debug.keystore ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── paypal │ │ └── example │ │ └── paypalandroidsdkexample │ │ └── test │ │ ├── PaymentTest.java │ │ └── TestHelper.java │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── paypal │ │ └── example │ │ └── paypalandroidsdkexample │ │ └── SampleActivity.java │ └── res │ ├── drawable-hdpi │ └── ic_launcher.png │ ├── drawable-mdpi │ └── ic_launcher.png │ ├── drawable-xhdpi │ └── ic_launcher.png │ ├── drawable-xxxhdpi │ └── ic_launcher.png │ ├── layout │ └── activity_main.xml │ ├── values-sw600dp │ └── dimens.xml │ ├── values-sw720dp-land │ └── dimens.xml │ └── values │ ├── dimens.xml │ └── strings.xml ├── aars └── PayPalAndroidSDK-2.16.0.aar ├── acknowledgments.md └── docs ├── future_payment_error_codes.md ├── future_payments_mobile.md ├── future_payments_server.md ├── ja ├── README.md ├── future_payment_error_codes.md ├── future_payments_mobile.md ├── future_payments_server.md ├── profile_sharing_mobile.md ├── profile_sharing_server.md └── single_payment.md ├── profile_sharing_mobile.md ├── profile_sharing_server.md ├── single_payment.md └── supplemental_errors.md /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | ### General information 3 | 4 | * SDK/Library version: 5 | * Environment: 6 | * `PayPal-Debug-ID` values: 7 | * Android Version and Device: 8 | 9 | ### Issue description 10 | 11 | 12 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | PayPal Android SDK release notes 2 | ================================ 3 | 4 | 2.16.0 5 | ------ 6 | * Return transactionId on success [#402](https://github.com/paypal/PayPal-Android-SDK/issues/402). 7 | * Update translations. 8 | * Update SSL pinning cerificates. 9 | 10 | 2.15.3 11 | ------ 12 | * Update risk-component to 3.5.7. 13 | 14 | 2.15.2 15 | ------ 16 | * Add mandatory res folder in aar during release [#383](https://github.com/paypal/PayPal-Android-SDK/issues/383). 17 | * Updated card.io to 5.5.0. 18 | * Updated okhttp to 3.6.0. 19 | 20 | 2.15.1 21 | ------ 22 | * Removed trustall trustmanager to resolve google play security issue [#364](https://github.com/paypal/PayPal-Android-SDK/issues/364). 23 | * Shows amount properly in all devices [#357](https://github.com/paypal/PayPal-Android-SDK/issues/357). 24 | 25 | 2.15.0 26 | ------ 27 | * Add support for third-party receivers [iOS #140](https://github.com/paypal/PayPal-iOS-SDK/issues/140). Available as an optional property, `PayPalPayment.payeeEmail()`. This property is only available for PayPal payments, not Direct Credit Card (DCC) payments. 28 | * Direct Credit Card (DCC) payments are now deprecated in this SDK. Please use [Braintree Payments](https://www.braintreepayments.com/), a PayPal Company, which is the easiest way to accept PayPal, credit cards, and many other payment methods. All new integrations should [disable direct credit card payments](README.md#disabling-direct-credit-card-payments). 29 | * Update card.io to 5.4.2. 30 | 31 | 2.14.6 32 | ------ 33 | * Fix issue where okhttp cannot find the `TrustManager` [#341](https://github.com/paypal/PayPal-Android-SDK/issues/341). 34 | * Update card.io to 5.4.1. 35 | 36 | 2.14.5 37 | ------ 38 | * Update okhttp dependency to 3.4.1. 39 | * Fix crash when app does not have READ_PHONE_STATE permission [#321](https://github.com/paypal/PayPal-Android-SDK/issues/321). 40 | 41 | 2.14.4 42 | ------ 43 | * Minor bug fixes. 44 | * Updated gradle version to 2.14. 45 | * Include `org.json.*` exceptions in default proguard file [#299](https://github.com/paypal/PayPal-Android-SDK/issues/299). 46 | 47 | 2.14.3 48 | ------ 49 | * Update card.io to 5.4.0. 50 | * Update okhttp dependency to 3.3.1. 51 | 52 | 2.14.2 53 | ------ 54 | * Added a new Kotlin SampleApp! 55 | * Update card.io to 5.3.4. 56 | * Update build tools. 57 | 58 | 2.14.1 59 | ------ 60 | * Update card.io to 5.3.2. 61 | * Add proguard config to aar file. 62 | * Minor bug fixes. 63 | 64 | 2.14.0 65 | ------ 66 | * Update `minSdkVersion` to 16. This is the minimum Android version to communicate over TLSv1.2, which is required to support [a Payment Card Industry (PCI) Council mandate](http://blog.pcisecuritystandards.org/migrating-from-ssl-and-early-tls). All organizations that handle credit card information are required to comply with this standard. As part of this obligation, [PayPal is updating its services](https://github.com/paypal/tls-update) to require TLSv1.2 for all HTTPS connections. To override the minSdkVersion, please see [the readme](README.md#override-minsdkversion). 67 | * Update okhttp dependency to 3.2.0. 68 | * Fix issue related to non-ascii characters in user agent [#271](https://github.com/paypal/PayPal-Android-SDK/issues/271). 69 | 70 | 2.13.3 71 | ------ 72 | * Update okhttp dependency to 3.1.2. 73 | * Really fixes issue related to okhttp 3.1.2 [#258](https://github.com/paypal/PayPal-Android-SDK/issues/258). 74 | 75 | 2.13.2 76 | ------ 77 | * Fixes issue related to okhttp 3.1.2 [#258](https://github.com/paypal/PayPal-Android-SDK/issues/258). 78 | 79 | 2.13.1 80 | ------ 81 | * Fix issue preventing the SDK from app-switching to newer versions of the PayPal App. 82 | 83 | 2.13.0 84 | ------ 85 | * Fix sandbox pinning issue [#228](https://github.com/paypal/PayPal-Android-SDK/issues/228). 86 | * Allow complete removal of card.io dependency, effectively disabling direct credit card payments [#226](https://github.com/paypal/PayPal-Android-SDK/issues/226) & [#234](https://github.com/paypal/PayPal-Android-SDK/issues/234). 87 | * Update okhttp dependency to 3.0.1. 88 | * Update card.io to 5.3.0. 89 | 90 | 2.12.5 91 | ------ 92 | * Update okhttp dependency to 2.7.2. 93 | * Clean up manifest permissions [#233](https://github.com/paypal/PayPal-Android-SDK/issues/233). 94 | * Minor bug fixes. 95 | 96 | 2.12.4 97 | ------ 98 | * Documentation Updates for Maven based integrations. 99 | * Disabled `allowBackup` in Manifest. 100 | 101 | 2.12.3 102 | ------ 103 | * SDK is now available at Maven Central [#14](https://github.com/paypal/PayPal-Android-SDK/issues/14) & [#208](https://github.com/paypal/PayPal-Android-SDK/issues/208). 104 | * `com.paypal.sdk:paypal-android-sdk:2.12.3`. 105 | 106 | 2.12.2 107 | ------ 108 | * Enable aar packaging. 109 | * Ability to push to maven. 110 | 111 | 2.12.1 112 | ------ 113 | * Fix bug introduced in 2.12.0 that caused older devices to fail prematurely. 114 | 115 | 2.12.0 116 | ------ 117 | * Allow TLSv1.2 for API 16-19 devices, and add a special error message if PayPal requires TLSv1.2 but the device cannot comply. 118 | * Add a LogCat warning during PayPalService initialization when an Android version < API 16 (JELLY_BEAN) is detected. 119 | 120 | 2.11.2 121 | ------ 122 | * Minor bug fixes. 123 | * Update card.io to 5.1.2. 124 | 125 | 2.11.1 126 | ------ 127 | * Fix crash in `PayPalService.onDestroy()` [#212](https://github.com/paypal/PayPal-Android-SDK/issues/212). 128 | * Fix case where shipping address selections were inadvertently displayed to the user [#213](https://github.com/paypal/PayPal-Android-SDK/issues/213). 129 | * Decrease minSdkVersion back down to 10 (GINGERBREAD_MR1). 130 | * Convert SampleApp to only use Gradle builds. 131 | 132 | 2.11.0 133 | ------ 134 | * Target Android 23 (M). 135 | * Update card.io to 5.1.1 (supports new Android 23 Permissions). Note: this version of card.io contains support for more processor architectures. Please be sure to grab the entire contents of this SDK, including all up-to-date card.io `*.so` files within the `/libs` folder to ensure that card.io will continue to work on these architectures. 136 | * Increase minSdkVersion to 11 (HONEYCOMB). 137 | * Update all networking to use HttpURLConnection instead of Apache's HTTP Client. 138 | * Set all obfuscated classes to use lower case as a workaround for [an Android Tools issue](https://code.google.com/p/android/issues/detail?id=187210). 139 | 140 | 2.10.1 141 | ------ 142 | * Minor bug fixes. 143 | 144 | 2.10.0 145 | ------ 146 | * Fixed behavior where `retrieve_shipping_address ` is disabled and no `shipping address` is provided from the app, so it will not default to the PayPal account `shipping address`. 147 | 148 | 2.9.11 149 | ------ 150 | * Minor bug fixes. 151 | 152 | 2.9.10 153 | ------ 154 | * Minor bug fixes. 155 | 156 | 2.9.9 157 | ----- 158 | * Fix rare crash when making a single payment [#179](https://github.com/paypal/PayPal-Android-SDK/issues/179). 159 | * Minor bug fixes. 160 | 161 | 2.9.8 162 | ----- 163 | * Fix rare crash in `PayPalService` [#166](https://github.com/paypal/PayPal-Android-SDK/issues/166). 164 | * Minor bug fixes. 165 | 166 | 2.9.7 167 | ----- 168 | * Fix rare instance of PAYMENT_CREATION_ERROR. 169 | * Fix rare crashing issue on some devices when checking permissions [#167](https://github.com/paypal/PayPal-Android-SDK/issues/167). 170 | * Upgrade build tools. 171 | 172 | 2.9.6 173 | ----- 174 | * Fix issue where card.io compatibility was being checked even if credit cards are disabled [#173](https://github.com/paypal/PayPal-Android-SDK/issues/173). 175 | * Update card.io to 5.0.1. 176 | 177 | 2.9.5 178 | ----- 179 | * Update sample app build tools version to 1.2.2, compileSdkVersion to 22, and build tools version to 22.0.1. 180 | * Minor bug fixes to the consent screen. 181 | 182 | 2.9.4 183 | ----- 184 | * Fix rare NPE issue [#163](https://github.com/paypal/PayPal-Android-SDK/issues/163). 185 | 186 | 2.9.3 187 | ----- 188 | * Remove dependency on the [Android Support Library](http://developer.android.com/tools/support-library/index.html). 189 | * Fix NoClassDefFoundError issue with AdvertisingIdClient [#157](https://github.com/paypal/PayPal-Android-SDK/issues/157). 190 | * Fix ClassCastException issue with GsmCellLocation [#160](https://github.com/paypal/PayPal-Android-SDK/issues/160). 191 | * Minor bug fixes. 192 | 193 | 2.9.2 194 | ----- 195 | * Minor bug fixes. 196 | 197 | 2.9.1 198 | ----- 199 | * Fix crashing issue on Android `2.3.*` devices [#159](https://github.com/paypal/PayPal-Android-SDK/issues/159). 200 | * Fix `PayPalService.clearAllUserData()` to clear all environments when `PayPalService` is not running [#155](https://github.com/paypal/PayPal-Android-SDK/issues/155). If `PayPalService` is running, the v4 support library is still required to clear the current user data. 201 | * Fix issue with `PayPalService.clearAllUserData()` not actually clearing the current user [#156](https://github.com/paypal/PayPal-Android-SDK/issues/156). 202 | * Add some helpful logging to `PayPalService.clearAllUserData()`. 203 | * Minor bug fixes. 204 | 205 | 2.9.0 206 | ----- 207 | * Add `PayPalService.clearAllUserData(Context)` [#88](https://github.com/paypal/PayPal-Android-SDK/issues/88). Note: this method requires the use of the [Android Support Library](http://developer.android.com/tools/support-library/index.html), due to its use of `LocalBroadcastManager`. This SDK can still be used without the support library, but this method will not function. 208 | * Fix validation of `PayPalItem`: `sku` is no longer required, currencies and amounts have more strict validation [#153](https://github.com/paypal/PayPal-Android-SDK/issues/153). 209 | * Fix issue where too many profile sharing attributes were shown to the user. 210 | * Change name of `ENVIRONMENT_NO_NETWORK` merchant. 211 | * Minor bug fixes. 212 | 213 | 2.8.8 214 | ----- 215 | * Change "Send Payment" button to "Pay". (see https://github.com/paypal/PayPal-iOS-SDK/issues/174). 216 | * Minor bug fixes. 217 | * Update card.io to 5.0.0. 218 | 219 | 2.8.7 220 | ----- 221 | * Enforce required permissions: `ACCESS_NETWORK_STATE` and `INTERNET`. 222 | * Gracefully handle devices that do not return network state. 223 | * Better null handling. 224 | 225 | 2.8.6 226 | ----- 227 | * Update card.io to 4.0.1. 228 | * Add button allowing user to create a new PayPal account. 229 | * Add more public logging. 230 | * Minor UI tweaks. 231 | 232 | 2.8.5 233 | ----- 234 | * Update card.io to 4.0.0. 235 | * Update sample app build tools version to 1.0.1. 236 | * Minor bug fixes. 237 | 238 | 2.8.4 239 | ----- 240 | * Fix issue where resource is not properly closed [#125](https://github.com/paypal/PayPal-Android-SDK/issues/125). 241 | * Add even better error messages in all locales. 242 | 243 | 2.8.3 244 | ----- 245 | * Fix ClassNotFoundException issue in Parcelable classes. 246 | * Add better error messages for some common errors. 247 | * Minor bug fixes. 248 | * Fix several docs and SampleApp issues. 249 | 250 | 2.8.2 251 | ----- 252 | * Fix consent privacy policy and user agreement links, and update the mock link urls. 253 | * Fix issue where the service would not properly restart after being backgrounded [#117](https://github.com/paypal/PayPal-Android-SDK/issues/117). 254 | It is now recommended that developers pass the `PayPalConfiguration` object into the PayPal activities, in addition to `PayPalService`. 255 | Update the documentation and sample app with the suggested modifications. 256 | * Add documentation on correct `httpcomponents` dependencies, which addresses [#113](https://github.com/paypal/PayPal-Android-SDK/issues/113). 257 | * Update Visa branding. 258 | * Minor bug fixes. 259 | 260 | 2.8.1 261 | ----- 262 | * Fix issue where consent was not working for new users (bug introduced in 2.8.0). 263 | * Remove unneeded ACCESS_WIFI_STATE from integration docs. 264 | * Update sample app build tools version to 1.0.0. 265 | 266 | 2.8.0 267 | ----- 268 | * Allow login by users who have enabled two-factor authentication on their PayPal accounts. 269 | * Update `Paypal-Application-Correlation-Id` header to `PayPal-Client-Metadata-Id`, 270 | and deprecate `PayPalConfiguration.getApplicationCorrelationId()` in favor 271 | of `PayPalConfiguration.getClientMetadataId()`. 272 | * Update sample app build tools version. 273 | * Minor bug fixes. 274 | 275 | 2.7.3 276 | ----- 277 | * Fix single payments issue affecting cross-app integrations. 278 | 279 | 2.7.2 280 | ----- 281 | * Add additional logging for exceptions on threads. 282 | * Update sample app gradle wrapper to 2.2.1. 283 | * Update sample app build tools version. 284 | 285 | 2.7.1 286 | ----- 287 | * Fix validation issue related to android:process [#114](https://github.com/paypal/PayPal-Android-SDK/issues/114). 288 | * Minor bug fixes. 289 | * Update sample app build tools version. 290 | * Remove some old files. 291 | 292 | 2.7.0 293 | ----- 294 | * Add support for Russian Rubles. 295 | * Add gradle files to Sample App. 296 | * Minor fixes to the Consent Activity. 297 | 298 | 2.6.1 299 | ----- 300 | * Minor improvements relevant only to select partners. 301 | * Minor bug fixes. 302 | 303 | 2.6.0 304 | ----- 305 | * Streamline Profile Sharing for cases where a user has previously authorized sharing. 306 | * Update card.io library to 3.2.0. 307 | * Update all targets to android-21. 308 | * Minor bug fixes. 309 | 310 | 2.5.6 311 | ----- 312 | * Minor bug fixes. 313 | 314 | 2.5.5 315 | ----- 316 | * Fix issue with some PayPal Credit funding instruments [#97](https://github.com/paypal/PayPal-Android-SDK/issues/97). 317 | 318 | 2.5.4 319 | ----- 320 | * Fix issue that kept some apps from authorizing properly. 321 | * The SDK now rejects fractional amounts for HUF, JPY, TWD currencies (previously fractional amounts were rounded). 322 | 323 | 324 | 2.5.3 325 | ----- 326 | * Update card.io library (adds Diners Club and China UnionPay support). 327 | * Fix Cursor not closing problem reported in Strict mode [#87](https://github.com/paypal/PayPal-Android-SDK/issues/87). 328 | * Minor bug fixes. 329 | 330 | 2.5.2 331 | ----- 332 | * Update Sample App icons. 333 | * Minor bug fixes. 334 | 335 | 2.5.1 336 | ----- 337 | * Fix layout xml issue in SampleApp [#89](https://github.com/paypal/PayPal-Android-SDK/issues/89). 338 | 339 | 2.5.0 340 | ----- 341 | * Add support for payment intent value `order` to create a payment for later authorization and capture via server calls. 342 | * For single payments, an individual `PayPalItem` may be negative (for discounts, coupons, etc.). 343 | * Add `invoiceNumber`, `custom`, and `softDescriptor` as optional properties on `PayPalPayment`. 344 | 345 | 2.4.0 346 | ----- 347 | * Add [Profile Sharing](https://github.com/paypal/PayPal-Android-SDK/blob/master/docs/profile_sharing_mobile.md) feature. 348 | * Developer selects requested account profile attributes. 349 | * User may consent to sharing the requested profile data. 350 | * Fix sluggish performance in Payment Method selection on devices with slower cameras (Nexus 10). 351 | * Fix issue [#77: Invalid path on some devices](https://github.com/paypal/PayPal-Android-SDK/issues/77). 352 | 353 | 2.3.5 354 | ---- 355 | * Hotfix for issue on live/sandbox environment introduced in 2.3.4. 356 | 357 | 2.3.4 358 | ---- 359 | * Fix issue [#83: App freezes when calling startService](https://github.com/paypal/PayPal-Android-SDK/issues/83) for realsies this time. 360 | * Restrict phone/pin login where appropriate. 361 | 362 | 2.3.3 363 | ---- 364 | * Fix issue [#83: App freezes when calling startService](https://github.com/paypal/PayPal-Android-SDK/issues/83). 365 | * Minor bug fixes. 366 | 367 | 2.3.2 368 | ---- 369 | * Re-add Version class for Cordova backward compatibility. 370 | 371 | 2.3.1 372 | ---- 373 | * Support display of Pay After Delivery funding options. 374 | * Minor bug fixes. 375 | 376 | 2.3.0 377 | ---- 378 | * Add user funding option selection. 379 | * Add app-controlled user shipping address selection (including support for the app to add a new shipping address). 380 | * Rename zh-Hant_HK -> zh-Hant so that HK is chosen by default for other regions. 381 | 382 | 2.2.2 383 | ----- 384 | * Add translations for Thai. 385 | * Fix bnCode validation to accept underscores and hyphens. 386 | 387 | 2.2.1 388 | ----- 389 | * Fix SampleApp code related to multiple item support. 390 | * Add instructions for using SDK in Gradle projects. 391 | * Fix issues associated with how the PayPalService was being managed. 392 | 393 | 2.2.0 394 | ----- 395 | * Add support for multiple items per payment. 396 | * Update PayPal logo. 397 | * Update card.io library to 3.1.5. 398 | 399 | 2.1.0 400 | ----- 401 | * Add integration with PayPal Wallet App (available only on the Samsung app store). 402 | * In live environment, if the newly released PayPal Wallet app with authenticator is present on a user's device, the PayPal Wallet app will log the user in to the SDK. 403 | * Fix issue where some email addresses would not be accepted. 404 | * Fix some Spanish translations. 405 | * Fix possible NPE in payment confirmation flow. 406 | 407 | 2.0.3 408 | ----- 409 | * 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. 410 | * Add `PayPalConfig.getLibraryVersion()`. 411 | * Add support for Arabic and Malay languages. 412 | * Add proper handling of right-to-left languages (Hebrew and Arabic). 413 | * Improve user experience when user must log in again (informational dialog is displayed). 414 | 415 | 2.0.2 416 | ----- 417 | * Minor bug fixes. 418 | 419 | 2.0.1 420 | ----- 421 | * Fix values for product_name and build_time returned by SDK. 422 | 423 | 2.0.0 424 | ----- 425 | * Add Future Payment with PayPal support. Users can now authenticate and consent within an app using the SDK. A user no longer needs to repeatedly enter credentials. 426 | * Introduce a `PayPalFuturePaymentActivity`, which returns a `PayPalAuthorization` object. 427 | * Changes to payment feature: 428 | * Change backend to use PayPal's new REST APIs for all SDK functions. Now there is a single way to verify both credit card and PayPal payments. 429 | * Introduce `PayPalPaymentDetails` to support payment details, including line-item subtotal amount, tax amount, and shipping amount. 430 | * Single payments now include a payment`intent` to distinguish between: 431 | 1. immediate payment processing 432 | 2. payment authorization only, with subsequent payment capture from the merchant's server. 433 | * Use `PayPalConfiguration` object for common configuration across both single payment and future payment use cases. 434 | * For API errors, logging will now provide additional information, including a PayPal Debug-ID for MTS investigations. 435 | * Add support for directional controller interaction (for set-top boxes, game consoles, etc.). 436 | * Resolves issues with PayPal user passwords containing special characters. 437 | 438 | 1.2.6 439 | ----- 440 | * Fix issue where PaymentActivity.EXTRA_DEFAULT_USER_EMAIL was not being handled properly in all cases [47](https://github.com/paypal/PayPal-Android-SDK/issues/47). 441 | 442 | 1.2.5 443 | ----- 444 | * Refactor code to eliminate spurious error message in LogCat [40](https://github.com/paypal/PayPal-Android-SDK/issues/40). 445 | * Fix validation of PayPalPayment.shortDescription where some credit card payments caused incorrect JSONException [41](https://github.com/paypal/PayPal-Android-SDK/issues/41). 446 | * Eliminate source of potential NPE [37](https://github.com/paypal/PayPal-Android-SDK/issues/37). 447 | * Update card.io lib to 3.1.4 (includes fixes for potential NPEs). 448 | 449 | 1.2.4 450 | ----- 451 | * Fix NumberFormatException on some payments in locales that use comma for decimal separator [34](https://github.com/paypal/PayPal-Android-SDK/issues/34). 452 | 453 | 1.2.3 454 | ----- 455 | * Fix issue where invalid currency amounts could be sent to the PayPal server. 456 | 457 | 1.2.2 458 | ----- 459 | * Fix login page layout issue [20](https://github.com/paypal/PayPal-Android-SDK/issues/20). 460 | * Add some login error logging. 461 | 462 | 1.2.1 463 | ----- 464 | * Update card.io library to 3.1.3. 465 | * Fix issue [#11: release/debug UI differences](https://github.com/paypal/PayPal-Android-SDK/issues/11). 466 | 467 | 1.2.0 468 | ----- 469 | * Eliminate the final "Complete" screen. 470 | * Fix Hebrew phone settings detection bug. 471 | * Update card.io library to 3.1.2. 472 | 473 | 1.1.2 474 | ----- 475 | * Re-add `Version` class. 476 | * Update card.io library to 3.1.1. 477 | * Support all currencies that are currently accepted by the REST APIs. See [README](README.md) for details. 478 | * Fix various localizations. 479 | * Additional localization: ko (Korean). 480 | * Minor UI cleanup (including [issue 4](https://github.com/paypal/PayPal-Android-SDK/issues/4)). 481 | 482 | 1.1.1 483 | ----- 484 | * Skipped. 485 | 486 | 1.1.0 487 | ----- 488 | * Bug fixes. 489 | * Update card.io to 3.1.0. 490 | * Add translations of all strings into ~20 languages, in addition to American English. 491 | - Translation choice is controlled by `EXTRA_LANGUAGE_OR_LOCALE` in PaymentActivity. 492 | - The translations that a few developers had previously created for their own apps will no longer be used by the SDK. 493 | - NOTE: Default language, if not set by your app, will now be based upon the device's current language setting. 494 | 495 | 1.0.3 496 | ----- 497 | * Bug fixes. 498 | 499 | 1.0.2 500 | ----- 501 | * Several small fixes & improvements. 502 | 503 | 1.0.1 504 | ----- 505 | * Update card.io to 3.0.5. 506 | * Minor UI improvements. 507 | * Other small fixes. 508 | 509 | 1.0.0 510 | ----- 511 | * First release! 512 | 513 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contribute to the PayPal Android SDK 2 | 3 | We love your contributions. If you're looking to submit changes to the sample app or documentation available within this repo, feel free to submit a PR. 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The PayPal Android SDK Sample App is released under the BSD License: 2 | 3 | Copyright (c) 2014-2016 PayPal Holdings, Inc. 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 2. Redistributions in binary form must reproduce the above copyright notice, 12 | this list of conditions and the following disclaimer in the documentation 13 | and/or other materials provided with the distribution. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 19 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | The views and conclusions contained in the software and documentation are those 27 | of the authors and should not be interpreted as representing official policies, 28 | either expressed or implied, of the FreeBSD Project. 29 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | **Important**: This PayPal Android SDK is Deprecated. The APIs powering them will remain operational long enough for merchants to migrate, but the SDKs themselves will no longer be updated. Please use the [PayPal Android Checkout SDK](https://github.com/paypal/android-checkout-sdk). Reference the [Developer Documentation](https://developer.paypal.com/docs/business/native-checkout/android/) for getting started. 2 | 3 | PayPal Android SDK 4 | ================== 5 | 6 | The PayPal Android SDK makes it easy to add PayPal payments to mobile apps. 7 | 8 | *This documentation is available in Japanese: [日本語のドキュメント](docs/ja/README.md).* 9 | 10 | ## Contents 11 | 12 | - [Use Cases](#use-cases) 13 | - [Integration with the PayPal Wallet App](#integration-with-the-paypal-wallet-app) 14 | - [Requirements](#requirements) 15 | - [Add the SDK to Your Project](#add-the-sdk-to-your-project) 16 | - [Credentials](#credentials) 17 | - [International Support](#international-support) 18 | - [Disabling Direct Credit Card Payments](#disabling-direct-credit-card-payments) 19 | - [Override `minSdkVersion`](#override-minsdkversion) 20 | - [Testing](#testing) 21 | - [Documentation](#documentation) 22 | - [Usability](#usability) 23 | - [Next Steps](#next-steps) 24 | - [Contributing](#contributing) 25 | - [License](#license) 26 | 27 | ## Add the SDK to Your Project 28 | 29 | The PayPal Android SDK is now available at [Maven Repository](https://repo1.maven.org/maven2/com/paypal/sdk/paypal-android-sdk/). The latest version is available via `mavenCentral()`: 30 | 31 | ```groovy 32 | compile 'com.paypal.sdk:paypal-android-sdk:2.16.0' 33 | ``` 34 | 35 | 36 | ## Use Cases 37 | 38 | The SDK supports two use cases for making payments - **Single Payment** and **Future Payments** - and a third use case for obtaining information about the customer - **Profile Sharing**. 39 | 40 | 41 | ### Single Payment 42 | 43 | Receive a one-time payment from a customer's PayPal account or payment card (scanned with [card.io](https://www.card.io/)). This can be either (1) an **immediate** payment which your servers should subsequently **verify**, or (2) an **authorization** for a payment which your servers must subsequently **capture**, or (3) a payment for an **order** which your servers must subsequently **authorize** and **capture**: 44 | 45 | 1. [Accept a Single Payment](docs/single_payment.md) and receive back a proof of payment. 46 | 2. On your server, [Verify the Payment](https://developer.paypal.com/webapps/developer/docs/integration/mobile/verify-mobile-payment/), [Capture the Payment](https://developer.paypal.com/webapps/developer/docs/integration/direct/capture-payment/#capture-the-payment), or [Process the Order](https://developer.paypal.com/webapps/developer/docs/integration/direct/create-process-order/) (PayPal Developer site) using PayPal's API. 47 | 48 | *Note:* Direct Credit Card (DCC) payments are now deprecated in this SDK. Please use [Braintree Payments](https://www.braintreepayments.com/), a PayPal Company, which is the easiest way to accept PayPal, credit cards, and many other payment methods. All new integrations should [disable direct credit card payments](#disabling-direct-credit-card-payments). 49 | 50 | 51 | ### Future Payments 52 | 53 | Your customer logs in to PayPal just one time and consents to future payments: 54 | 55 | 1. [Obtain Customer Consent](docs/future_payments_mobile.md#obtain-customer-consent) to receive an authorization code. 56 | 2. On your server, use this authorization code to [Obtain OAuth2 Tokens](docs/future_payments_server.md#obtain-oauth2-tokens). 57 | 58 | Later, when that customer initiates a payment: 59 | 60 | 1. [Obtain a Client Metadata ID](docs/future_payments_mobile.md#obtain-an-application-correlation-id) that you'll pass to your server. 61 | 2. On your server, [Create a Payment](docs/future_payments_server.md#create-a-payment) using your OAuth2 tokens, the Client Metadata ID, and PayPal's API. 62 | 63 | ### Profile Sharing 64 | 65 | Your customer logs in to PayPal and consents to PayPal sharing information with you: 66 | 67 | 1. [Obtain Customer Consent](docs/profile_sharing_mobile.md#obtain-customer-consent) to receive an authorization code. 68 | 2. On your server, use this authorization code to [Obtain OAuth2 Tokens](docs/profile_sharing_server.md#obtain-oauth2-tokens). 69 | 3. On your server, [Retrieve Customer Information](docs/profile_sharing_server.md#retrieve-customer-information) using your OAuth2 tokens and PayPal's API. 70 | 71 | 72 | ## Integration with the PayPal Wallet App 73 | 74 | The SDK will now use the newest version of the PayPal Wallet App if present on the device to log in to a customer account. No additional configuration is required to enable this feature. This integration enables device-specific PayPal [FIDO](https://fidoalliance.org/) integrations, including login by fingerprint on the Galaxy S5. In addition, a user who logged in to the PayPal Wallet App and checked "Keep me logged in" may not need to log-in again when paying with your app. For more information on how this all works, please read the [blog post](http://www.embedded.com/design/real-world-applications/4430305/Implementing-Android-based-fingerprint-authentication-for-online-payments) from one of our architects. 75 | 76 | ### Limitations 77 | 78 | * The integration will _not_ be enabled in any of the [testing](#testing) modes, as the Wallet app does not support this developer testing environment. 79 | 80 | ## Requirements 81 | 82 | * Android 4.1.x (API 16) or later 83 | * Phone or tablet 84 | 85 | ## Credentials 86 | 87 | Your mobile integration requires different `client_id` values for each environment: Live and Test (Sandbox). 88 | 89 | Your server integrations for verifying or creating payments will also require the corresponding `client_secret` for each `client_id`. 90 | 91 | You can obtain these PayPal API credentials by visiting the [Applications page on the PayPal Developer site](https://developer.paypal.com/webapps/developer/applications) and logging in with your PayPal account. 92 | 93 | ### Sandbox 94 | 95 | Once logged in on this Applications page, you will be assigned **test credentials**, including Client ID, which will let you test your Android integration against the PayPal Sandbox. 96 | 97 | While testing your app, when logging in to PayPal in the SDK's UI you should use a *personal* Sandbox account email and password. I.e., not your Sandbox *business* credentials. 98 | 99 | You can create both business and personal Sandbox accounts on the [Sandbox accounts](https://developer.paypal.com/webapps/developer/applications/accounts) page. 100 | 101 | #### Sandbox and TLSv1.2 102 | 103 | PayPal will be upgrading the endpoint that the PayPal Android SDK uses to communicate with PayPal servers on Jan 18th, 2016. If you're testing on sandbox with a version of the PayPal Android SDK older than 2.13.0, then you'll start seeing communication failures when using Android devices >= API 16, and < API 20. Please upgrade to a version [2.13.0](https://github.com/paypal/PayPal-Android-SDK/releases) or higher to fix these errors. 104 | 105 | If you're testing on a device older than API 16, Android will not be able to communicate with PayPal, no matter what version of the SDK you use. 106 | 107 | These TLS changes coincides with the TLSv1.2 security mandate outlined [here](https://www.paypal-knowledge.com/infocenter/index?page=content&widgetview=true&id=FAQ1914&viewlocale=en_US), and will be followed by a similar change to the Production endpoints at some later date. For any questions or concerns, please [create an issue](https://github.com/paypal/PayPal-Android-SDK/issues/). 108 | 109 | ### Live 110 | 111 | To obtain your **live** credentials, you will need to have a business account. If you don't yet have a business account, there is a link at the bottom of that same Applications page that will get you started. 112 | 113 | 114 | ## International Support 115 | 116 | ### Localizations 117 | 118 | The SDK has built-in translations for many languages and locales. See [javadoc](http://paypal.github.io/PayPal-Android-SDK/) files for a complete list. 119 | 120 | ### Currencies 121 | 122 | The SDK supports multiple currencies. See [the REST API country and currency documentation](https://developer.paypal.com/webapps/developer/docs/integration/direct/rest_api_payment_country_currency_support/) for a complete, up-to-date list. 123 | 124 | ## Disabling Direct Credit Card Payments 125 | 126 | Disabling Direct Credit Card Payments is now preferred. To completely disable Direct Credit Card (DCC) payments, exclude the card.io library in your application `build.gradle`: 127 | ```groovy 128 | dependencies { 129 | compile('com.paypal.sdk:paypal-android-sdk:2.16.0') { 130 | exclude group: 'io.card' 131 | } 132 | } 133 | ``` 134 | 135 | ## Override `minSdkVersion` 136 | 137 | As of release `2.14.0`, the `minSdkVersion` has been increased to 16. If you prefer to have your app on a lower `minSdkVersion` and want to leverage the latest SDK, please disable PayPal for versions below API 16, add `xmlns:tools="http://schemas.android.com/tools` inside the manifest's xml declaration, and add the following snippet to your `AndroidManifest.xml`: 138 | 139 | ```xml 140 | 141 | ``` 142 | 143 | See the [Android manifest merger docs](http://tools.android.com/tech-docs/new-build-system/user-guide/manifest-merger) for more information. 144 | 145 | ## Testing 146 | 147 | During development, use `environment()` in the `PayPalConfiguration` object to change the environment. Set it to either `ENVIRONMENT_NO_NETWORK` or `ENVIRONMENT_SANDBOX` to avoid moving real money. 148 | 149 | 150 | ## Documentation 151 | 152 | * These docs in the SDK, which include an overview of usage, step-by-step integration instructions, and sample code. 153 | * The sample app included in this SDK. 154 | * There are [javadocs](http://paypal.github.io/PayPal-Android-SDK/) available. 155 | * The [PayPal Developer Docs](https://developer.paypal.com/docs), which cover error codes and server-side integration instructions. 156 | 157 | 158 | ## Usability 159 | 160 | User interface appearance and behavior is set within the library itself. For the sake of usability and user experience consistency, apps should not attempt to modify the SDK's behavior beyond the documented methods. 161 | 162 | 163 | ## Next Steps 164 | 165 | Depending on your use case, you can now: 166 | 167 | * [Accept a single payment](docs/single_payment.md) 168 | * [Obtain user consent](docs/future_payments_mobile.md) to [create future payments](docs/future_payments_server.md). 169 | 170 | 171 | ## Contributing 172 | 173 | Please read our [contributing guidelines](CONTRIBUTING.md) prior to submitting a Pull Request. 174 | 175 | ## License 176 | 177 | Please refer to this repo's [license file](LICENSE). 178 | -------------------------------------------------------------------------------- /SampleApp-Kotlin/.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the dex VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | 15 | # Gradle files 16 | .gradle/ 17 | build/ 18 | 19 | # Local configuration file (sdk path, etc) 20 | local.properties 21 | 22 | # Eclipse settings files 23 | .settings/ 24 | 25 | # IntelliJ project files 26 | *.iml 27 | *.ipr 28 | *.iws 29 | .idea/ 30 | 31 | # Misc 32 | .DS_Store 33 | -------------------------------------------------------------------------------- /SampleApp-Kotlin/README.md: -------------------------------------------------------------------------------- 1 | PayPal Android SDK Sample App - Kotlin 2 | ============================= 3 | 4 | This is the PayPal Android SDK Sample App using the Kotlin Language. 5 | -------------------------------------------------------------------------------- /SampleApp-Kotlin/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.kotlin_version = '1.1.50' 3 | repositories { 4 | jcenter() 5 | mavenCentral() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:2.2.0' 9 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 10 | } 11 | } 12 | 13 | repositories { 14 | jcenter() 15 | mavenCentral() 16 | } 17 | 18 | apply plugin: 'com.android.application' 19 | apply plugin: 'kotlin-android' 20 | 21 | android { 22 | compileSdkVersion 26 23 | buildToolsVersion '24.0.1' 24 | 25 | defaultConfig { 26 | minSdkVersion 18 27 | targetSdkVersion 26 28 | } 29 | 30 | signingConfigs { 31 | debug { 32 | storeFile file('debug.keystore') 33 | storePassword 'android' 34 | keyAlias 'androiddebugkey' 35 | keyPassword 'android' 36 | } 37 | release { 38 | storeFile file('debug.keystore') 39 | storePassword 'android' 40 | keyAlias 'androiddebugkey' 41 | keyPassword 'android' 42 | } 43 | } 44 | 45 | // Only for SampleApp. 46 | // It is failing because the okio version and okhttp is not found, which is expected. 47 | lintOptions { 48 | abortOnError false 49 | } 50 | 51 | 52 | buildTypes { 53 | debug { 54 | applicationIdSuffix ".debug" 55 | signingConfig signingConfigs.debug 56 | } 57 | 58 | release{ 59 | minifyEnabled true 60 | proguardFile getDefaultProguardFile('proguard-android.txt') 61 | signingConfig signingConfigs.release 62 | } 63 | } 64 | 65 | android.applicationVariants.all { variant -> 66 | variant.outputs.each { output -> 67 | def outputFile = output.outputFile 68 | if (outputFile != null && outputFile.name.endsWith('.apk')) { 69 | output.outputFile = new File(outputFile.parent, "paypal-sample-app-${variant.name}.apk") 70 | } 71 | } 72 | } 73 | 74 | sourceSets { 75 | main.java.srcDirs += 'src/main/kotlin' 76 | } 77 | } 78 | 79 | dependencies { 80 | if (parent != null) { 81 | compile project(path: ':androidSDK', configuration: 'generalDebug') 82 | } else { 83 | compile('com.paypal.sdk:paypal-android-sdk:2.16.0') 84 | } 85 | compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" 86 | } 87 | 88 | task wrapper(type: Wrapper) { 89 | gradleVersion = '2.14' 90 | } 91 | -------------------------------------------------------------------------------- /SampleApp-Kotlin/debug.keystore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paypal/PayPal-Android-SDK/f7534f0951ae0ad1a7127069bac59a9ba8a23bec/SampleApp-Kotlin/debug.keystore -------------------------------------------------------------------------------- /SampleApp-Kotlin/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paypal/PayPal-Android-SDK/f7534f0951ae0ad1a7127069bac59a9ba8a23bec/SampleApp-Kotlin/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /SampleApp-Kotlin/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Jun 29 16:07:52 CDT 2016 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.14-bin.zip 7 | -------------------------------------------------------------------------------- /SampleApp-Kotlin/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /SampleApp-Kotlin/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /SampleApp-Kotlin/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /SampleApp-Kotlin/src/main/java/com/paypal/example/paypalandroidsdkexample/SampleActivity.kt: -------------------------------------------------------------------------------- 1 | package com.paypal.example.paypalandroidsdkexample 2 | 3 | import com.paypal.android.sdk.payments.PayPalAuthorization 4 | import com.paypal.android.sdk.payments.PayPalConfiguration 5 | import com.paypal.android.sdk.payments.PayPalFuturePaymentActivity 6 | import com.paypal.android.sdk.payments.PayPalItem 7 | import com.paypal.android.sdk.payments.PayPalOAuthScopes 8 | import com.paypal.android.sdk.payments.PayPalPayment 9 | import com.paypal.android.sdk.payments.PayPalPaymentDetails 10 | import com.paypal.android.sdk.payments.PayPalProfileSharingActivity 11 | import com.paypal.android.sdk.payments.PayPalService 12 | import com.paypal.android.sdk.payments.PaymentActivity 13 | import com.paypal.android.sdk.payments.PaymentConfirmation 14 | import com.paypal.android.sdk.payments.ShippingAddress 15 | 16 | 17 | import android.app.Activity 18 | import android.content.Intent 19 | import android.net.Uri 20 | import android.os.Bundle 21 | import android.util.Log 22 | import android.view.View 23 | import android.widget.TextView 24 | import android.widget.Toast 25 | 26 | import org.json.JSONException 27 | 28 | import java.math.BigDecimal 29 | import java.util.Arrays 30 | import java.util.HashSet 31 | 32 | /** 33 | * Basic sample using the SDK to make a payment or consent to future payments. 34 | * 35 | * For sample mobile backend interactions, see 36 | * https://github.com/paypal/rest-api-sdk-python/tree/master/samples/mobile_backend 37 | */ 38 | class SampleActivity : Activity() { 39 | 40 | override fun onCreate(savedInstanceState: Bundle?) { 41 | super.onCreate(savedInstanceState) 42 | setContentView(R.layout.activity_main) 43 | 44 | val intent = Intent(this, PayPalService::class.java) 45 | intent.putExtra(PayPalService.EXTRA_PAYPAL_CONFIGURATION, config) 46 | startService(intent) 47 | } 48 | 49 | fun onBuyPressed(pressed: View) { 50 | /* 51 | * PAYMENT_INTENT_SALE will cause the payment to complete immediately. 52 | * Change PAYMENT_INTENT_SALE to 53 | * - PAYMENT_INTENT_AUTHORIZE to only authorize payment and capture funds later. 54 | * - PAYMENT_INTENT_ORDER to create a payment for authorization and capture 55 | * later via calls from your server. 56 | * 57 | * Also, to include additional payment details and an item list, see getStuffToBuy() below. 58 | */ 59 | val thingToBuy = getThingToBuy(PayPalPayment.PAYMENT_INTENT_SALE) 60 | 61 | /* 62 | * See getStuffToBuy(..) for examples of some available payment options. 63 | */ 64 | 65 | val intent = Intent(this@SampleActivity, PaymentActivity::class.java) 66 | 67 | // send the same configuration for restart resiliency 68 | intent.putExtra(PayPalService.EXTRA_PAYPAL_CONFIGURATION, config) 69 | 70 | intent.putExtra(PaymentActivity.EXTRA_PAYMENT, thingToBuy) 71 | 72 | startActivityForResult(intent, REQUEST_CODE_PAYMENT) 73 | } 74 | 75 | private fun getThingToBuy(paymentIntent: String): PayPalPayment { 76 | return PayPalPayment(BigDecimal("1.75"), "USD", "sample item", 77 | paymentIntent) 78 | } 79 | 80 | /* 81 | * This method shows use of optional payment details and item list. 82 | */ 83 | private fun getStuffToBuy(paymentIntent: String): PayPalPayment { 84 | //--- include an item list, payment amount details 85 | val items = arrayOf( 86 | PayPalItem("sample item #1", 2, BigDecimal("87.50"), "USD", "sku-12345678"), 87 | PayPalItem("free sample item #2", 1, BigDecimal("0.00"), "USD", "sku-zero-price"), 88 | PayPalItem("sample item #3 with a longer name", 6, BigDecimal("37.99"), "USD", "sku-33333") 89 | ) 90 | val subtotal = PayPalItem.getItemTotal(items) 91 | val shipping = BigDecimal("7.21") 92 | val tax = BigDecimal("4.67") 93 | val paymentDetails = PayPalPaymentDetails(shipping, subtotal, tax) 94 | val amount = subtotal.add(shipping).add(tax) 95 | val payment = PayPalPayment(amount, "USD", "sample item", paymentIntent) 96 | payment.items(items).paymentDetails(paymentDetails) 97 | 98 | //--- set other optional fields like invoice_number, custom field, and soft_descriptor 99 | payment.custom("This is text that will be associated with the payment that the app can use.") 100 | 101 | return payment 102 | } 103 | 104 | /* 105 | * Add app-provided shipping address to payment 106 | */ 107 | private fun addAppProvidedShippingAddress(paypalPayment: PayPalPayment) { 108 | val shippingAddress = ShippingAddress() 109 | .recipientName("Mom Parker") 110 | .line1("52 North Main St.") 111 | .city("Austin") 112 | .state("TX") 113 | .postalCode("78729") 114 | .countryCode("US") 115 | paypalPayment.providedShippingAddress(shippingAddress) 116 | } 117 | 118 | /* 119 | * Enable retrieval of shipping addresses from buyer's PayPal account 120 | */ 121 | private fun enableShippingAddressRetrieval(paypalPayment: PayPalPayment, enable: Boolean) { 122 | paypalPayment.enablePayPalShippingAddressesRetrieval(enable) 123 | } 124 | 125 | fun onFuturePaymentPressed(pressed: View) { 126 | val intent = Intent(this@SampleActivity, PayPalFuturePaymentActivity::class.java) 127 | 128 | // send the same configuration for restart resiliency 129 | intent.putExtra(PayPalService.EXTRA_PAYPAL_CONFIGURATION, config) 130 | 131 | startActivityForResult(intent, REQUEST_CODE_FUTURE_PAYMENT) 132 | } 133 | 134 | fun onProfileSharingPressed(pressed: View) { 135 | val intent = Intent(this@SampleActivity, PayPalProfileSharingActivity::class.java) 136 | 137 | // send the same configuration for restart resiliency 138 | intent.putExtra(PayPalService.EXTRA_PAYPAL_CONFIGURATION, config) 139 | 140 | intent.putExtra(PayPalProfileSharingActivity.EXTRA_REQUESTED_SCOPES, oauthScopes) 141 | 142 | startActivityForResult(intent, REQUEST_CODE_PROFILE_SHARING) 143 | } 144 | 145 | private /* create the set of required scopes 146 | * Note: see https://developer.paypal.com/docs/integration/direct/identity/attributes/ for mapping between the 147 | * attributes you select for this app in the PayPal developer portal and the scopes required here. 148 | */ val oauthScopes: PayPalOAuthScopes 149 | get() { 150 | val scopes = HashSet( 151 | Arrays.asList( 152 | PayPalOAuthScopes.PAYPAL_SCOPE_EMAIL, 153 | PayPalOAuthScopes.PAYPAL_SCOPE_ADDRESS 154 | ) 155 | ) 156 | return PayPalOAuthScopes(scopes) 157 | } 158 | 159 | protected fun displayResultText(result: String) { 160 | var resultView:TextView = findViewById(R.id.txtResult) 161 | resultView.text = "Result : " + result 162 | Toast.makeText( 163 | applicationContext, 164 | result, Toast.LENGTH_LONG).show() 165 | } 166 | 167 | override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { 168 | if (requestCode == REQUEST_CODE_PAYMENT) { 169 | if (resultCode == Activity.RESULT_OK) { 170 | val confirm = data?.getParcelableExtra(PaymentActivity.EXTRA_RESULT_CONFIRMATION) 171 | if (confirm != null) { 172 | try { 173 | Log.i(TAG, confirm.toJSONObject().toString(4)) 174 | Log.i(TAG, confirm.payment.toJSONObject().toString(4)) 175 | /** 176 | * TODO: send 'confirm' (and possibly confirm.getPayment() to your server for verification 177 | * or consent completion. 178 | * See https://developer.paypal.com/webapps/developer/docs/integration/mobile/verify-mobile-payment/ 179 | * for more details. 180 | 181 | * For sample mobile backend interactions, see 182 | * https://github.com/paypal/rest-api-sdk-python/tree/master/samples/mobile_backend 183 | */ 184 | displayResultText("PaymentConfirmation info received from PayPal") 185 | 186 | 187 | } catch (e: JSONException) { 188 | Log.e(TAG, "an extremely unlikely failure occurred: ", e) 189 | } 190 | 191 | } 192 | } else if (resultCode == Activity.RESULT_CANCELED) { 193 | Log.i(TAG, "The user canceled.") 194 | } else if (resultCode == PaymentActivity.RESULT_EXTRAS_INVALID) { 195 | Log.i( 196 | TAG, 197 | "An invalid Payment or PayPalConfiguration was submitted. Please see the docs.") 198 | } 199 | } else if (requestCode == REQUEST_CODE_FUTURE_PAYMENT) { 200 | if (resultCode == Activity.RESULT_OK) { 201 | val auth = data?.getParcelableExtra(PayPalFuturePaymentActivity.EXTRA_RESULT_AUTHORIZATION) 202 | if (auth != null) { 203 | try { 204 | Log.i("FuturePaymentExample", auth.toJSONObject().toString(4)) 205 | 206 | val authorization_code = auth.authorizationCode 207 | Log.i("FuturePaymentExample", authorization_code) 208 | 209 | sendAuthorizationToServer(auth) 210 | displayResultText("Future Payment code received from PayPal") 211 | 212 | } catch (e: JSONException) { 213 | Log.e("FuturePaymentExample", "an extremely unlikely failure occurred: ", e) 214 | } 215 | 216 | } 217 | } else if (resultCode == Activity.RESULT_CANCELED) { 218 | Log.i("FuturePaymentExample", "The user canceled.") 219 | } else if (resultCode == PayPalFuturePaymentActivity.RESULT_EXTRAS_INVALID) { 220 | Log.i( 221 | "FuturePaymentExample", 222 | "Probably the attempt to previously start the PayPalService had an invalid PayPalConfiguration. Please see the docs.") 223 | } 224 | } else if (requestCode == REQUEST_CODE_PROFILE_SHARING) { 225 | if (resultCode == Activity.RESULT_OK) { 226 | val auth = data?.getParcelableExtra(PayPalProfileSharingActivity.EXTRA_RESULT_AUTHORIZATION) 227 | if (auth != null) { 228 | try { 229 | Log.i("ProfileSharingExample", auth.toJSONObject().toString(4)) 230 | 231 | val authorization_code = auth.authorizationCode 232 | Log.i("ProfileSharingExample", authorization_code) 233 | 234 | sendAuthorizationToServer(auth) 235 | displayResultText("Profile Sharing code received from PayPal") 236 | 237 | } catch (e: JSONException) { 238 | Log.e("ProfileSharingExample", "an extremely unlikely failure occurred: ", e) 239 | } 240 | 241 | } 242 | } else if (resultCode == Activity.RESULT_CANCELED) { 243 | Log.i("ProfileSharingExample", "The user canceled.") 244 | } else if (resultCode == PayPalFuturePaymentActivity.RESULT_EXTRAS_INVALID) { 245 | Log.i( 246 | "ProfileSharingExample", 247 | "Probably the attempt to previously start the PayPalService had an invalid PayPalConfiguration. Please see the docs.") 248 | } 249 | } 250 | } 251 | 252 | private fun sendAuthorizationToServer(authorization: PayPalAuthorization) { 253 | 254 | /** 255 | * TODO: Send the authorization response to your server, where it can 256 | * exchange the authorization code for OAuth access and refresh tokens. 257 | 258 | * Your server must then store these tokens, so that your server code 259 | * can execute payments for this user in the future. 260 | 261 | * A more complete example that includes the required app-server to 262 | * PayPal-server integration is available from 263 | * https://github.com/paypal/rest-api-sdk-python/tree/master/samples/mobile_backend 264 | */ 265 | 266 | } 267 | 268 | fun onFuturePaymentPurchasePressed(pressed: View) { 269 | // Get the Client Metadata ID from the SDK 270 | val metadataId = PayPalConfiguration.getClientMetadataId(this) 271 | 272 | Log.i("FuturePaymentExample", "Client Metadata ID: " + metadataId) 273 | 274 | // TODO: Send metadataId and transaction details to your server for processing with 275 | // PayPal... 276 | displayResultText("Client Metadata Id received from SDK") 277 | } 278 | 279 | public override fun onDestroy() { 280 | // Stop service when done 281 | stopService(Intent(this, PayPalService::class.java)) 282 | super.onDestroy() 283 | } 284 | 285 | companion object { 286 | private val TAG = "paymentExample" 287 | /** 288 | * - Set to PayPalConfiguration.ENVIRONMENT_PRODUCTION to move real money. 289 | 290 | * - Set to PayPalConfiguration.ENVIRONMENT_SANDBOX to use your test credentials 291 | * from https://developer.paypal.com 292 | 293 | * - Set to PayPalConfiguration.ENVIRONMENT_NO_NETWORK to kick the tires 294 | * without communicating to PayPal's servers. 295 | */ 296 | private val CONFIG_ENVIRONMENT = PayPalConfiguration.ENVIRONMENT_NO_NETWORK 297 | 298 | // note that these credentials will differ between live & sandbox environments. 299 | private val CONFIG_CLIENT_ID = "credentials from developer.paypal.com" 300 | 301 | private val REQUEST_CODE_PAYMENT = 1 302 | private val REQUEST_CODE_FUTURE_PAYMENT = 2 303 | private val REQUEST_CODE_PROFILE_SHARING = 3 304 | 305 | private val config = PayPalConfiguration() 306 | .environment(CONFIG_ENVIRONMENT) 307 | .clientId(CONFIG_CLIENT_ID) 308 | .merchantName("Example Merchant") 309 | .merchantPrivacyPolicyUri(Uri.parse("https://www.example.com/privacy")) 310 | .merchantUserAgreementUri(Uri.parse("https://www.example.com/legal")) 311 | } 312 | } 313 | -------------------------------------------------------------------------------- /SampleApp-Kotlin/src/main/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paypal/PayPal-Android-SDK/f7534f0951ae0ad1a7127069bac59a9ba8a23bec/SampleApp-Kotlin/src/main/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /SampleApp-Kotlin/src/main/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paypal/PayPal-Android-SDK/f7534f0951ae0ad1a7127069bac59a9ba8a23bec/SampleApp-Kotlin/src/main/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /SampleApp-Kotlin/src/main/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paypal/PayPal-Android-SDK/f7534f0951ae0ad1a7127069bac59a9ba8a23bec/SampleApp-Kotlin/src/main/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /SampleApp-Kotlin/src/main/res/drawable-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paypal/PayPal-Android-SDK/f7534f0951ae0ad1a7127069bac59a9ba8a23bec/SampleApp-Kotlin/src/main/res/drawable-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /SampleApp-Kotlin/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 10 | 11 | 18 | 19 |