[PAID] 💵 PayPal Extension to add payment system in you app

Extension Overview:

The "PayPal Extension By @Black_Knight " is your entry point for incorporating PayPal’s strength into your Kodular applications. With the help of this dynamic plugin, the PayPal API may be easily accessed by your apps. Its clever construction makes it simple to retrieve access tokens using client credentials, bringing up a plethora of options for creating payment features.

Blocks

:point_down:




4

Extension Overview:

This extension allows you to integrate PayPal payments into your App Inventor apps. It provides functions to:

  • Get an access token for interacting with PayPal APIs.

  • Make PayPal payments using various methods (credit card, PayPal account, etc.).

  • Refund payments.

  • Create basic invoices.

  • Check the status of payments.

  • Extract information from payment responses (e.g., payment ID, sale ID, currency code, price).

Functions and Events:

1

1. GetAccessToken:

  • Function: GetAccessToken(boolean isLive)

    • Retrieves an access token from PayPal using your client credentials.

    • Parameters:

      • isLive: true for live environment, false for sandbox.
  • Event:

1

AccessTokenObtained(String accessToken, String appId, int expiresIn, String respondCode)

  • Triggered when the access token is successfully retrieved.

  • Parameters:

    • accessToken: The retrieved access token.

    • appId: The PayPal app ID.

    • expiresIn: The expiration time of the access token in seconds.

    • respondCode: The response code from PayPal.

1

2. MakePayPalPayment:

  • Function: MakePayPalPayment(String accessToken, double amount, String currency, String productName, String productDescription, String returnUrl, String cancelUrl, boolean isLive)

    • Creates a PayPal payment request and handles the response.

    • Parameters:

      • accessToken: The access token.

      • amount: The payment amount.

      • currency: The currency code.

      • productName: The name of the product or service.

      • productDescription: A description of the product or service.

      • returnUrl: The URL where the user is redirected after successful payment.

      • cancelUrl: The URL where the user is redirected if they cancel the payment.

      • isLive: true for live environment, false for sandbox.

  • Event:

2

PaymentInfoObtained(String jsonResponse)

  • Triggered with the complete JSON response from PayPal.

  • Parameters:

    • jsonResponse: The JSON response containing payment information.

1

3. MakePaymentToEmail:

  • Function: This function allows you to send a simple payment to another PayPal account using the recipient’s email address. It handles the payment request and provides the response, including a redirect URL if necessary for the user to approve the payment.

    • Makes a PayPal payment to another account using the recipient’s email address.

    • Parameters:

      • accessToken: The access token.

      • recipientEmail: The recipient’s email address.

      • amount: The payment amount.

      • currency: The currency code.

      • note: An optional note to include with the payment.

      • returnUrl: The URL where the user is redirected after successful payment.

      • cancelUrl: The URL where the user is redirected if they cancel the payment.

      • isLive: true for live environment, false for sandbox.

  • Event:

2

PaymentToEmailResponse(boolean success, String jsonResponse, String redirectUrl)

  • Triggered with the response of the payment to email request.

  • Parameters:

    • success: true if the payment request was successful, false otherwise.

    • jsonResponse: The JSON response from PayPal.

    • redirectUrl: The URL to redirect the user to for payment approval (if applicable).

1

4. Pay with Credit Card:

  • Function: This function allows you to process credit card payments directly through PayPal without requiring the user to have a PayPal account.

    • Executes a PayPal credit card payment request and processes the response.

    • Parameters:

      • accessToken: The access token.

      • cardNumber: The credit card number.

      • cardType: The credit card type (e.g., “visa”, “mastercard”).

      • expireMonth: The credit card expiration month.

      • expireYear: The credit card expiration year.

      • cvv2: The credit card CVV2 code.

      • firstName: The cardholder’s first name.

      • lastName: The cardholder’s last name.

      • amount: The payment amount.

      • currency: The currency code.

      • paymentDescription: A description of the payment.

      • isLive: true for live environment, false for sandbox.

  • Event:

