-
-
Save pavi2410/62cb3022c3696111487256045adaaf58 to your computer and use it in GitHub Desktop.
package com.pavitra; | |
import android.app.Activity; | |
import android.util.Log; | |
import android.content.Context; | |
import android.widget.Toast; | |
import com.paytm.pgsdk.PaytmOrder; | |
import com.paytm.pgsdk.PaytmPGService; | |
import com.paytm.pgsdk.PaytmPaymentTransactionCallback; | |
import com.google.appinventor.components.annotations.*; | |
import com.google.appinventor.components.annotations.androidmanifest.*; | |
import com.google.appinventor.components.runtime.util.*; | |
import com.google.appinventor.components.common.*; | |
import java.util.HashMap; | |
import java.util.Map; | |
import java.util.Random; | |
@DesignerComponent(version = 1, | |
description = "PayTM extension by Pavitra", | |
category = ComponentCategory.EXTENSION, | |
nonVisible = true, | |
iconName = "images/extension.png") | |
@UsesLibraries(libraries = "paytm.jar") | |
@UsesPermissions(permissionNames = "android.permission.INTERNET, android.permission.ACCESS_NETWORK_STATE") | |
@UsesActivities(activities = { | |
@ActivityElement(name = "com.paytm.pgsdk.PaytmPGActivity", | |
screenOrientation = "portrait", | |
configChanges = "keyboardHidden|orientation|keyboard") | |
}) | |
@SimpleObject(external = true) | |
public class PayTM extends AndroidNonvisibleComponent implements Component { | |
private static final String LOG_TAG = "PayTM Extension"; | |
private Context context; | |
private static Activity activity; | |
private final Form form; | |
private boolean testMode = false; | |
public PayTM(ComponentContainer container) { | |
super(container.$form()); | |
this.form = container.$form(); | |
activity = container.$context(); | |
context = container.$context(); | |
Log.d(LOG_TAG, "PayTM Extension Created"); | |
} | |
@DesignerProperty(editorType = PropertyTypeConstants.PROPERTY_TYPE_BOOLEAN, defaultValue = "false") | |
@SimpleProperty | |
public void TestMode(boolean testMode) { | |
this.testMode = testMode; | |
} | |
@SimpleProperty | |
public boolean TestMode() { | |
return testMode; | |
} | |
@SimpleFunction | |
public String genOrderId() { | |
Random r = new Random(System.currentTimeMillis()); | |
return "ORDER" + (1 + r.nextInt(2)) * 10000 + r.nextInt(10000); | |
} | |
@SimpleFunction | |
public boolean DoTransaction(String merchantId, | |
String orderId, | |
String custId, | |
String industryType, | |
String channelId, | |
String website, | |
String checksum) { | |
// Getting the Service Instance. | |
PaytmPGService Service = testMode | |
? PaytmPGService.getStagingService() | |
: PaytmPGService.getProductionService(); | |
// Create new order Object having all order information. | |
Map<String, String> paramMap = new HashMap<String, String>(); | |
paramMap.put("MID", merchantId); | |
paramMap.put("ORDER_ID", orderId); | |
paramMap.put("CUST_ID", custId); | |
paramMap.put("INDUSTRY_TYPE_ID", industryType); | |
paramMap.put("CHANNEL_ID", channelId); | |
paramMap.put("TXN_AMOUNT", txnAmount); | |
paramMap.put("WEBSITE", website); | |
paramMap.put("CALLBACK_URL", "https://securegw.paytm.in/theia/paytmCallback?ORDER_ID=" + orderId); | |
paramMap.put("CHECKSUMHASH", checksum); | |
PaytmOrder Order = new PaytmOrder(paramMap); | |
// Set PaytmOrder and PaytmClientCertificate Object. Call this method and set both objects before starting transaction. | |
Service.initialize(Order, null); | |
// Start the Payment Transaction. Before starting the transaction ensure that initialize method is called. | |
Service.startPaymentTransaction(this.context, true, true, new PaytmPaymentTransactionCallback() { | |
@Override | |
public void someUIErrorOccurred(String inErrorMessage) { | |
Log.d("LOG", "UI Error Occur."); | |
} | |
@Override | |
public void onTransactionResponse(Bundle inResponse) { | |
Log.d("LOG", "Payment Transaction : " + inResponse); | |
} | |
@Override | |
public void networkNotAvailable() { | |
Log.d("LOG", "UI Error Occur."); | |
} | |
@Override | |
public void clientAuthenticationFailed(String inErrorMessage) { | |
Log.d("LOG", "UI Error Occur."); | |
} | |
@Override | |
public void onErrorLoadingWebPage(int iniErrorCode, String inErrorMessage, String inFailingUrl) { | |
} | |
@Override | |
public void onBackPressedCancelTransaction() { | |
// TODO Auto-generated method stub | |
} | |
@Override | |
public void onTransactionCancel(String inErrorMessage, Bundle inResponse) { | |
Log.d("LOG", "Payment Transaction Failed " + inErrorMessage); | |
} | |
}); | |
} | |
} |
Buildfile: /projects/goldv2/appinventor-sources/appinventor/build.xml
extensions:
clean:
init:
common_CommonUtils:
init:
CommonUtils:
common_CommonVersion:
init:
CommonVersion:
[exec] Result: 128
[exec] Result: 128
CopyToRunLibDir:
components_AndroidRuntime:
init:
CommonConstants:
[javac] Compiling 6 source files to /projects/goldv2/appinventor-sources/appinventor/components/build/classes/CommonConstants
[javac] warning: [options] bootstrap class path not set in conjunction with -source 1.7
[javac] 1 warning
HtmlEntities:
[javac] Compiling 1 source file to /projects/goldv2/appinventor-sources/appinventor/components/build/classes/HtmlEntities
[javac] warning: [options] bootstrap class path not set in conjunction with -source 1.7
[javac] 1 warning
common_CommonVersion:
init:
CommonVersion:
[exec] Result: 128
[exec] Result: 128
AndroidRuntime:
[javac] Compiling 332 source files to /projects/goldv2/appinventor-sources/appinventor/components/build/classes/AndroidRuntime
[javac] warning: [options] bootstrap class path not set in conjunction with -source 1.7
[javac] /projects/goldv2/appinventor-sources/appinventor/components/src/com/appybuilder/indianplans/PayTmRoti/PayTmRoti.java:37: error: class PayTM is public, should be declared in a file named PayTM.java
[javac] public class PayTM extends AndroidNonvisibleComponent implements Component {
[javac] ^
[javac] /projects/goldv2/appinventor-sources/appinventor/components/src/com/appybuilder/indianplans/PayTmRoti/PayTmRoti.java:11: error: package com.paytm.pgsdk does not exist
[javac] import com.paytm.pgsdk.PaytmOrder;
[javac] ^
[javac] /projects/goldv2/appinventor-sources/appinventor/components/src/com/appybuilder/indianplans/PayTmRoti/PayTmRoti.java:12: error: package com.paytm.pgsdk does not exist
[javac] import com.paytm.pgsdk.PaytmPGService;
[javac] ^
[javac] /projects/goldv2/appinventor-sources/appinventor/components/src/com/appybuilder/indianplans/PayTmRoti/PayTmRoti.java:13: error: package com.paytm.pgsdk does not exist
[javac] import com.paytm.pgsdk.PaytmPaymentTransactionCallback;
[javac] ^
[javac] /projects/goldv2/appinventor-sources/appinventor/components/src/com/appybuilder/indianplans/PayTmRoti/PayTmRoti.java:37: error: cannot find symbol
[javac] public class PayTM extends AndroidNonvisibleComponent implements Component {
[javac] ^
[javac] symbol: class AndroidNonvisibleComponent
[javac] /projects/goldv2/appinventor-sources/appinventor/components/src/com/appybuilder/indianplans/PayTmRoti/PayTmRoti.java:37: error: cannot find symbol
[javac] public class PayTM extends AndroidNonvisibleComponent implements Component {
[javac] ^
[javac] symbol: class Component
[javac] /projects/goldv2/appinventor-sources/appinventor/components/src/com/appybuilder/indianplans/PayTmRoti/PayTmRoti.java:42: error: cannot find symbol
[javac] private final Form form;
[javac] ^
[javac] symbol: class Form
[javac] location: class PayTM
[javac] /projects/goldv2/appinventor-sources/appinventor/components/src/com/appybuilder/indianplans/PayTmRoti/PayTmRoti.java:46: error: cannot find symbol
[javac] public PayTM(ComponentContainer container) {
[javac] ^
[javac] symbol: class ComponentContainer
[javac] location: class PayTM
[javac] /projects/goldv2/appinventor-sources/appinventor/components/src/com/appybuilder/indianplans/PayTmRoti/PayTmRoti.java:81: error: cannot find symbol
[javac] PaytmPGService Service = testMode
[javac] ^
[javac] symbol: class PaytmPGService
[javac] location: class PayTM
[javac] /projects/goldv2/appinventor-sources/appinventor/components/src/com/appybuilder/indianplans/PayTmRoti/PayTmRoti.java:82: error: cannot find symbol
[javac] ? PaytmPGService.getStagingService()
[javac] ^
[javac] symbol: variable PaytmPGService
[javac] location: class PayTM
[javac] /projects/goldv2/appinventor-sources/appinventor/components/src/com/appybuilder/indianplans/PayTmRoti/PayTmRoti.java:83: error: cannot find symbol
[javac] : PaytmPGService.getProductionService();
[javac] ^
[javac] symbol: variable PaytmPGService
[javac] location: class PayTM
[javac] /projects/goldv2/appinventor-sources/appinventor/components/src/com/appybuilder/indianplans/PayTmRoti/PayTmRoti.java:92: error: cannot find symbol
[javac] paramMap.put("TXN_AMOUNT", txnAmount);
[javac] ^
[javac] symbol: variable txnAmount
[javac] location: class PayTM
[javac] /projects/goldv2/appinventor-sources/appinventor/components/src/com/appybuilder/indianplans/PayTmRoti/PayTmRoti.java:97: error: cannot find symbol
[javac] PaytmOrder Order = new PaytmOrder(paramMap);
[javac] ^
[javac] symbol: class PaytmOrder
[javac] location: class PayTM
[javac] /projects/goldv2/appinventor-sources/appinventor/components/src/com/appybuilder/indianplans/PayTmRoti/PayTmRoti.java:97: error: cannot find symbol
[javac] PaytmOrder Order = new PaytmOrder(paramMap);
[javac] ^
[javac] symbol: class PaytmOrder
[javac] location: class PayTM
[javac] /projects/goldv2/appinventor-sources/appinventor/components/src/com/appybuilder/indianplans/PayTmRoti/PayTmRoti.java:103: error: cannot find symbol
[javac] Service.startPaymentTransaction(this.context, true, true, new PaytmPaymentTransactionCallback() {
[javac] ^
[javac] symbol: class PaytmPaymentTransactionCallback
[javac] location: class PayTM
[javac] Note: Some input files use or override a deprecated API.
[javac] Note: Recompile with -Xlint:deprecation for details.
[javac] Note: Some input files use unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.
[javac] 15 errors
[javac] 1 warning
BUILD FAILED
/projects/goldv2/appinventor-sources/appinventor/build.xml:35: The following error occurred while executing this line:
/projects/goldv2/appinventor-sources/appinventor/build-common.xml:372: The following error occurred while executing this line:
/projects/goldv2/appinventor-sources/appinventor/components/build.xml:141: The following error occurred while executing this line:
/projects/goldv2/appinventor-sources/appinventor/build-common.xml:118: Compile failed; see the compiler error output for details.
Total time: 7 seconds
avac] symbol: class PaytmOrder
[javac] location: class PayTM
[javac] /projects/goldv2/appinventor-sources/appinventor/components/src/com/appybuilder/indianplans/PayTmRoti/PayTmRoti.java:97: error: cannot find symbol
[javac] PaytmOrder Order = new PaytmOrder(paramMap);
[javac] ^
[javac] symbol: class PaytmOrder
[javac] location: class PayTM
[javac] /projects/goldv2/appinventor-sources/appinventor/components/src/com/appybuilder/indianplans/PayTmRoti/PayTmRoti.java:103: error: cannot find symbol
[javac] Service.startPaymentTransaction(this.context, true, true, new PaytmPaymentTransactionCallback() {
[javac] ^
[javac] symbol: class PaytmPaymentTransactionCallback
[javac] location: class PayTM
[javac] Note: Some input files use or override a deprecated API.
[javac] Note: Recompile with -Xlint:deprecation for details.
[javac] Note: Some input files use unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.
[javac] 15 errors
[javac] 1 warning
BUILD FAILED
/projects/goldv2/appinventor-sources/appinventor/build.xml:35: The following error occurred while executing this line:
/projects/goldv2/appinventor-sources/appinventor/build-common.xml:372: The following error occurred while executing this line:
/projects/goldv2/appinventor-sources/appinventor/components/build.xml:141: The following error occurred while executing this line:
/projects/goldv2/appinventor-sources/appinventor/build-common.xml:118: Compile failed; see the compiler error output for details.
Total time: 7 seconds
@indianplans Import this jar library https://gist.github.com/pavi2410/62cb3022c3696111487256045adaaf58#gistcomment-2390768
Sir, Link doesn't work
error: class PayTM is public, should be declared in a file named PayTM.java
Excuse me sir, The link for jar doesn't work
Sir please do reply
It shows Error while compiling
Build Log
Started Compiling Project PayTM
Buildfile: /compiler/android/build.xml
javac:
[mkdir] Created dir: /compiler/android/build/kpblw/classes
[javac] Compiling 1 source file to /compiler/android/build/kpblw/classes
[javac] warning: [options] bootstrap class path not set in conjunction with -source 1.7
[javac] warning: In component PayTM, method genOrderId is missing a description.
[javac] warning: In component PayTM, method DoTransaction is missing a description.
[javac] Note: Wrote file file:/compiler/android/build/kpblw/classes/simple_components.json
[javac] warning: In component PayTM, method genOrderId is missing a description.
[javac] warning: In component PayTM, method DoTransaction is missing a description.
[javac] Note: Wrote file file:/compiler/android/build/kpblw/classes/simple_components.txt
[javac] Note: Wrote file file:/compiler/android/build/kpblw/classes/simple_components_build_info.json
[javac] warning: In component PayTM, method genOrderId is missing a description.
[javac] warning: In component PayTM, method DoTransaction is missing a description.
[javac] Note: Wrote file file:/compiler/android/build/kpblw/classes/AutogeneratedOdeMessages.java
[javac] Note: Wrote file file:/compiler/android/build/kpblw/classes/ComponentsTranslation.java
[javac] warning: In component PayTM, method genOrderId is missing a description.
[javac] warning: In component PayTM, method DoTransaction is missing a description.
[javac] /compiler/android/src/kpblw/com/pavitra/PayTM.java:34: error: cannot find symbol
[javac] public class PayTM extends AndroidNonvisibleComponent implements Component {
[javac] ^
[javac] symbol: class AndroidNonvisibleComponent
[javac] /compiler/android/src/kpblw/com/pavitra/PayTM.java:34: error: cannot find symbol
[javac] public class PayTM extends AndroidNonvisibleComponent implements Component {
[javac] ^
[javac] symbol: class Component
[javac] /compiler/android/src/kpblw/com/pavitra/PayTM.java:39: error: cannot find symbol
[javac] private final Form form;
[javac] ^
[javac] symbol: class Form
[javac] location: class PayTM
[javac] /compiler/android/src/kpblw/com/pavitra/PayTM.java:43: error: cannot find symbol
[javac] public PayTM(ComponentContainer container) {
[javac] ^
[javac] symbol: class ComponentContainer
[javac] location: class PayTM
[javac] 4 errors
[javac] 8 warnings
Download latest jar for this project -https://artifactory.paytm.in/artifactory/libs-release-local/com/paytm/pgplussdk/
https://github.com/Paytm-Payments/Paytm_Android_App_Kit/blob/master/PaytmSDK/PGSDK_V2.1.jar