paypal-checkout

PayPal IAP for Android

License

License

GroupId

GroupId

io.github.kaustubhpatange
ArtifactId

ArtifactId

paypal-checkout
Last Version

Last Version

1.4
Release Date

Release Date

Type

Type

aar
Description

Description

paypal-checkout
PayPal IAP for Android
Project URL

Project URL

https://github.com/KaustubhPatange/PayPal-IAP-for-Android
Source Code Management

Source Code Management

https://github.com/KaustubhPatange/PayPal-IAP-for-Android/tree/master

Download paypal-checkout

How to add to project

<!-- https://jarcasting.com/artifacts/io.github.kaustubhpatange/paypal-checkout/ -->
<dependency>
    <groupId>io.github.kaustubhpatange</groupId>
    <artifactId>paypal-checkout</artifactId>
    <version>1.4</version>
    <type>aar</type>
</dependency>
// https://jarcasting.com/artifacts/io.github.kaustubhpatange/paypal-checkout/
implementation 'io.github.kaustubhpatange:paypal-checkout:1.4'
// https://jarcasting.com/artifacts/io.github.kaustubhpatange/paypal-checkout/
implementation ("io.github.kaustubhpatange:paypal-checkout:1.4")
'io.github.kaustubhpatange:paypal-checkout:aar:1.4'
<dependency org="io.github.kaustubhpatange" name="paypal-checkout" rev="1.4">
  <artifact name="paypal-checkout" type="aar" />
</dependency>
@Grapes(
@Grab(group='io.github.kaustubhpatange', module='paypal-checkout', version='1.4')
)
libraryDependencies += "io.github.kaustubhpatange" % "paypal-checkout" % "1.4"
[io.github.kaustubhpatange/paypal-checkout "1.4"]

Dependencies

compile (1)

Group / Artifact Type Version
androidx.databinding » viewbinding jar 4.0.1

runtime (4)

Group / Artifact Type Version
org.jetbrains.kotlin : kotlin-android-extensions-runtime jar 1.3.72
org.jetbrains.kotlin : kotlin-stdlib jar 1.3.72
androidx.core » core-ktx jar 1.3.1
androidx.appcompat » appcompat jar 1.2.0

Project Modules

There are no modules declared in this project.

PayPal IAP for Android

Maven Central

An unofficial PayPal In-App-Purchase library for Android apps. Using this you can easily accept payments within your Android app.

The library source is hidden to protect it from anti-tampering.

If you are likely publishing your app to Google Play. It is recommended not to use any other payment method other than their official one. There is a high chance your app might get banned.

It is always good to have other IAP methods. ❤️

FAQ

Q. How is this different from the offical?

Well, for starters the official sdk repository has no long term support but its ok since it still works. The main problem with direct payments are, they don't return purchase details as this library does.

Also it doesn't accept credit card purchase which is possible by using PayPal buttons. XDA Labs uses their own implementation of such process.

Q. Can you steal our credentials?

If you are thinking that I might steal your credential during payment process, then I must say this is technically not possible with only having "Internet" permission in manifest (also I don't care).

Download

Library is available on mavenCentral()

implementation 'io.github.kaustubhpatange:paypal-checkout:$version'

Usage

For more information on how to use this payment mode, check the sample provided in this Github repo. A basic workflow is shown below.

  • Each IAP is basically a Paypal button, so you first need to create it by following this guide.

Checkout (Single payment only)

  • You will need a button Id & redirect url which you have created in above step. Create an Options from Options.Builder class with this information.
val options = Paypal.Options(
    paypalButtonId = "button-id",
    purchaseCompleteUrl = "redirect-url",
    isSandbox = true // Set this to false to accept live payments
)
  • Initialize PayPal class using PayPal.Builder class where you need to pass this option as constructor parameter. This class will be responsible for payment checkout.

Note: Each instance of PayPal class can hold one button Id only.

private lateinit var paypal: Paypal

paypal = Paypal.Builder(options)
            .setCallingContext(this) // Activity or Fragment
  • Start your checkout process.
paypal.checkout(
    closeOnCheckout = false, // See this parameter behavior at the bottom of this guide.
    onCheckOutComplete = { details ->
        Toast.makeText(this, "Completed with ${details?.email}", Toast.LENGTH_SHORT).show()
    },
    showCloseDialog = true, // (Optional) default true
    showDoNotCloseInfo = true, // (Optional) default true
    showProgressBar = true // (Optional) default true
)

Detect completion or cancellation

  • You need to override onActivityResult method as follows.
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
    super.onActivityResult(requestCode, resultCode, data)

    if (paypal.isPurchaseComplete(requestCode, resultCode)) {
        val details = data?.getSerializableExtra(Paypal.PURCHASE_DATA) as? Paypal.History
        // Do something after purchase complete.
        // ...
    } else if (paypal.isPurchaseCancelled(requestCode, resultCode)) {
        // Do something after purchase cancelled.
    }
}

Anatomy of closeOnCheckout

closeOnCheckout = false closeOnCheckout = true
You need to manually click "Return to Merchant" button to trigger purchase complete. Directly exit payment screen after completing checkout.

Sample

For more information on how to use this payment mode, check the sample provided in this Github repo.

Requirements

  • AndroidX
  • Min SDK 19+

License

Copyright 2020 Kaustubh Patange

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Versions

Version
1.4
1.3
1.2
1.1
1.0