2

CreditCardPaymentResponse(String responseCode, String jsonResponse)

  • Triggered with the response of the credit card payment request.

  • Parameters:

    • responseCode: The HTTP response code from PayPal.

    • jsonResponse: The JSON response containing payment information.

1

5. Capture Amount:

  • Function: CaptureAmount(String paymentId, String payerId, String accessToken, boolean isLive)

    • Captures a previously authorized payment.

    • Parameters:

      • paymentId: The ID of the payment to capture.

      • payerId: The Payer ID associated with the payment.

      • accessToken: The access token.

      • isLive: true for live environment, false for sandbox.

  • Event:

2

AmountCaptured(boolean success, String response)

  • Triggered when the capture attempt is completed.

  • Parameters:

    • success: true if the capture was successful, false otherwise.

    • response: The JSON response from PayPal.

1

3. RefundPayment:

  • Function:

RefundPayment(String accessToken, String paymentId, double amount, String currency, String reason, boolean isLive)

  • Refunds a PayPal payment.

  • Parameters:

    • accessToken: The access token.

    • paymentId: The ID of the payment to refund.

    • amount: The amount to refund (optional, for partial refunds).

    • currency: The currency code (required if amount is specified).

    • reason: An optional reason for the refund.

    • isLive: true for live environment, false for sandbox.

  • Event:

2

RefundProcessed(String id, String state, String total, String currency, String reason)

  • Triggered when a refund is processed successfully.

  • Parameters:

    • id: The refund ID.

    • state: The state of the refund (e.g., “completed”).

    • total: The refunded amount.

    • currency: The currency code of the refund.

    • reason: The reason for the refund.

  • Event:

3

RefundError(String error, String errorDescription)

  • Triggered when an error occurs during the refund process.

  • Parameters:

    • error: The error code or type.

    • errorDescription: A description of the error.

4. CreateInvoice:

  • Function:

1

CreateInvoice(String accessToken, String recipientEmail, double amount, String currency, String description, boolean isLive)

  • Creates a basic PayPal invoice.

  • Parameters:

    • accessToken: The access token.

    • recipientEmail: The recipient’s email address.

    • amount: The invoice amount.

    • currency: The currency code.

    • description: A description of the invoice.

    • isLive: true for live environment, false for sandbox.

  • Event:

2

InvoiceCreated(boolean success, String response)

  • Triggered when an invoice is created.

  • Parameters:

    • success: true if the invoice was created successfully, false otherwise.

    • response: The JSON response from PayPal.

1

5. CheckPaymentStatus:

  • Function: CheckPaymentStatus(String paymentId, String accessToken, boolean isLive)

    • Checks the status of a specific PayPal payment.

    • Parameters:

      • paymentId: The ID of the payment to check.

      • accessToken: The access token.

      • isLive: true for live environment, false for sandbox.

  • Event:

2

PaymentStatusReceived(String paymentId, String id, String intent, String state, String createTime, String updateTime, String jsonResponse)

  • Triggered with the status of the payment.

  • Parameters:

    • paymentId: The original payment ID provided.

    • id: The actual payment ID from the response.

    • intent: The payment intent (e.g., “sale”).

    • state: The state of the payment (e.g., “approved”).

    • createTime: The time the payment was created.

    • updateTime: The time the payment was last updated.

    • jsonResponse: The complete JSON response from PayPal.

Additional Functions:

1

  • ExtractHrefFromLinks(String jsonResponse): Extracts the href value from a JSON response, typically used to obtain the approval URL for redirecting users to PayPal’s payment page.

1

  • ExtractHrefFromResponse(String jsonResponse): Extracts the href value from a payment response, specifically the approval URL for redirecting users to PayPal.

1

  • ExtractResponseCode(String jsonResponse): Extracts the response code from a JSON response.

1

  • ExtractIdFromResponse(String jsonResponse): Extracts the id value from a JSON response, typically the payment ID.

