├── .gitignore
├── LICENSE
├── README.md
├── app
├── .gitignore
├── build.gradle
├── debug.keystore
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── uz
│ │ └── paycom
│ │ └── testpaycom
│ │ └── TestActivity.java
│ └── res
│ ├── layout
│ └── activity_test.xml
│ ├── mipmap-hdpi
│ └── ic_launcher.png
│ ├── mipmap-mdpi
│ └── ic_launcher.png
│ ├── mipmap-xhdpi
│ └── ic_launcher.png
│ ├── mipmap-xxhdpi
│ └── ic_launcher.png
│ ├── mipmap-xxxhdpi
│ └── ic_launcher.png
│ ├── values-w820dp
│ └── dimens.xml
│ └── values
│ ├── colors.xml
│ ├── dimens.xml
│ ├── strings.xml
│ └── styles.xml
├── build.gradle
├── docs
└── img.png
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── payment
├── .gitignore
├── build.gradle
├── proguard-payment.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── uz
│ │ └── paycom
│ │ └── payment
│ │ ├── ConfirmActivity.java
│ │ ├── PaymentActivity.java
│ │ ├── api
│ │ ├── JsonParser.java
│ │ ├── JsonRpcRequest.java
│ │ ├── TLSSocketFactory.java
│ │ └── task
│ │ │ └── VerifyCardTask.java
│ │ ├── model
│ │ ├── Confirm.java
│ │ └── Result.java
│ │ └── utils
│ │ ├── CardNumberFormat.java
│ │ ├── DateExpireFormat.java
│ │ ├── LocaleHelper.java
│ │ ├── Logger.java
│ │ ├── PaycomSandBox.java
│ │ └── ViewDisable.java
│ └── res
│ ├── drawable
│ ├── ic_repeat.xml
│ └── ic_warning.xml
│ ├── layout
│ ├── paycom_payment_confirm.xml
│ └── paycom_payment_main.xml
│ ├── values-uz
│ └── strings.xml
│ └── values
│ ├── colors.xml
│ ├── dimens.xml
│ ├── strings.xml
│ └── styles.xml
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | #built application files
2 | *.apk
3 | *.ap_
4 |
5 | # Java class files
6 | *.class
7 |
8 | # built native files (uncomment if you build your own)
9 | # *.o
10 | # *.so
11 |
12 | # generated files
13 | bin/
14 | gen/
15 |
16 | # Ignore gradle files
17 | .gradle/
18 | build/
19 |
20 | # Android Studio Navigation editor temp files
21 | .navigation/
22 |
23 | # files for the dex VM
24 | *.dex
25 |
26 | # generated files
27 | bin/
28 | gen/
29 |
30 | # Local configuration file (sdk path, etc)
31 | local.properties
32 |
33 | # Windows thumbnail db
34 | Thumbs.db
35 |
36 | # Android Studio captures folder
37 | captures/
38 |
39 | # OSX files
40 | .DS_Store
41 |
42 | # Proguard folder generated by Eclipse
43 | proguard/
44 |
45 | # Eclipse project files
46 | .classpath
47 | .project
48 | .metadata/
49 |
50 | # Android Studio
51 | *.iml
52 | .idea
53 |
54 | # Mac OS X clutter
55 | *.DS_Store
56 |
57 | # mpeltonen/sbt-idea plugin
58 | .idea_modules/
59 |
60 | # IntelliJ
61 | /out/
62 |
63 | /*/out
64 | /*/*/build
65 | /*/*/production
66 | *.iws
67 | *.ipr
68 | *~
69 | *.swp
70 |
71 | */build
72 | */production
73 | */local.properties
74 | */out
75 |
76 | # Log Files
77 | *.log
78 |
79 | #NDK
80 | obj/
81 |
82 | local.properties
83 |
84 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "{}"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright {yyyy} {name of copyright owner}
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Paycom Android SDK [](https://bintray.com/paycom/general/android-sdk/_latestVersion)
2 |
3 | Чтобы интегрировать Paycom с мобильным приложением, подключите к мобильному приложению [библиотеку Paycom Android SDK](https://github.com/PaycomUZ/AndroidSDK) и реализуйте [методы работы с пластиковыми картами](http://paycom.uz/api/#subscribe-api-metody-dlya-raboty-s-plastikovymi-kartami-servernaya-chast) и [чеком](http://paycom.uz/api/#subscribe-api-metody-dlya-raboty-s-chekom-servernaya-chast) из [Subscribe API](http://paycom.uz/api/#subscribe-api).
4 |
5 | В библиотеке Paycom Android SDK — реализован пользовательский интерфейс и все [методы работы с пластиковыми картами для клиентской части](http://paycom.uz/api/#subscribe-api-metody-dlya-raboty-s-plastikovymi-kartami-klientskaya-chast).
6 |
7 | [Последняя версия библиотеки Paycom Android SDK на bintray](https://bintray.com/paycom/general/android-sdk)
8 |
9 | ## Подключение библиотеки
10 |
11 | 1. Добавьте в app build.gradle:
12 |
13 | ```java
14 | dependencies {
15 | compile 'uz.paycom:payment:$last version'
16 | }
17 | ```
18 |
19 | 2. Встройте в приложение вызов на оплату:
20 | ```java
21 | @Override public void onClick(View v) {
22 | Intent intent = new Intent(YourActivity.this, PaymentActivity.class);
23 | intent.putExtra(EXTRA_ID, xAuth); //Ваш ID мерчанта
24 | final Double sum = Double.valueOf(activityTestSum.getText().toString());
25 | intent.putExtra(EXTRA_AMOUNT, sum); //Сумма оплаты
26 | intent.putExtra(EXTRA_SAVE, activityTestMultiple.isChecked()); //Сохранить для многократной оплаты?
27 | intent.putExtra(EXTRA_LANG, "RU"); //Язык "RU" или "UZ"
28 | PaycomSandBox.setEnabled(false); //true для тестовой площадки
29 | startActivityForResult(intent, 0);
30 | }
31 | ```
32 |
33 | ## Обработка результата
34 |
35 | После вызова оплаты: покупатель вводит данные платежа, Paycom SDK — возвращает токен для совершения платежа. Токен передаётся в backend мобильного приложения.
36 |
37 | **Пример**
38 | ```java
39 | @Override
40 | protected void onActivityResult(int requestCode, int resultCode, Intent data) {
41 | super.onActivityResult(requestCode, resultCode, data);
42 | if (resultCode == RESULT_OK) {
43 | Result result = data.getParcelableExtra(EXTRA_RESULT);
44 | Log.d(TAG, result.toString());
45 | } else if (resultCode == RESULT_CANCELED) {
46 | Log.d(TAG, "Payment canceled"); //Произошла отмена оплаты
47 | }
48 | }
49 | ```
50 |
51 | **Result** содержит поля:
52 |
53 | - number: string // Маскированный номер карты;
54 |
55 | - expire: string // Срок действия карты;
56 |
57 | - token: string // Токен для совершения платежа. Токен передаётся в backend мобильного приложения и используется для [оплаты чека](http://paycom.uz/api/#subscribe-api-metody-dlya-raboty-s-chekom-servernaya-chast-oplata-cheka).
58 |
59 | - recurrent: boolean // Возможность проведения повторных платежей. Если false — возможна только одна транзакция с обязательным указанием точно такой же суммы.
60 |
61 | - verify: boolean // Была ли пройдена идентификация владельца карты по смс.
62 |
63 | ## Тестирование в песочнице
64 |
65 | СМС-код безопасности для всех тестовых карт всегда: 666666
66 |
67 | **Тестовые карты**
68 |
69 | | Номер | Срок действия карты (Expired) | Комментарий |
70 | | ------------------- | ----------------------------- | --------------------------------- |
71 | | 8600 0691 9540 6311 | 03/20 | |
72 | | 8600 4954 7331 6478 | 03/20 | |
73 | | 8600 0609 2109 0842 | 03/20 | Не подключенно СМС информирование |
74 | | 3333 3364 1580 4657 | 03/15 | Срок дейтвия истек |
75 | | 4444 4459 8745 9073 | 03/20 | Карта заблокированнна |
76 |
77 | ## Пользовательский интерфейс
78 |
79 | 
80 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion project.ext.compileSdkVersion
5 | buildToolsVersion project.ext.buildToolsVersion
6 | defaultConfig {
7 | applicationId "uz.paycom.testpaycom"
8 | minSdkVersion project.ext.minSdkVersion
9 | targetSdkVersion project.ext.targetSdkVersion
10 | versionCode project.ext.versionCode
11 | versionName project.ext.versionName
12 | }
13 | signingConfigs {
14 | release {
15 | keyAlias 'androiddebugkey'
16 | keyPassword 'android'
17 | storeFile file('debug.keystore')
18 | storePassword 'android'
19 | }
20 | }
21 | buildTypes {
22 | debug {
23 | debuggable true
24 | }
25 | release {
26 | minifyEnabled true
27 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
28 | signingConfig signingConfigs.release
29 | }
30 | }
31 | }
32 |
33 | dependencies {
34 | implementation "com.android.support:appcompat-v7:$supportVersion"
35 | implementation project(':payment')
36 | }
--------------------------------------------------------------------------------
/app/debug.keystore:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PaycomUZ/AndroidSDK/d4c3e1832c389ea8707ce914abc66daf566b6132/app/debug.keystore
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PaycomUZ/AndroidSDK/d4c3e1832c389ea8707ce914abc66daf566b6132/app/proguard-rules.pro
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/app/src/main/java/uz/paycom/testpaycom/TestActivity.java:
--------------------------------------------------------------------------------
1 | package uz.paycom.testpaycom;
2 |
3 | import android.content.Intent;
4 | import android.support.v7.app.AppCompatActivity;
5 | import android.os.Bundle;
6 | import android.util.Log;
7 | import android.view.View;
8 | import android.widget.Button;
9 | import android.widget.CheckBox;
10 | import android.widget.EditText;
11 |
12 | import uz.paycom.payment.PaymentActivity;
13 | import uz.paycom.payment.model.Result;
14 | import uz.paycom.payment.utils.PaycomSandBox;
15 |
16 | import static uz.paycom.payment.PaymentActivity.EXTRA_AMOUNT;
17 | import static uz.paycom.payment.PaymentActivity.EXTRA_ID;
18 | import static uz.paycom.payment.PaymentActivity.EXTRA_LANG;
19 | import static uz.paycom.payment.PaymentActivity.EXTRA_RESULT;
20 | import static uz.paycom.payment.PaymentActivity.EXTRA_SAVE;
21 |
22 | public class TestActivity extends AppCompatActivity {
23 |
24 | private static final String TAG = "TestActivity";
25 | private static final String xAuth = "5a3bb098d9ffa237dc027290";
26 |
27 | @Override protected void onCreate(Bundle savedInstanceState) {
28 | super.onCreate(savedInstanceState);
29 | setContentView(R.layout.activity_test);
30 |
31 | final EditText activityTestSum = findViewById(R.id.activity_test_sum);
32 | final CheckBox activityTestMultiple = findViewById(R.id.activity_test_multiple);
33 | final Button activityTestPayment = findViewById(R.id.activity_test_payment);
34 |
35 | activityTestPayment.setOnClickListener(new View.OnClickListener() {
36 | @Override
37 | public void onClick(View v) {
38 | Intent intent = new Intent(TestActivity.this, PaymentActivity.class);
39 | intent.putExtra(EXTRA_ID, xAuth);
40 | final Double sum = Double.valueOf(activityTestSum.getText().toString());
41 | intent.putExtra(EXTRA_AMOUNT, sum);
42 | intent.putExtra(EXTRA_SAVE, activityTestMultiple.isChecked());
43 | intent.putExtra(EXTRA_LANG, "RU");
44 | PaycomSandBox.setEnabled(false);
45 | startActivityForResult(intent, 0);
46 | }
47 | });
48 | }
49 |
50 | @Override
51 | protected void onActivityResult(int requestCode, int resultCode, Intent data) {
52 | super.onActivityResult(requestCode, resultCode, data);
53 | if (resultCode == RESULT_OK) {
54 | Result result = data.getParcelableExtra(EXTRA_RESULT);
55 | Log.d(TAG, result.toString());
56 | } else if (resultCode == RESULT_CANCELED) {
57 | Log.d(TAG, "Payment canceled");
58 | }
59 | }
60 | }
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_test.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
14 |
21 |
27 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PaycomUZ/AndroidSDK/d4c3e1832c389ea8707ce914abc66daf566b6132/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PaycomUZ/AndroidSDK/d4c3e1832c389ea8707ce914abc66daf566b6132/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PaycomUZ/AndroidSDK/d4c3e1832c389ea8707ce914abc66daf566b6132/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PaycomUZ/AndroidSDK/d4c3e1832c389ea8707ce914abc66daf566b6132/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PaycomUZ/AndroidSDK/d4c3e1832c389ea8707ce914abc66daf566b6132/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #e71f15
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | TestPaycom
3 | Многократная оплата
4 | Оплата
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | repositories {
3 | google()
4 | jcenter()
5 | mavenCentral()
6 | maven {url "https://jitpack.io"}
7 | maven {url 'https://maven.fabric.io/public'}
8 | }
9 | dependencies {
10 | classpath 'com.android.tools.build:gradle:3.3.2'
11 | classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
12 | classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
13 | }
14 | }
15 |
16 | plugins {
17 | id "com.jfrog.bintray" version "1.7.3"
18 | }
19 |
20 | allprojects {
21 | repositories {
22 | google()
23 | jcenter()
24 | mavenCentral()
25 | maven {url "https://jitpack.io"}
26 | maven {url 'https://maven.fabric.io/public'}
27 | }
28 | project.ext {
29 | buildToolsVersion = "28.0.3"
30 | minSdkVersion = 16
31 | targetSdkVersion = 28
32 | compileSdkVersion = 28
33 | supportVersion = "28.0.0"
34 | versionCode = 1
35 | versionName = "1.0"
36 | }
37 | }
--------------------------------------------------------------------------------
/docs/img.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PaycomUZ/AndroidSDK/d4c3e1832c389ea8707ce914abc66daf566b6132/docs/img.png
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | #org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
19 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PaycomUZ/AndroidSDK/d4c3e1832c389ea8707ce914abc66daf566b6132/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Mar 06 12:41:32 UZT 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/payment/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/payment/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'com.jfrog.bintray'
3 | apply plugin: 'com.github.dcendents.android-maven'
4 |
5 | Properties properties = new Properties()
6 | properties.load(project.rootProject.file('local.properties').newDataInputStream())
7 |
8 | ext {
9 | code = 1
10 | ver = "1.0.5.5"
11 | }
12 |
13 | android {
14 | compileSdkVersion project.ext.compileSdkVersion
15 | buildToolsVersion project.ext.buildToolsVersion
16 | defaultConfig {
17 | minSdkVersion project.ext.minSdkVersion
18 | targetSdkVersion project.ext.targetSdkVersion
19 | versionCode code
20 | versionName ver
21 | }
22 | buildTypes {
23 | debug {
24 | debuggable true
25 | }
26 | release {
27 | minifyEnabled true
28 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-payment.pro'
29 | }
30 | }
31 | }
32 |
33 | dependencies {
34 | implementation "com.android.support:appcompat-v7:$supportVersion"
35 | }
36 |
37 | group = 'uz.paycom'
38 | version = ver
39 |
40 | bintray {
41 | user = properties.getProperty("bintray.user")
42 | key = properties.getProperty("bintray.apikey")
43 | configurations = ['archives']
44 | pkg {
45 | repo = 'general'
46 | name = 'android-sdk'
47 | userOrg = 'paycom'
48 | licenses = ['Apache-2.0']
49 | vcsUrl = 'https://github.com/PaycomUZ/AndroidSDK.git'
50 | version {
51 | name = ver
52 | desc = 'Paycom android sdk'
53 | vcsTag = ver
54 | }
55 | }
56 | }
57 |
58 | task sourcesJar(type: Jar) {
59 | from android.sourceSets.main.java.srcDirs
60 | classifier = 'sources'
61 | }
62 |
63 | task javadoc(type: Javadoc) {
64 | source = android.sourceSets.main.java.srcDirs
65 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
66 | }
67 |
68 | task javadocJar(type: Jar, dependsOn: javadoc) {
69 | classifier = 'javadoc'
70 | from javadoc.destinationDir
71 | }
72 |
73 | artifacts {
74 | archives javadocJar
75 | archives sourcesJar
76 | }
--------------------------------------------------------------------------------
/payment/proguard-payment.pro:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PaycomUZ/AndroidSDK/d4c3e1832c389ea8707ce914abc66daf566b6132/payment/proguard-payment.pro
--------------------------------------------------------------------------------
/payment/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/payment/src/main/java/uz/paycom/payment/ConfirmActivity.java:
--------------------------------------------------------------------------------
1 | package uz.paycom.payment;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.content.res.Resources;
6 | import android.os.AsyncTask;
7 | import android.os.Bundle;
8 | import android.os.CountDownTimer;
9 | import android.support.v7.app.AppCompatActivity;
10 | import android.text.TextUtils;
11 | import android.view.View;
12 | import android.view.WindowManager;
13 | import android.widget.Button;
14 | import android.widget.EditText;
15 | import android.widget.ImageView;
16 | import android.widget.ProgressBar;
17 | import android.widget.RelativeLayout;
18 | import android.widget.TextView;
19 |
20 | import org.json.JSONObject;
21 |
22 | import uz.paycom.payment.api.JsonParser;
23 | import uz.paycom.payment.api.JsonRpcRequest;
24 | import uz.paycom.payment.model.Confirm;
25 | import uz.paycom.payment.utils.LocaleHelper;
26 |
27 | import static uz.paycom.payment.PaymentActivity.EXTRA_LANG;
28 |
29 | public class ConfirmActivity extends AppCompatActivity {
30 |
31 | public final static String ARG_CONFIRM = "CONFIRM";
32 | public final static String ARG_TOKEN = "TOKEN";
33 |
34 | private String token;
35 |
36 | private Button activityConfirmButton;
37 | private ImageView activityRepeatImage;
38 | private TextView activityConfirmError;
39 | private TextView activityConfirmClose;
40 | private TextView activityConfirmTimer;
41 | private EditText activityConfirmCodeConfirm;
42 | private TextView activityConfirmPhoneNumber;
43 | private ProgressBar activityConfirmProgress;
44 | private TextView activityConfirmErrorMessage;
45 | private TextView activityConfirmPhoneNumberTitle;
46 | private TextView activityConfirmCodeConfirmTitle;
47 | private RelativeLayout activityConfirmErrorLayout;
48 |
49 | @Override protected void onCreate(Bundle savedInstanceState) {
50 | super.onCreate(savedInstanceState);
51 | setContentView(R.layout.paycom_payment_confirm);
52 |
53 | getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
54 |
55 | activityRepeatImage = findViewById(R.id.activity_repeat_image);
56 | activityConfirmError = findViewById(R.id.activity_confirm_error);
57 | activityConfirmClose = findViewById(R.id.activity_confirm_close);
58 | activityConfirmTimer = findViewById(R.id.activity_confirm_timer);
59 | activityConfirmButton = findViewById(R.id.activity_confirm_button);
60 | activityConfirmProgress = findViewById(R.id.activity_confirm_progress);
61 | activityConfirmErrorLayout = findViewById(R.id.activity_confirm_errorLayout);
62 | activityConfirmCodeConfirm = findViewById(R.id.activity_confirm_codeConfirm);
63 | activityConfirmPhoneNumber = findViewById(R.id.activity_confirm_phoneNumber);
64 | activityConfirmErrorMessage = findViewById(R.id.activity_confirm_errorMessage);
65 | activityConfirmCodeConfirmTitle = findViewById(R.id.activity_confirm_codeConfirmTitle);
66 | activityConfirmPhoneNumberTitle = findViewById(R.id.activity_confirm_phoneNumberTitle);
67 |
68 | Context context = LocaleHelper.onAttach(this, getIntent().getStringExtra(EXTRA_LANG));
69 | Resources resources = context.getResources();
70 | this.setTitle(resources.getString(R.string.paycomTitle));
71 | activityConfirmError.setText(resources.getString(R.string.error));
72 | activityConfirmClose.setText(resources.getString(R.string.close));
73 | activityConfirmCodeConfirmTitle.setText(resources.getString(R.string.codeConfirm));
74 | activityConfirmPhoneNumberTitle.setText(resources.getString(R.string.codeSent));
75 | activityConfirmButton.setText(resources.getString(R.string.confirm));
76 | activityConfirmCodeConfirmTitle.setText(resources.getString(R.string.codeConfirm));
77 |
78 | initUI(null);
79 | token = getIntent().getStringExtra(ARG_TOKEN);
80 | //Shared OnClickListener not allowed in library module project
81 | activityConfirmButton.setOnClickListener(new View.OnClickListener() {
82 | @Override
83 | public void onClick(View v) {
84 | activityConfirmErrorLayout.setVisibility(View.GONE);
85 | activityConfirmButton.setEnabled(false);
86 | activityConfirmProgress.setVisibility(View.VISIBLE);
87 | new ConfirmTask().execute();
88 | }
89 | });
90 |
91 | activityConfirmClose.setOnClickListener(new View.OnClickListener() {
92 | @Override
93 | public void onClick(View v) {
94 | activityConfirmErrorLayout.setVisibility(View.GONE);
95 | }
96 | });
97 |
98 | activityRepeatImage.setOnClickListener(new View.OnClickListener() {
99 | @Override
100 | public void onClick(View v) {
101 | activityConfirmErrorLayout.setVisibility(View.GONE);
102 | activityConfirmButton.setEnabled(false);
103 | activityConfirmProgress.setVisibility(View.VISIBLE);
104 | new RetryTask().execute();
105 | }
106 | });
107 | }
108 |
109 | private void initUI(Confirm confirm) {
110 | if (confirm == null) {
111 | confirm = getIntent().getParcelableExtra(ARG_CONFIRM);
112 | }
113 |
114 | activityConfirmPhoneNumber.setText(confirm.getPhone());
115 | activityRepeatImage.setVisibility(View.GONE);
116 | activityConfirmTimer.setVisibility(View.VISIBLE);
117 | new CountDownTimer(confirm.getWait(), 1000) {
118 | public void onTick(long millisUntilFinished) {
119 | activityConfirmTimer.setText("0:" + String.valueOf(millisUntilFinished / 1000));
120 | }
121 | public void onFinish() {
122 | activityRepeatImage.setVisibility(View.VISIBLE);
123 | activityConfirmTimer.setVisibility(View.GONE);
124 | }
125 | }.start();
126 | }
127 |
128 | private class ConfirmTask extends AsyncTask {
129 |
130 | private String code;
131 | private boolean hasError;
132 | private JsonParser jsonParser;
133 |
134 | public ConfirmTask() {
135 | this.jsonParser = new JsonParser();
136 | }
137 |
138 | @Override protected void onPreExecute() {
139 | code = activityConfirmCodeConfirm.getText().toString();
140 | }
141 |
142 | @Override protected String doInBackground(Void... params) {
143 | JsonRpcRequest jsonRpcRequest = new JsonRpcRequest(PaymentActivity.id);
144 |
145 | JSONObject jsonObject = jsonParser.getCardsVerify(token, code);
146 | String result = jsonRpcRequest.callApiMethod(jsonObject, JsonRpcRequest.cardsCreateVerifyMethod);
147 |
148 | if (result == null) return null;
149 | if (jsonParser.checkError(result) != null) {
150 | hasError = true;
151 | return jsonParser.checkError(result);
152 | }
153 |
154 | return result;
155 | }
156 |
157 | @Override protected void onPostExecute(String s) {
158 | if (s == null) {
159 | showError(getString(R.string.tryAgainMessage));
160 | } else if (hasError) {
161 | showError(s);
162 | } else {
163 | Intent intent = new Intent();
164 | intent.putExtra(PaymentActivity.EXTRA_RESULT, jsonParser.getResult(s));
165 | setResult(RESULT_OK, intent);
166 | finish();
167 | }
168 | activityConfirmButton.setEnabled(true);
169 | activityConfirmProgress.setVisibility(View.GONE);
170 | }
171 | }
172 |
173 | private class RetryTask extends AsyncTask {
174 |
175 | private boolean hasError;
176 | private JsonParser jsonParser;
177 |
178 | public RetryTask() {
179 | jsonParser = new JsonParser();
180 | }
181 |
182 | @Override
183 | protected String doInBackground(Void... params) {
184 | JsonRpcRequest jsonRpcRequest = new JsonRpcRequest(PaymentActivity.id);
185 | JSONObject jsonObject = jsonParser.getCardsVerifyCode(token);
186 |
187 | String result = jsonRpcRequest.callApiMethod(jsonObject, JsonRpcRequest.cardsGetVerifyCodeMethod);
188 | if (result == null) return null;
189 | if (jsonParser.checkError(result) != null) {
190 | hasError = true;
191 | return jsonParser.checkError(result);
192 | }
193 |
194 | return result;
195 | }
196 |
197 | @Override
198 | protected void onPostExecute(String s) {
199 | if (s == null) {
200 | showError(getString(R.string.tryAgainMessage));
201 | } else if (hasError) {
202 | showError(s);
203 | } else {
204 | initUI(jsonParser.getConfirm(s));
205 | }
206 | activityConfirmButton.setEnabled(true);
207 | activityConfirmProgress.setVisibility(View.GONE);
208 | }
209 | }
210 |
211 | private void showError(String s) {
212 | if (!TextUtils.isEmpty(s)) {
213 | activityConfirmErrorLayout.setVisibility(View.VISIBLE);
214 | activityConfirmErrorMessage.setText(s);
215 | }
216 | }
217 |
218 | @Override
219 | public void onBackPressed() {
220 | super.onBackPressed();
221 | setResult(RESULT_CANCELED);
222 | }
223 | }
--------------------------------------------------------------------------------
/payment/src/main/java/uz/paycom/payment/PaymentActivity.java:
--------------------------------------------------------------------------------
1 | package uz.paycom.payment;
2 |
3 | import android.content.Context;
4 | import android.content.res.Resources;
5 | import android.os.Bundle;
6 | import android.support.v7.app.AppCompatActivity;
7 | import android.text.TextUtils;
8 | import android.view.View;
9 | import android.widget.Button;
10 | import android.widget.CheckBox;
11 | import android.widget.EditText;
12 | import android.widget.ProgressBar;
13 | import android.widget.RelativeLayout;
14 | import android.widget.TextView;
15 |
16 | import java.text.DecimalFormat;
17 | import java.text.DecimalFormatSymbols;
18 |
19 | import uz.paycom.payment.api.task.VerifyCardTask;
20 | import uz.paycom.payment.utils.CardNumberFormat;
21 | import uz.paycom.payment.utils.DateExpireFormat;
22 | import uz.paycom.payment.utils.LocaleHelper;
23 | import uz.paycom.payment.utils.PaycomSandBox;
24 |
25 | public class PaymentActivity extends AppCompatActivity {
26 |
27 | public static String id;
28 |
29 | public static final String EXTRA_ID = "ID";
30 | public static final String EXTRA_LANG = "LANG";
31 | public static final String EXTRA_SAVE = "SAVE";
32 | public static final String EXTRA_AMOUNT = "AMOUNT";
33 | public static final String EXTRA_RESULT = "RESULT";
34 |
35 | private TextView activityMainClose;
36 | private TextView activityMainPaymentSum;
37 | private TextView activityMainErrorMessage;
38 | private TextView activityMainPaymentSumTitle;
39 | private TextView activityMainErrorLayoutError;
40 | private TextView activityMainCardNumberTitle;
41 | private TextView activityMainUzcardOnlyText;
42 | private TextView activityMainDateExpireTitle;
43 | private RelativeLayout activityMainErrorLayout;
44 |
45 | private DecimalFormat decimalFormat;
46 |
47 | public EditText activityMainCardNumber;
48 | public EditText activityMainDateExpire;
49 | public CheckBox activityMainCardRemember;
50 | public Button activityMainContinue;
51 | public ProgressBar activityMainProgress;
52 |
53 | public String lang;
54 | public Double amount;
55 | public boolean save;
56 |
57 | @Override protected void onCreate(Bundle savedInstanceState) {
58 | super.onCreate(savedInstanceState);
59 | setContentView(R.layout.paycom_payment_main);
60 |
61 | activityMainClose = findViewById(R.id.activity_main_close);
62 | activityMainContinue = findViewById(R.id.activity_main_continue);
63 | activityMainProgress = findViewById(R.id.activity_main_progress);
64 | activityMainCardNumber = findViewById(R.id.activity_main_cardNumber);
65 | activityMainPaymentSum = findViewById(R.id.activity_main_paymentSum);
66 | activityMainDateExpire = findViewById(R.id.activity_main_dateExpire);
67 | activityMainErrorLayout = findViewById(R.id.activity_main_errorLayout);
68 | activityMainErrorMessage = findViewById(R.id.activity_main_errorMessage);
69 | activityMainCardRemember = findViewById(R.id.activity_main_cardRemember);
70 | activityMainUzcardOnlyText = findViewById(R.id.activity_main_uzcardOnlyText);
71 | activityMainCardNumberTitle = findViewById(R.id.activity_main_cardNumberTitle);
72 | activityMainPaymentSumTitle = findViewById(R.id.activity_main_paymentSumTitle);
73 | activityMainDateExpireTitle = findViewById(R.id.activity_main_dateExpireTitle);
74 | activityMainErrorLayoutError = findViewById(R.id.activity_main_errorLayout_error);
75 |
76 | initUI();
77 | activityMainCardNumber.addTextChangedListener(new
78 | CardNumberFormat(activityMainContinue, activityMainDateExpire));
79 | activityMainDateExpire.addTextChangedListener(new
80 | DateExpireFormat(activityMainContinue, activityMainCardNumber));
81 |
82 | activityMainContinue.setEnabled(false);
83 | activityMainContinue.setAlpha(.3f);
84 | activityMainContinue.setClickable(false);
85 | activityMainContinue.setOnClickListener(new View.OnClickListener() {
86 | @Override
87 | public void onClick(View v) {
88 | String number = activityMainCardNumber.getText().toString().replace(" ", "");
89 | if (!isOnline(number) && !PaycomSandBox.isSandBox()) {
90 | showError(getString(R.string.uzcardOnly));
91 | return;
92 | }
93 | if (!isValid(number)) showError(getString(R.string.invalidCard));
94 | new VerifyCardTask(PaymentActivity.this).execute();
95 | activityMainContinue.setEnabled(false);
96 | activityMainProgress.setVisibility(View.VISIBLE);
97 | activityMainErrorLayout.setVisibility(View.GONE);
98 | }
99 | });
100 |
101 | activityMainClose.setOnClickListener(new View.OnClickListener() {
102 | @Override
103 | public void onClick(View v) {
104 | activityMainErrorLayout.setVisibility(View.GONE);
105 | }
106 | });
107 | }
108 |
109 | private void initUI() {
110 | //Set language from intent param
111 | lang = getIntent().getStringExtra(EXTRA_LANG);
112 | Context context = LocaleHelper.onAttach(this, lang);
113 | Resources resources = context.getResources();
114 |
115 | this.setTitle(resources.getString(R.string.paycomTitle));
116 | activityMainErrorLayoutError.setText(resources.getString(R.string.error));
117 | activityMainClose.setText(resources.getString(R.string.close));
118 | activityMainPaymentSumTitle.setText(resources.getString(R.string.paymentSum));
119 | activityMainCardNumberTitle.setText(resources.getString(R.string.cardNumber));
120 | activityMainUzcardOnlyText.setText(resources.getString(R.string.uzcardOnly));
121 | activityMainDateExpireTitle.setText(resources.getString(R.string.dateExpire));
122 | activityMainDateExpire.setHint(resources.getString(R.string.dateExpireHint));
123 | activityMainContinue.setText(resources.getString(R.string.continueText));
124 | activityMainCardRemember.setText(resources.getString(R.string.cardRemember));
125 |
126 | id = getIntent().getStringExtra(EXTRA_ID);
127 | amount = getIntent().getDoubleExtra(EXTRA_AMOUNT, 0.00);
128 | //Round to 2 fraction digits after comma
129 | amount = Math.floor(amount * 100.0) / 100.0;
130 | save = getIntent().getBooleanExtra(EXTRA_SAVE, false);
131 | if (amount <= 0) {setResult(RESULT_CANCELED); finish();}
132 | activityMainPaymentSum.setText(formatMoney(amount, true) + " " + resources.getString(R.string.card_balance_currency));
133 | activityMainCardRemember.setVisibility(save ? View.VISIBLE : View.GONE);
134 | }
135 |
136 | public static boolean isValid(String code) {
137 | // Valid only for even code length
138 | int sum = 0;
139 |
140 | boolean alternate = false;
141 |
142 | for (int i = code.length() - 1; i >= 0; i--) {
143 | int n = Integer.parseInt(code.substring(i, i + 1));
144 | if (alternate) {
145 | n *= 2;
146 | if (n > 9) {
147 | n = (n % 10) + 1;
148 | }
149 | }
150 | sum += n;
151 | alternate = !alternate;
152 | }
153 | return (sum % 10 == 0);
154 | }
155 |
156 | public String formatMoney(double value, boolean showDecimal) {
157 | if (decimalFormat == null) {
158 | decimalFormat = new DecimalFormat("###,###,###.00");
159 | decimalFormat.setGroupingSize(3);
160 | decimalFormat.setMinimumFractionDigits(0);
161 |
162 | DecimalFormatSymbols s = new DecimalFormatSymbols();
163 | s.setGroupingSeparator(' ');
164 | DecimalFormatSymbols symbols = decimalFormat.getDecimalFormatSymbols();
165 | s.setDecimalSeparator(symbols.getDecimalSeparator());
166 | decimalFormat.setDecimalFormatSymbols(s);
167 | }
168 |
169 | decimalFormat.setMinimumFractionDigits(showDecimal ? 2 : 0);
170 | decimalFormat.setMaximumFractionDigits(showDecimal ? 2 : 0);
171 |
172 | return decimalFormat.format(value);
173 | }
174 |
175 | public static boolean isOnline(String code) {
176 | return code.substring(0, 4).equals("8600");
177 | }
178 |
179 | public void showError(String s) {
180 | if (!TextUtils.isEmpty(s)) {
181 | activityMainErrorLayout.setVisibility(View.VISIBLE);
182 | activityMainErrorMessage.setText(s);
183 | }
184 | }
185 |
186 | @Override
187 | public void onBackPressed() {
188 | super.onBackPressed();
189 | setResult(RESULT_CANCELED);
190 | }
191 | }
--------------------------------------------------------------------------------
/payment/src/main/java/uz/paycom/payment/api/JsonParser.java:
--------------------------------------------------------------------------------
1 | package uz.paycom.payment.api;
2 |
3 | import org.json.JSONObject;
4 | import uz.paycom.payment.model.Confirm;
5 | import uz.paycom.payment.model.Result;
6 | import uz.paycom.payment.utils.Logger;
7 |
8 | /**
9 | * Parse json api objects
10 | */
11 | public class JsonParser {
12 |
13 | private static final String TAG = "JsonParser";
14 |
15 | public JSONObject getCardsCreate(String number, String expire,
16 | Double amount, Boolean save) {
17 | JSONObject root = new JSONObject();
18 | JSONObject params = new JSONObject();
19 | JSONObject card = new JSONObject();
20 | try {
21 | card.accumulate("number", number);
22 | card.accumulate("expire", expire);
23 | params.accumulate("card", card);
24 | params.accumulate("amount", amount);
25 | params.accumulate("save", save);
26 | root.accumulate("params", params);
27 | } catch (Exception e) {
28 | Logger.d(TAG, e.toString());
29 | }
30 |
31 | return root;
32 | }
33 |
34 | public JSONObject getCardsVerifyCode(String token) {
35 | JSONObject root = new JSONObject();
36 | JSONObject params = new JSONObject();
37 |
38 | try {
39 | params.accumulate("token", token);
40 | root.accumulate("params", params);
41 | } catch (Exception e) {
42 | Logger.d(TAG, e.toString());
43 | }
44 |
45 | return root;
46 | }
47 |
48 | public String getCardToken(String result) {
49 | try {
50 | JSONObject jsonObject = new JSONObject(result);
51 | return jsonObject.getJSONObject("result")
52 | .getJSONObject("card")
53 | .getString("token");
54 | } catch (Exception e) {
55 | Logger.d(TAG, e.toString());
56 | return null;
57 | }
58 | }
59 |
60 | public String getCardToken(JSONObject jsonObject) {
61 | try {
62 | return jsonObject.getString("token");
63 | } catch (Exception e) {
64 | Logger.d(TAG, e.toString());
65 | return null;
66 | }
67 | }
68 |
69 | public JSONObject getCardsVerify(String token, String code) {
70 | JSONObject root = new JSONObject();
71 | JSONObject params = new JSONObject();
72 |
73 | try {
74 | params.accumulate("token", token);
75 | params.accumulate("code", code);
76 | root.accumulate("params", params);
77 | } catch (Exception e) {
78 | Logger.d(TAG, e.toString());
79 | }
80 |
81 | return root;
82 | }
83 |
84 | public String checkError(String result) {
85 | try {
86 | JSONObject jsonObject = new JSONObject(result);
87 | return jsonObject.getJSONObject("error")
88 | .getString("message");
89 | } catch (Exception e) {
90 | Logger.d(TAG, e.toString());
91 | return null;
92 | }
93 | }
94 |
95 | public Result getResult(String json) {
96 | try {
97 | JSONObject jsonObject = new JSONObject(json);
98 | JSONObject resultObject = jsonObject.getJSONObject("result");
99 | JSONObject card = resultObject.getJSONObject("card");
100 | return new Result(card.getString("number")
101 | ,card.getString("expire")
102 | ,card.getString("token")
103 | ,card.getBoolean("recurrent")
104 | ,card.getBoolean("verify"));
105 | } catch (Exception e) {
106 | Logger.d(TAG, e.toString());
107 | return null;
108 | }
109 | }
110 |
111 | public Confirm getConfirm(String json) {
112 | try {
113 | JSONObject jsonObject = new JSONObject(json);
114 | JSONObject result = jsonObject.getJSONObject("result");
115 | return new Confirm(result.getBoolean("sent")
116 | ,result.getString("phone")
117 | ,result.getInt("wait"));
118 | } catch (Exception e) {
119 | Logger.d(TAG, e.toString());
120 | return null;
121 | }
122 | }
123 | }
--------------------------------------------------------------------------------
/payment/src/main/java/uz/paycom/payment/api/JsonRpcRequest.java:
--------------------------------------------------------------------------------
1 | package uz.paycom.payment.api;
2 |
3 | import java.security.KeyManagementException;
4 | import java.security.NoSuchAlgorithmException;
5 | import javax.net.ssl.HttpsURLConnection;
6 | import org.json.JSONException;
7 | import org.json.JSONObject;
8 |
9 | import java.io.BufferedReader;
10 | import java.io.IOException;
11 | import java.io.InputStreamReader;
12 | import java.io.OutputStreamWriter;
13 | import java.net.HttpURLConnection;
14 | import java.net.URL;
15 |
16 | import uz.paycom.payment.utils.Logger;
17 | import uz.paycom.payment.utils.PaycomSandBox;
18 |
19 | public class JsonRpcRequest {
20 |
21 | private static final String TAG = "JsonRpcRequest";
22 |
23 | public final static String cardsCreateMethod = "cards.create";
24 | public final static String cardsGetVerifyCodeMethod = "cards.get_verify_code";
25 | public final static String cardsCreateVerifyMethod = "cards.verify";
26 |
27 | private final String xAuth;
28 | private HttpsURLConnection urlConnection;
29 |
30 | public JsonRpcRequest(String xAuth) {
31 | this.xAuth = xAuth;
32 | }
33 |
34 | private String callApi(JSONObject jsonObject) {
35 | try {
36 | String urlApi = PaycomSandBox.isSandBox() ? "https://checkout.test.paycom.uz/api"
37 | : "https://checkout.paycom.uz/api";
38 | Logger.d(TAG, urlApi);
39 | URL url = new URL(urlApi);
40 | urlConnection = (HttpsURLConnection) url.openConnection();
41 |
42 | try {
43 | urlConnection.setSSLSocketFactory(new TLSSocketFactory());
44 | } catch (KeyManagementException | NoSuchAlgorithmException e) {
45 | Logger.d(TAG, e.toString());
46 | }
47 |
48 | urlConnection.setRequestMethod("POST");
49 | urlConnection.addRequestProperty("X-Auth", xAuth);
50 | urlConnection.setDoInput(true);
51 | urlConnection.setDoOutput(true);
52 | urlConnection.setUseCaches(false);
53 | urlConnection.setConnectTimeout(30000);
54 |
55 | OutputStreamWriter writer = new OutputStreamWriter(urlConnection.getOutputStream());
56 | writer.write(jsonObject.toString());
57 | writer.flush();
58 |
59 | Logger.d(TAG, jsonObject.toString());
60 | int responseCode = urlConnection.getResponseCode();
61 |
62 | String line = "";
63 | if (responseCode == HttpURLConnection.HTTP_OK) {
64 | StringBuffer response = new StringBuffer();
65 | BufferedReader br=new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
66 | while ((line = br.readLine()) != null) {
67 | response.append(line);
68 | Logger.d(TAG, line);
69 | }
70 | br.close();
71 | return response.toString();
72 | } else {
73 | throw new IOException("Unexpected responseCode: " + responseCode);
74 | }
75 |
76 | } catch (IOException e) {
77 | Logger.d(TAG, e.toString());
78 | return null;
79 | } finally {
80 | if (urlConnection != null) {
81 | urlConnection.disconnect();
82 | }
83 | }
84 | }
85 |
86 | public String callApiMethod(JSONObject jsonObject, String method) {
87 | try {
88 | Logger.d(TAG, method);
89 | jsonObject.accumulate("method", method);
90 | } catch (JSONException e) {
91 | Logger.d(TAG, e.toString());
92 | }
93 | return callApi(jsonObject);
94 | }
95 | }
--------------------------------------------------------------------------------
/payment/src/main/java/uz/paycom/payment/api/TLSSocketFactory.java:
--------------------------------------------------------------------------------
1 | package uz.paycom.payment.api;
2 |
3 | import java.io.IOException;
4 | import java.net.InetAddress;
5 | import java.net.Socket;
6 | import java.net.UnknownHostException;
7 | import java.security.KeyManagementException;
8 | import java.security.NoSuchAlgorithmException;
9 |
10 | import javax.net.ssl.SSLContext;
11 | import javax.net.ssl.SSLSocket;
12 | import javax.net.ssl.SSLSocketFactory;
13 |
14 | public class TLSSocketFactory extends SSLSocketFactory {
15 |
16 | private SSLSocketFactory internalSSLSocketFactory;
17 |
18 | public TLSSocketFactory() throws KeyManagementException, NoSuchAlgorithmException {
19 | SSLContext context = SSLContext.getInstance("TLS");
20 | context.init(null, null, null);
21 | internalSSLSocketFactory = context.getSocketFactory();
22 | }
23 |
24 | @Override
25 | public String[] getDefaultCipherSuites() {
26 | return internalSSLSocketFactory.getDefaultCipherSuites();
27 | }
28 |
29 | @Override
30 | public String[] getSupportedCipherSuites() {
31 | return internalSSLSocketFactory.getSupportedCipherSuites();
32 | }
33 |
34 | @Override
35 | public Socket createSocket() throws IOException {
36 | return enableTLSOnSocket(internalSSLSocketFactory.createSocket());
37 | }
38 |
39 | @Override
40 | public Socket createSocket(Socket s, String host, int port, boolean autoClose) throws IOException {
41 | return enableTLSOnSocket(internalSSLSocketFactory.createSocket(s, host, port, autoClose));
42 | }
43 |
44 | @Override
45 | public Socket createSocket(String host, int port) throws IOException, UnknownHostException {
46 | return enableTLSOnSocket(internalSSLSocketFactory.createSocket(host, port));
47 | }
48 |
49 | @Override
50 | public Socket createSocket(String host, int port, InetAddress localHost, int localPort) throws IOException, UnknownHostException {
51 | return enableTLSOnSocket(internalSSLSocketFactory.createSocket(host, port, localHost, localPort));
52 | }
53 |
54 | @Override
55 | public Socket createSocket(InetAddress host, int port) throws IOException {
56 | return enableTLSOnSocket(internalSSLSocketFactory.createSocket(host, port));
57 | }
58 |
59 | @Override
60 | public Socket createSocket(InetAddress address, int port, InetAddress localAddress, int localPort) throws IOException {
61 | return enableTLSOnSocket(internalSSLSocketFactory.createSocket(address, port, localAddress, localPort));
62 | }
63 |
64 | private static Socket enableTLSOnSocket(Socket socket) {
65 | if(socket != null && (socket instanceof SSLSocket)) {
66 | ((SSLSocket)socket).setEnabledProtocols(new String[] {"TLSv1.1", "TLSv1.2"});
67 | }
68 | return socket;
69 | }
70 | }
--------------------------------------------------------------------------------
/payment/src/main/java/uz/paycom/payment/api/task/VerifyCardTask.java:
--------------------------------------------------------------------------------
1 | package uz.paycom.payment.api.task;
2 |
3 | import android.content.Intent;
4 | import android.os.AsyncTask;
5 | import android.view.View;
6 |
7 | import org.json.JSONObject;
8 |
9 | import java.lang.ref.WeakReference;
10 |
11 | import uz.paycom.payment.ConfirmActivity;
12 | import uz.paycom.payment.PaymentActivity;
13 | import uz.paycom.payment.R;
14 | import uz.paycom.payment.api.JsonParser;
15 | import uz.paycom.payment.api.JsonRpcRequest;
16 |
17 | /**
18 | * VerifyCardTask - call several cards methods api
19 | * and update activity
20 | */
21 | public class VerifyCardTask extends AsyncTask {
22 |
23 | private Double amount;
24 | private boolean hasError, save;
25 | private JsonParser jsonParser;
26 | private String id, number, expire, token;
27 | private WeakReference weakActivity;
28 |
29 | public VerifyCardTask(PaymentActivity activity) {
30 | jsonParser = new JsonParser();
31 | weakActivity = new WeakReference<>(activity);
32 | }
33 |
34 | @Override protected void onPreExecute() {
35 | PaymentActivity activity = weakActivity.get();
36 | if (activity != null) {
37 | id = activity.id;
38 | amount = activity.amount * 100; //Amount in teens
39 | number = activity.activityMainCardNumber.getText().toString().replace(" ", "");
40 | expire = activity.activityMainDateExpire.getText().toString().replace("/", "");
41 | save = activity.activityMainCardRemember.isChecked();
42 | }
43 | }
44 |
45 | @Override protected String doInBackground(Void... params) {
46 | JsonRpcRequest jsonRpcRequest = new JsonRpcRequest(id);
47 |
48 | JSONObject jsonObject = jsonParser.getCardsCreate(number, expire, amount, save);
49 | String result = jsonRpcRequest.callApiMethod(jsonObject, JsonRpcRequest.cardsCreateMethod);
50 |
51 | if (result == null) return null;
52 | if (jsonParser.checkError(result) != null) {
53 | hasError = true;
54 | return jsonParser.checkError(result);
55 | }
56 |
57 | token = jsonParser.getCardToken(result);
58 | jsonObject = jsonParser.getCardsVerifyCode(token);
59 | result = jsonRpcRequest.callApiMethod(jsonObject, JsonRpcRequest.cardsGetVerifyCodeMethod);
60 |
61 | return result;
62 | }
63 |
64 | @Override protected void onPostExecute(String s) {
65 | PaymentActivity activity = weakActivity.get();
66 | if (activity == null) return;
67 | if (s == null) {
68 | activity.showError(activity.getString(R.string.tryAgainMessage));
69 | } else if (hasError) {
70 | activity.showError(s);
71 | } else {
72 | Intent intent = new Intent(activity, ConfirmActivity.class);
73 | intent.putExtra(ConfirmActivity.ARG_CONFIRM, jsonParser.getConfirm(s));
74 | intent.putExtra(ConfirmActivity.ARG_TOKEN, token);
75 | intent.putExtra(PaymentActivity.EXTRA_LANG, activity.lang);
76 | intent.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
77 | activity.startActivity(intent);
78 | activity.finish();
79 | }
80 | activity.activityMainContinue.setEnabled(true);
81 | activity.activityMainProgress.setVisibility(View.GONE);
82 | }
83 | }
--------------------------------------------------------------------------------
/payment/src/main/java/uz/paycom/payment/model/Confirm.java:
--------------------------------------------------------------------------------
1 | package uz.paycom.payment.model;
2 |
3 | import android.os.Parcel;
4 | import android.os.Parcelable;
5 |
6 | /**
7 | * Api cards.get_verify_code object
8 | */
9 | public class Confirm implements Parcelable {
10 |
11 | private boolean sent;
12 | private String phone;
13 |
14 | public Confirm(boolean sent, String phone, int wait) {
15 | this.sent = sent;
16 | this.phone = phone;
17 | this.wait = wait;
18 | }
19 |
20 | private int wait;
21 |
22 | public boolean isSent() {
23 | return sent;
24 | }
25 |
26 | public String getPhone() {
27 | return phone;
28 | }
29 |
30 | public int getWait() {
31 | return wait;
32 | }
33 |
34 | @Override
35 | public int describeContents() {
36 | return 0;
37 | }
38 |
39 | @Override
40 | public void writeToParcel(Parcel dest, int flags) {
41 | dest.writeByte(this.sent ? (byte) 1 : (byte) 0);
42 | dest.writeString(this.phone);
43 | dest.writeInt(this.wait);
44 | }
45 |
46 | protected Confirm(Parcel in) {
47 | this.sent = in.readByte() != 0;
48 | this.phone = in.readString();
49 | this.wait = in.readInt();
50 | }
51 |
52 | public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {
53 | @Override
54 | public Confirm createFromParcel(Parcel source) {
55 | return new Confirm(source);
56 | }
57 |
58 | @Override
59 | public Confirm[] newArray(int size) {
60 | return new Confirm[size];
61 | }
62 | };
63 | }
--------------------------------------------------------------------------------
/payment/src/main/java/uz/paycom/payment/model/Result.java:
--------------------------------------------------------------------------------
1 | package uz.paycom.payment.model;
2 |
3 | import android.os.Parcel;
4 | import android.os.Parcelable;
5 |
6 | /**
7 | * Here is our result for calling outer activity
8 | */
9 | public class Result implements Parcelable {
10 |
11 | private String number;
12 | private String expire;
13 | private String token;
14 | private boolean recurent;
15 | private boolean verify;
16 |
17 | public Result(String number, String expire, String token, boolean recurent, boolean verify) {
18 | this.number = number;
19 | this.expire = expire;
20 | this.token = token;
21 | this.recurent = recurent;
22 | this.verify = verify;
23 | }
24 |
25 | public String getExpire() {
26 | return expire;
27 | }
28 |
29 | public String getToken() {
30 | return token;
31 | }
32 |
33 | public String getNumber() {
34 | return number;
35 | }
36 |
37 | public boolean isRecurent() {
38 | return recurent;
39 | }
40 |
41 | public boolean isVerify() {
42 | return verify;
43 | }
44 |
45 | @Override
46 | public String toString() {
47 | return "Result{" +
48 | "number='" + number + '\'' +
49 | ", expire='" + expire + '\'' +
50 | ", token='" + token + '\'' +
51 | ", recurent=" + recurent +
52 | ", verify=" + verify +
53 | '}';
54 | }
55 |
56 | @Override
57 | public int describeContents() {
58 | return 0;
59 | }
60 |
61 | @Override
62 | public void writeToParcel(Parcel dest, int flags) {
63 | dest.writeString(this.number);
64 | dest.writeString(this.expire);
65 | dest.writeString(this.token);
66 | dest.writeByte(this.recurent ? (byte) 1 : (byte) 0);
67 | dest.writeByte(this.verify ? (byte) 1 : (byte) 0);
68 | }
69 |
70 | protected Result(Parcel in) {
71 | this.number = in.readString();
72 | this.expire = in.readString();
73 | this.token = in.readString();
74 | this.recurent = in.readByte() != 0;
75 | this.verify = in.readByte() != 0;
76 | }
77 |
78 | public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {
79 | @Override
80 | public Result createFromParcel(Parcel source) {
81 | return new Result(source);
82 | }
83 |
84 | @Override
85 | public Result[] newArray(int size) {
86 | return new Result[size];
87 | }
88 | };
89 | }
--------------------------------------------------------------------------------
/payment/src/main/java/uz/paycom/payment/utils/CardNumberFormat.java:
--------------------------------------------------------------------------------
1 | package uz.paycom.payment.utils;
2 |
3 | import android.text.Editable;
4 | import android.text.TextWatcher;
5 | import android.view.View;
6 | import android.widget.EditText;
7 |
8 | public class CardNumberFormat extends ViewDisable implements TextWatcher {
9 |
10 | private boolean lock;
11 | private EditText editText;
12 |
13 | public CardNumberFormat(View view, EditText editText) {
14 | super(view);
15 | this.editText = editText;
16 | }
17 |
18 | @Override
19 | public void beforeTextChanged(CharSequence s, int start, int count, int after) {
20 | }
21 |
22 | @Override
23 | public void onTextChanged(CharSequence s, int start, int before, int count) {
24 | }
25 |
26 | @Override
27 | public void afterTextChanged(Editable s) {
28 | int dateExpireLength = editText.getText().toString().length();
29 | if (s.length() > 18 && dateExpireLength> 4) { enableView(); } else { disableView(); }
30 | if (lock || s.length() > 16) {
31 | return;
32 | }
33 | lock = true;
34 | for (int i = 4; i < s.length(); i += 5) {
35 | if (s.toString().charAt(i) != ' ') {
36 | s.insert(i, " ");
37 | }
38 | }
39 | lock = false;
40 | }
41 | }
--------------------------------------------------------------------------------
/payment/src/main/java/uz/paycom/payment/utils/DateExpireFormat.java:
--------------------------------------------------------------------------------
1 | package uz.paycom.payment.utils;
2 |
3 | import android.text.Editable;
4 | import android.text.TextWatcher;
5 | import android.view.View;
6 | import android.widget.EditText;
7 |
8 | public class DateExpireFormat extends ViewDisable implements TextWatcher {
9 |
10 | private boolean lock;
11 | private EditText editText;
12 |
13 | public DateExpireFormat(View view, EditText editText) {
14 | super(view);
15 | this.editText = editText;
16 | }
17 |
18 | @Override
19 | public void beforeTextChanged(CharSequence s, int start, int count, int after) {
20 | }
21 |
22 | @Override
23 | public void onTextChanged(CharSequence s, int start, int before, int count) {
24 | }
25 |
26 | @Override
27 | public void afterTextChanged(Editable s) {
28 | int cardNumberLength = editText.getText().toString().length();
29 | if (s.length() > 4 && cardNumberLength > 18) { enableView(); } else { disableView(); }
30 | if (lock || s.length() > 4) {
31 | return;
32 | }
33 | lock = true;
34 | for (int i = 2; i < s.length(); i +=2) {
35 | if (s.toString().charAt(i) != '/') {
36 | s.insert(i, "/");
37 | }
38 | }
39 | lock = false;
40 | }
41 | }
--------------------------------------------------------------------------------
/payment/src/main/java/uz/paycom/payment/utils/LocaleHelper.java:
--------------------------------------------------------------------------------
1 | package uz.paycom.payment.utils;
2 |
3 | import android.annotation.TargetApi;
4 | import android.content.Context;
5 | import android.content.SharedPreferences;
6 | import android.content.res.Configuration;
7 | import android.content.res.Resources;
8 | import android.os.Build;
9 |
10 | import java.util.Locale;
11 |
12 | public class LocaleHelper {
13 |
14 | public static Context onAttach(Context context, String language) {
15 | return setLocale(context, getLanguage(language));
16 | }
17 |
18 | private static String getLanguage(String language) {
19 | if (language == null) return Locale.getDefault().getLanguage();
20 | if (language.toLowerCase().trim().equals("uz")) return language;
21 | return Locale.getDefault().getLanguage();
22 | }
23 |
24 | private static Context setLocale(Context context, String language) {
25 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
26 | return updateResources(context, language);
27 | }
28 |
29 | return updateResourcesLegacy(context, language);
30 | }
31 |
32 | @TargetApi(Build.VERSION_CODES.N)
33 | private static Context updateResources(Context context, String language) {
34 | Locale locale = new Locale(language);
35 | Locale.setDefault(locale);
36 |
37 | Configuration configuration = context.getResources().getConfiguration();
38 | configuration.setLocale(locale);
39 |
40 | return context.createConfigurationContext(configuration);
41 | }
42 |
43 | @SuppressWarnings("deprecation")
44 | private static Context updateResourcesLegacy(Context context, String language) {
45 | Locale locale = new Locale(language);
46 | Locale.setDefault(locale);
47 |
48 | Resources resources = context.getResources();
49 |
50 | Configuration configuration = resources.getConfiguration();
51 | configuration.locale = locale;
52 |
53 | resources.updateConfiguration(configuration, resources.getDisplayMetrics());
54 |
55 | return context;
56 | }
57 | }
--------------------------------------------------------------------------------
/payment/src/main/java/uz/paycom/payment/utils/Logger.java:
--------------------------------------------------------------------------------
1 | package uz.paycom.payment.utils;
2 |
3 | import android.util.Log;
4 | import uz.paycom.payment.BuildConfig;
5 |
6 | public class Logger {
7 | public static void d(String tag, String log) {
8 | if (BuildConfig.DEBUG) {
9 | Log.d(tag, log);
10 | }
11 | }
12 | }
--------------------------------------------------------------------------------
/payment/src/main/java/uz/paycom/payment/utils/PaycomSandBox.java:
--------------------------------------------------------------------------------
1 | package uz.paycom.payment.utils;
2 |
3 | public class PaycomSandBox {
4 |
5 | private static boolean isSandBox;
6 |
7 | public static void setEnabled(boolean enabled) {
8 | isSandBox = enabled;
9 | };
10 |
11 | public static boolean isSandBox() {
12 | return isSandBox;
13 | }
14 | }
--------------------------------------------------------------------------------
/payment/src/main/java/uz/paycom/payment/utils/ViewDisable.java:
--------------------------------------------------------------------------------
1 | package uz.paycom.payment.utils;
2 |
3 | import android.view.View;
4 |
5 | class ViewDisable {
6 |
7 | private View view;
8 |
9 | ViewDisable(View view) {
10 | this.view = view;
11 | }
12 |
13 | void enableView() {
14 | view.setEnabled(true);
15 | view.setAlpha(1f);
16 | view.setClickable(true);
17 | };
18 |
19 | void disableView() {
20 | view.setEnabled(false);
21 | view.setAlpha(.3f);
22 | view.setClickable(false);
23 | }
24 | }
--------------------------------------------------------------------------------
/payment/src/main/res/drawable/ic_repeat.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/payment/src/main/res/drawable/ic_warning.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/payment/src/main/res/layout/paycom_payment_confirm.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
17 |
27 |
38 |
48 |
62 |
63 |
64 |
71 |
72 |
83 |
92 |
99 |
107 |
115 |
124 |
133 |
140 |
141 |
142 |
143 |
--------------------------------------------------------------------------------
/payment/src/main/res/layout/paycom_payment_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
14 |
15 |
22 |
32 |
43 |
53 |
67 |
68 |
69 |
70 |
76 |
77 |
86 |
87 |
96 |
97 |
106 |
107 |
117 |
118 |
127 |
128 |
137 |
138 |
147 |
148 |
155 |
156 |
162 |
163 |
171 |
172 |
173 |
174 |
--------------------------------------------------------------------------------
/payment/src/main/res/values-uz/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Paycom
3 | To`lov so`mmasi
4 | Kartaning raqami
5 | Faqat Uzcard Online kartalari
6 | Kartaning amal qilish muddati
7 | Kartani saqlab qo`yin
8 | Oldinga
9 | Tasdiqlash
10 | TASDIQLASH KODI QUYIDAGI RAQAMGA JUNATILDI
11 | Tekshiruv kodi
12 | Xato
13 | Yopish
14 | Xatolik yuz berdi, qaytadan urinib ko`ring
15 | xxxx xxxx xxxx xxxx
16 | mm/yy
17 | Paycom To`lov
18 | Karta raqami noto`g`ri`kiritildi
19 | so`m
20 |
21 |
--------------------------------------------------------------------------------
/payment/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #4591d1
4 | #4591d1
5 | @android:color/holo_blue_light
6 |
7 | #ffc4c4c4
8 |
9 |
--------------------------------------------------------------------------------
/payment/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
7 | 4dp
8 | 8dp
9 | 12dp
10 | 16dp
11 | 20dp
12 | 24dp
13 | 48dp
14 |
15 |
16 | 8sp
17 | 10sp
18 | 12sp
19 | 14sp
20 | 18sp
21 | 22sp
22 | 24sp
23 | 32sp
24 | 80dp
25 |
26 |
27 |
--------------------------------------------------------------------------------
/payment/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Paycom
3 | Сумма к оплате
4 | Номер карты
5 | Только карты Uzcard Online
6 | Срок истечения
7 | Запомнить карту
8 | Продолжить
9 | Подтвердить
10 | КОД ПОДТВЕРЖДЕНИЯ ВЫСЛАН НА НОМЕР
11 | КОД ПОДТВЕРЖДЕНИЯ
12 | Ошибка
13 | Закрыть
14 | Произошла ошибка, попробуйте еще раз
15 | xxxx xxxx xxxx xxxx
16 | мм/гг
17 | Paycom Оплата
18 | Неправильный номер карты
19 | сум
20 |
21 |
--------------------------------------------------------------------------------
/payment/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
12 |
13 |
19 |
20 |
26 |
27 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':payment'
2 |
--------------------------------------------------------------------------------