Guest User

Untitled

a guest
Feb 11th, 2018
523
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.17 KB | None | 0 0
  1. package com.example.itachi.com.payutest;
  2.  
  3. import android.os.Bundle;
  4. import android.support.v7.app.AppCompatActivity;
  5. import android.view.View;
  6.  
  7. import com.payu.india.Extras.PayUChecksum;
  8. import com.payu.india.Model.PaymentParams;
  9. import com.payu.india.Model.PayuConfig;
  10. import com.payu.india.Payu.Payu;
  11. import com.payumoney.core.PayUmoneySdkInitializer;
  12. import com.payumoney.sdkui.ui.utils.PayUmoneyFlowManager;
  13.  
  14. public class MainActivity extends AppCompatActivity {
  15.  
  16.  
  17. private String merchantKey, userCredentials;
  18.  
  19. // These will hold all the payment parameters
  20. private PaymentParams mPaymentParams;
  21.  
  22. // This sets the configuration
  23. private PayuConfig payuConfig;
  24.  
  25. private PayUChecksum checksum;
  26.  
  27.  
  28. @Override
  29. protected void onCreate(Bundle savedInstanceState) {
  30. super.onCreate(savedInstanceState);
  31. setContentView(R.layout.activity_main);
  32.  
  33. Payu.setInstance(this);
  34.  
  35. }
  36.  
  37. public void navigateToBaseActivity(View view) {
  38.  
  39. PayuUtils mm = new PayuUtils();
  40. PayuUtils.PayuHash m = new PayuUtils.PayuHash();
  41.  
  42. m.setKey("your merchant key");
  43. m.setAmount("12.23");
  44. m.setEmail("john@gmail.com");
  45. m.setTxnid("1323");
  46. m.setFirstname("John");
  47. m.setProductinfo("Mobile");
  48. m.setPhone("9874561230");
  49.  
  50. mm.setHash(m);
  51.  
  52. PayUmoneySdkInitializer.PaymentParam.Builder builder = mm.init();
  53. //declare paymentParam object
  54. PayUmoneySdkInitializer.PaymentParam paymentParam = builder.build();
  55. //set the hash
  56.  
  57. paymentParam.setMerchantHash(mm.gernerateMyHash(this));
  58.  
  59. PayUmoneyFlowManager.startPayUMoneyFlow(paymentParam,
  60. this, R.style.AppTheme_default, false);
  61. }
  62.  
  63.  
  64. }
  65.  
  66. package com.example.itachi.com.payutest;
  67.  
  68. import android.content.Context;
  69.  
  70. import com.payumoney.core.PayUmoneySdkInitializer;
  71.  
  72. import java.security.MessageDigest;
  73. import java.security.NoSuchAlgorithmException;
  74.  
  75. /**
  76. * Created by ITACHI on 11-02-2018.
  77. */
  78.  
  79. public class PayuUtils {
  80. public PayuHash hash;
  81.  
  82.  
  83. public PayuHash getHash() {
  84. return hash;
  85. }
  86.  
  87. public void setHash(PayuHash hash) {
  88. this.hash = hash;
  89. }
  90.  
  91. public static class PayuHash {
  92. private String key;
  93. private String txnid;
  94. private String amount;
  95. private String productinfo;
  96. private String firstname;
  97. private String email;
  98. private String phone;
  99.  
  100. public String getKey() {
  101. return key;
  102. }
  103.  
  104. public void setKey(String key) {
  105. this.key = key;
  106. }
  107.  
  108. public String getTxnid() {
  109. return txnid;
  110. }
  111.  
  112. public void setTxnid(String txnid) {
  113. this.txnid = txnid;
  114. }
  115.  
  116. public String getAmount() {
  117. return amount;
  118. }
  119.  
  120. public void setAmount(String amount) {
  121. this.amount = amount;
  122. }
  123.  
  124. public String getProductinfo() {
  125. return productinfo;
  126. }
  127.  
  128. public void setProductinfo(String productinfo) {
  129. this.productinfo = productinfo;
  130. }
  131.  
  132. public String getFirstname() {
  133. return firstname;
  134. }
  135.  
  136. public void setFirstname(String firstname) {
  137. this.firstname = firstname;
  138. }
  139.  
  140. public String getEmail() {
  141. return email;
  142. }
  143.  
  144. public void setEmail(String email) {
  145. this.email = email;
  146. }
  147.  
  148. public String getPhone() {
  149. return phone;
  150. }
  151.  
  152. public void setPhone(String phone) {
  153. this.phone = phone;
  154. }
  155. }
  156.  
  157. public String gernerateMyHash(Context context) {
  158. // String hashSequence = key|txnid|amount|productinfo|firstname|email| + salt;
  159. // key|txnid|amount|productinfo|firstname|email|udf1|udf2|udf3|udf4|udf5||||||salt
  160.  
  161. String hashSequence = hash.key + "|" + hash.txnid + "|" + hash.amount + "|" + hash.productinfo + "|" + hash.firstname + "|" + hash.email + "|||||||||||"+" salt";
  162. String serverCalculatedHash = hashCal("SHA-512", hashSequence);
  163.  
  164. return serverCalculatedHash;
  165. }
  166.  
  167. private String hashCal(String type, String hashString) {
  168. StringBuilder hash = new StringBuilder();
  169. MessageDigest messageDigest = null;
  170. try {
  171. messageDigest = MessageDigest.getInstance(type);
  172. messageDigest.update(hashString.getBytes());
  173. byte[] mdbytes = messageDigest.digest();
  174. for (byte hashByte : mdbytes) {
  175. hash.append(Integer.toString((hashByte & 0xff) + 0x100, 16).substring(1));
  176. }
  177. } catch (NoSuchAlgorithmException e) {
  178. e.printStackTrace();
  179. }
  180. return hash.toString();
  181. }
  182.  
  183.  
  184. public PayUmoneySdkInitializer.PaymentParam.Builder init()
  185. {
  186. // ransaction. Please use the sample code provided below to setup the SDK initializer.
  187.  
  188. // The ‘udf’ fields below stand for ‘user defined field’. These are optional fields to pass custom information about the transaction to PayUmoney. You may pass up to 5 UDF fields.
  189. PayUmoneySdkInitializer.PaymentParam.Builder builder = new
  190. PayUmoneySdkInitializer.PaymentParam.Builder();
  191. builder.setAmount(Double.parseDouble(hash.amount)) // Payment amount
  192. .setTxnId(hash.txnid) // Transaction ID
  193. .setPhone(hash.phone) // User Phone number
  194. .setProductName(hash.productinfo) // Product Name or description
  195. .setFirstName(hash.firstname) // User First name
  196. .setEmail(hash.email) // User Email ID
  197. //.setsUrl(appEnvironment.surl()) // Success URL (surl)
  198. .setsUrl("http://www.google.com") // Success URL (surl)
  199. //.setfUrl(appEnvironment.furl()) //Failure URL (furl
  200. .setfUrl("http://www.facebook.com") //Failure URL (furl
  201. .setIsDebug(true) // Integration environment - true (Debug)/ false(Production)
  202. .setKey(hash.key) // Merchant key
  203. .setMerchantId("1723"); // not founded what to put
  204.  
  205. return builder;
  206. }
  207. }
  208.  
  209. 02-12 00:20:23.906 16366-16366/? I/art: Late-enabling -Xcheck:jni
  210. 02-12 00:20:23.942 16366-16366/com.example.itachi.com.payutest W/System: ClassLoader referenced unknown path: /data/app/com.example.itachi.com.payutest-1/lib/arm
  211. 02-12 00:20:23.976 16366-16366/com.example.itachi.com.payutest W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
  212. 02-12 00:20:24.101 16366-16389/com.example.itachi.com.payutest I/Adreno-EGL: <qeglDrvAPI_eglInitialize:379>: EGL 1.4 QUALCOMM build: Nondeterministic_AU_msm8974_LA.BF.1.1.3_RB1__release_AU (I741a3d36ca)
  213. OpenGL ES Shader Compiler Version: E031.29.00.00
  214. Build Date: 04/04/16 Mon
  215. Local Branch: mybranch19053788
  216. Remote Branch: quic/LA.BF.1.1.3_rb1.12
  217. Local Patches: NONE
  218. Reconstruct Branch: NOTHING
  219. 02-12 00:20:24.104 16366-16389/com.example.itachi.com.payutest I/OpenGLRenderer: Initialized EGL, version 1.4
  220. 02-12 00:20:24.104 16366-16389/com.example.itachi.com.payutest D/OpenGLRenderer: Swap behavior 1
  221. 02-12 00:20:24.107 16366-16389/com.example.itachi.com.payutest W/Adreno-ES20: <get_gpu_clk:229>: open failed: errno 13
  222. 02-12 00:20:31.613 16366-16366/com.example.itachi.com.payutest D/SdkHelper: isvalidEmail : true
  223. 02-12 00:20:31.613 16366-16366/com.example.itachi.com.payutest D/SdkHelper: isValidNumber : 9874561230
  224. 02-12 00:20:31.613 16366-16366/com.example.itachi.com.payutest D/SdkHelper: isValidNumber : true
  225. 02-12 00:20:31.615 16366-16366/com.example.itachi.com.payutest D/hash: cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e
  226. 02-12 00:20:31.615 16366-16366/com.example.itachi.com.payutest D/param :: key - your merchant key
  227. 02-12 00:20:31.616 16366-16366/com.example.itachi.com.payutest D/param :: merchantId - 1723
  228. 02-12 00:20:31.616 16366-16366/com.example.itachi.com.payutest D/param :: txnid - 1323
  229. 02-12 00:20:31.616 16366-16366/com.example.itachi.com.payutest D/param :: amount - 12.23
  230. 02-12 00:20:31.616 16366-16366/com.example.itachi.com.payutest D/param :: surl - http://www.google.com
  231. 02-12 00:20:31.616 16366-16366/com.example.itachi.com.payutest D/param :: furl - http://www.facebook.com
  232. 02-12 00:20:31.616 16366-16366/com.example.itachi.com.payutest D/param :: productInfo - Mobile
  233. 02-12 00:20:31.616 16366-16366/com.example.itachi.com.payutest D/param :: email - john@gmail.com
  234. 02-12 00:20:31.616 16366-16366/com.example.itachi.com.payutest D/param :: firstName - John
  235. 02-12 00:20:31.616 16366-16366/com.example.itachi.com.payutest D/param :: phone - 9874561230
  236. 02-12 00:20:31.616 16366-16366/com.example.itachi.com.payutest D/param :: udf1 -
  237. 02-12 00:20:31.616 16366-16366/com.example.itachi.com.payutest D/param :: udf2 -
  238. 02-12 00:20:31.616 16366-16366/com.example.itachi.com.payutest D/param :: udf3 -
  239. 02-12 00:20:31.616 16366-16366/com.example.itachi.com.payutest D/param :: udf4 -
  240. 02-12 00:20:31.616 16366-16366/com.example.itachi.com.payutest D/param :: udf5 -
  241. 02-12 00:20:31.616 16366-16366/com.example.itachi.com.payutest D/param :: udf6 -
  242. 02-12 00:20:31.616 16366-16366/com.example.itachi.com.payutest D/param :: udf7 -
  243. 02-12 00:20:31.616 16366-16366/com.example.itachi.com.payutest D/param :: udf8 -
  244. 02-12 00:20:31.616 16366-16366/com.example.itachi.com.payutest D/param :: udf9 -
  245. 02-12 00:20:31.617 16366-16366/com.example.itachi.com.payutest D/param :: udf10 -
  246. 02-12 00:20:31.629 16366-16366/com.example.itachi.com.payutest W/System: ClassLoader referenced unknown path: /system/app/Chrome/lib/arm
  247. 02-12 00:20:31.631 16366-16366/com.example.itachi.com.payutest D/ApplicationLoaders: ignored Vulkan layer search path /system/app/Chrome/lib/arm:/system/app/Chrome/Chrome.apk!/lib/armeabi-v7a:/system/lib:/vendor/lib for namespace 0x82a1a090
  248. 02-12 00:20:31.635 16366-16366/com.example.itachi.com.payutest I/WebViewFactory: Loading com.android.chrome version 55.0.2883.91 (code 288309102)
  249. 02-12 00:20:31.674 16366-16366/com.example.itachi.com.payutest I/cr_LibraryLoader: Time to load native libraries: 5 ms (timestamps 6596-6601)
  250. 02-12 00:20:31.675 16366-16366/com.example.itachi.com.payutest I/cr_LibraryLoader: Expected native library version number "55.0.2883.91", actual native library version number "55.0.2883.91"
  251. 02-12 00:20:31.690 16366-16366/com.example.itachi.com.payutest I/cr_LibraryLoader: Expected native library version number "55.0.2883.91", actual native library version number "55.0.2883.91"
  252. 02-12 00:20:31.691 16366-16366/com.example.itachi.com.payutest I/chromium: [INFO:library_loader_hooks.cc(163)] Chromium logging enabled: level = 0, default verbosity = 0
  253. 02-12 00:20:31.705 16366-16366/com.example.itachi.com.payutest I/cr_BrowserStartup: Initializing chromium process, singleProcess=true
  254. 02-12 00:20:31.721 16366-16366/com.example.itachi.com.payutest W/hi.com.payutest: type=1400 audit(0.0:19529): avc: denied { read } for name="gpuclk" dev="sysfs" ino=11414 scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:object_r:sysfs:s0 tclass=file permissive=0
  255. 02-12 00:20:31.723 16366-16366/com.example.itachi.com.payutest W/Adreno-ES20: <get_gpu_clk:229>: open failed: errno 13
  256. 02-12 00:20:31.831 16366-16366/com.example.itachi.com.payutest D/Clevertap: eventName : SDKInit
  257. 02-12 00:20:31.851 16366-16366/com.example.itachi.com.payutest D/Clevertap: eventData : {"ts":1518375031,"identity":"john@gmail.com","type":"event","evtData":{"MID":"1723","d_lang":"English","d_biohw":true,"u_lat":"","sdk_build":"7.1.0","d_scrn_res":"1080 * 1920","uuid":"56579813-8aa0-45fd-a01c-4d28baf81f80","d_osv":"7.1.2","app_name":"PayuTest","env":"DEBUG","d_os":"Android","EventSource":"SDK","d_ccid":"in","Platform":"Android","d_ua":"Mozilla/5.0 (Linux; Android 7.1.2; ZUK Z1 Build/NJH47F; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/55.0.2883.91 Mobile Safari/537.36","d_nw_type":"4G","d_ss":"0","app_version_name":"1.0","d_make":"ZUK","isUserLoggedIn":false,"d_model":"ZUK Z1","u_lon":"","u_acu":"","app_id":"com.example.itachi.com.payutest","app_version_code":"1","d_mfg":"ZUK","pnp_version":"1.1.0","package_name":"com.example.itachi.com.payutest","device_id":"cd907527cbb8740d","d_rooted":true,"sdk_version":"9","d_locale":"en","ip":"10.38.108.171","d_scrn_sz":"13.766366812144597"},"evtName":"SDKInit"}
  258. 02-12 00:20:32.127 16366-16712/com.example.itachi.com.payutest D/NetworkSecurityConfig: No Network Security Config specified, using platform default
  259. 02-12 00:20:32.128 16366-16712/com.example.itachi.com.payutest W/System: ClassLoader referenced unknown path: /system/framework/tcmclient.jar
  260. 02-12 00:20:32.129 16366-16712/com.example.itachi.com.payutest W/System: Ignoring header UserSessionCookiePageUrl because its value was null.
  261. 02-12 00:20:32.325 16366-16389/com.example.itachi.com.payutest D/OpenGLRenderer: endAllActiveAnimators on 0xb39e2e00 (RippleDrawable) with handle 0x6e6393c0
  262. 02-12 00:20:34.279 16366-16366/com.example.itachi.com.payutest I/Difference: [ main: SourceFile: 361: onResponse() ] --> URL=/payment/app/v1/addPaymentTime=2184
  263. 02-12 00:20:38.349 16366-16948/com.example.itachi.com.payutest D/Clevertap: Response : { "status" : "success" , "processed" : 1 , "unprocessed" : [ ]}
  264. 02-12 00:20:38.351 16366-16948/com.example.itachi.com.payutest D/Clevertap: OnClevertapEventsLoggedSuccessful : file deleted
Add Comment
Please, Sign In to add comment