PayPal MPL library

Erel

B4X founder
Staff member
Licensed User
Longtime User
This library is a wrapper for PayPal MPL SDK. Note that currently PayPal is migrating to a new SDK named Mobile SDK. The Mobile SDK is a different SDK and is only supported in the US.

PayPal MPL is considered part of PayPal Classic API and is based on the Adaptive API.

Currently only "Basic Payments" are supported.

Relevant links:
- PayPal MPL SDK: https://github.com/paypal/sdk-packa...al_MPL_1.5.6.46_Android-Developer-Package.zip (click on the Raw button).
You should download this zip file and copy PayPal_MPL.Jar from the MPL Library folder to Basic4android libraries folder.

- PayPal Java guide: https://developer.paypal.com/webapps/developer/docs/classic/mobile/ht_mpl-itemPayment-Android/

- Sandbox accounts: https://developer.paypal.com/webapps/developer/applications/accounts

It is quite simple to accept payments with PayPal library.

For example:
B4X:
Sub Globals
   Dim pp As PayPal
End Sub

Sub Activity_Create(FirstTime As Boolean)
   pp.Initialize("APP-80W284485P519543T", True, "paypal")
End Sub

Sub PayPal_Ready (Success As Boolean)
   Log("Ready: " & Success)
   If Success Then
      Activity.AddView(pp.GetPayPalButton(True), 0, 0, 200dip, 100dip)
   End If
End Sub

Sub PayPal_Click
   pp.RequestPayment("USD", 100, "[email protected]", "My Company", _
      pp.PAYMENT_TYPE_SERVICE)
End Sub

Sub PayPal_Result (Success As Boolean, Extra As String)
   Log("Success: " & Success & ", Extra: " & Extra)
End Sub
The first step is to initialize the PayPal object.
The Ready event is raised when the service is ready. You should then add the PayPal button.

When the user clicks on this button we make a payment request. The user will be asked for his account details:

SS-2013-06-02_12.57.44.png


The Result event is raised when the payment is processed (or canceled).
Extra parameter will hold the transaction key or the error message (or "canceled" for canceled transactions).

The following code should be added to the manifest editor:
B4X:
AddApplicationText(
<activity android:name="com.paypal.android.MEP.PayPalActivity"
   android:theme="@android:style/Theme.Translucent.NoTitleBar"
   android:configChanges="keyboardHidden|orientation"/>)

V1.00 - Fixes an issue with a missing permission.
 

Attachments

  • PayPalWrapper.zip
    6.3 KB · Views: 1,020
Last edited:

motley

Member
Licensed User
Longtime User
GREAT news!!

BTW
not sure, but can user pay by credit card?? or just from an account??
 

desof

Well-Known Member
Licensed User
Longtime User
1° as you can translate the text on the button and where it says My Total?

2° For it appears a banner SandBox?
 

Laurent95

Active Member
Licensed User
Longtime User
Hi,
Thank you Erel, very helpful.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
1° as you can translate the text on the button and where it says My Total?
In v1.0 you cannot change the language. However such a feature can be added in a simple update.

2° For it appears a banner SandBox?
This line sets the mode to Sandbox mode:
B4X:
pp.Initialize("APP-80W284485P519543T", True, "paypal")
This is useful for testing.
 

bluedude

Well-Known Member
Licensed User
Longtime User
What do you mean by Basic Payments?

Hi,

Looking on the x.com site of PayPal and Basic Payments is not a product. What do you mean by that?

Cheers,
 

bluedude

Well-Known Member
Licensed User
Longtime User
So when you say "basic" you mean the "simple" payment method? So purchasing just one product?
 

bluedude

Well-Known Member
Licensed User
Longtime User
Again, sorry :)

Just trying to figure out to which Paypal solution you are referring to so I can read that documentation.

You say "Basic" in your post, do you mean Adaptive and the Simple method?

Cheers,
 

bluedude

Well-Known Member
Licensed User
Longtime User
Basic, simple ??? What is it!

Hi,

I have the feeling you are referring to the wrong product when you say "Basic" in your post. I assume you mean the "Simple" Adaptive payment method?

Does this need IPN configuration?

Cheers.
 

Jaames

Active Member
Licensed User
Longtime User
PayPal button won't appear

I'm not sure should I open a new thread, or I can ask here.

I'm using this wrapper now in one of my app, but, on some devices paypal button won't appear. It is very rare but it happens.

Does anybody know if this is related to the wrapper or paypal library ?

And of course, Thanks a milion for this lib ;)
 

Jaames

Active Member
Licensed User
Longtime User
Can you reproduce it?

Unfortunately I can not..

On my devices it is working like a charm, but few of my users reported me that
button won't appear.

I can't figure out what could be wrong...

I'm using this wrapper and Parse library, to make licenced software.

One guy who bought my app successfully on the phone, told me that on his
tablet Galaxy Note 10.1 paypal button won't appear. And he is connected to
the same WiFi connection with both devices.
 

Jaames

Active Member
Licensed User
Longtime User
Are you checking the value of Success parameter (Ready event)?
B4X:
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("l1")

pp.Initialize("APP-***********", False, "paypal")
ProgressDialogShow("Waiting for PayPal button to appear...")
End Sub

B4X:
Sub PayPal_Ready (Success As Boolean)
    Log("Ready: " & Success)
    If Success Then
        Activity.AddView(pp.GetPayPalButton(False), Label5.Left, Label5.Top + Label5.Height,Label5.Width, 60dip)
        ProgressDialogHide
    End If
End Sub

That's the code I use, as you write in your tutorial.
As I said, no problem on my devices, but some users reported that there is no paypal button...
 
Top