1

  • ExtractPaymentIdFromUrl(String url): Extracts the paymentId value from a URL, often used after a user returns from PayPal’s payment page.

1

  • ExtractPayerIdFromUrl(String url): Extracts the PayerID value from a URL, also used after a user returns from PayPal’s payment page.

1

  • ExtractSaleId(String jsonResponse): Extracts the “sale id” from a PayPal payment response.

1

  • ExtractCurrencyCode(String jsonResponse): Extracts the currency code from a PayPal payment response.

2

  • ExtractPrice(String jsonResponse): Extracts the price (total amount) from a PayPal payment response.

Explanation :



Step 1: Set Up Your Project

  1. Open Kodular and create a new project or open an existing one.

Step 2: Add Components

  1. Drag and drop a “WebViewer” component from the “User Interface” section onto your screen.
  2. Drag and drop the “Paypal” extension component onto the screen.

Step 3: Design Your User Interface

  1. Arrange your components on the screen as you wish. You might want to add buttons or labels for user interaction.

Step 4: Blocks Setup

  1. In the Blocks section, set up the logic to interact with the PayPal API using the extension and Web Viewer.
  2. Set the ClientId and ClientSecret properties of the PayPal extension.
  3. When the user performs an action (e.g., clicking a button), call the GetAccessToken function of the PayPal extension to obtain an access token.
  4. In the AccessTokenObtained event, call the MakePayPalPayment function to initiate a payment and obtain the payment link (href).
  5. In the PaymentInfoObtained event, parse the response and use the ExtractHrefFromLinks function to get the payment link.
  6. Load the extracted payment link into the Web Viewer using the Go to URL block.

Step 5: Handle Web Viewer Page Loaded and Redirect URLs

  1. Use the Web Viewer’s PageLoaded event to detect when the PayPal payment page has loaded.
  2. In the PageLoaded event, check the URL of the Web Viewer. If the URL matches the “cancel_url,” it indicates a cancelled payment.
  3. If the URL matches the “return_url,” it indicates a successful payment. You can show a success message to the user in this case.
  4. after successful payment you have to use the capture_amount block to capture your price

steps in one image :

Remember:

  • You’ll need to obtain your PayPal client ID and client secret from the PayPal Developer Dashboard.

  • Carefully review PayPal’s API documentation for specific requirements and limitations of each API call.

I hope this explanation helps you understand and use the PayPal Extension effectively in your App Inventor projects!

Preview_Video:

Test

Preview image
successful payment in live mode

Extension:

you will get aix file in addition to aia file that contains methods of installing the extension inside your project

You can buy it via PayPal it costs 8$ instead of 12$ after your payment you will be directed to the download URL of the zip file that contains aix and aia file of the extension . This offer valid for a limited duration

https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LHK3ZVXPW6M8L

© 2023 MrKoder. All rights reserved.

For inquiries, please contact: Mr koder

Visit our YouTube channel: Mr Koder’s YouTube Channel

6 Likes

Download link??

updated with working URLs

1 Like

It seems that it doesn’t wirk on koduler?

Could you explain how it doesn’t work?

any error message? show us your build log…
Taifun

I apologize, the error was mine, because this apk was not built in kodular, therefore it threw an error. I just took the extension in a new apk and it worked, so far I couldn’t get the paypal test mode to work, but it does work

No problem man the aia is for mit app invrntor but it could be work with Kodular too .
did live mode works with you ?

@Ruben_Pietrobelli Extension updated to include Test with sandbox in addition to Livemode
you can now able to test with your PayPal account

and thanks for your feedback .

Topic updated with new functions now extension working fine

this offer is valid for a limited duration

New block added

now you can use Extension to make user to pay for some one else via its PayPal email

component_event(2)

component_method

1 Like

Same thing is available for free :skull:

But does it offer also the same functionality and do you get support in case of issues? Most probably not… usually you get what you pay for…

Taifun

Thank you for your input !
But I don’t think that these free alternatives have the same features.

The topic is fully updated with new useful functions

2 Likes