Back to project page Java-Yandex.Money-API-SDK.
The source code is released under:
MIT License
If you think the Android project Java-Yandex.Money-API-SDK listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package ru.yandex.money.droid; // w ww . j a v a 2 s.c om import android.app.Activity; import android.content.Context; import android.content.Intent; import ru.yandex.money.api.YandexMoneyImpl; import ru.yandex.money.api.rights.Permission; import java.math.BigDecimal; import java.util.Collection; import java.util.Map; /** * ???????????????? ??????? ?????????? Intent'?? Activity ??????????. * ?????? ???? ?????????? ???????? ??????????. * * @author dvmelnikov */ public class IntentCreator { /** * ???????? Intent'? ??????????? * * @param activity Activity, ?? ???????? ????? ??????????? Intent * @param clientId ????????????? ??????????? ? ????????? API ???????.?????? * @param redirectUri URI ????????? ???????????, ?? ??????? OAuth-??????? * ??????????????? ???????? ????????? ?????????? ???????????. ???????? ?????? ????????? * ??? ????????????? ?????????? ?????? ???? ????????? ???????? redirectUri, * ?????????? ??? ???????????? ???????????. ??? ?????????? ?? ????????????? ?????????????? * ????????? ???????????, ??????? ????? ???? ????????? ? ????? ??????? URI. * @param permissions ???????? ????????????? ??????????? ???? * @param showResultDialog ?????????? ?? ? Activities ?????????? ????????? ??????????? ???????? (??????/??????), * ??? ?????????? ????? ????? ?????????? ????????? ????????. * @return Intent ?? ??????????????? ??????????? */ public static Intent createAuth(final Activity activity, final String clientId, final String redirectUri, final Collection<Permission> permissions, final String clientSecret, boolean showResultDialog) { checkMainParams(clientId, "token", activity); Intent intent = new Intent(activity, AuthActivity.class); intent.putExtra(AuthActivity.AUTH_IN_CLIENT_ID, clientId); intent.putExtra(AuthActivity.AUTH_IN_REDIRECT_URI, redirectUri); intent.putExtra(AuthActivity.AUTH_IN_SHOW_RES_DLG, showResultDialog); intent.putExtra(AuthActivity.AUTH_IN_SECRET, clientSecret); YandexMoneyImpl yandexMoney = new YandexMoneyImpl(clientId); String authUri = yandexMoney.authorizeUri(permissions, redirectUri, true); intent.putExtra(AuthActivity.AUTH_IN_AUTH_URI, authUri); return intent; } /** * ???????? Intent'? ???????? ???????? * * @param activity ????????? ??????????? ??? ????????????? Activity * @param clientId ????????????? ??????????? ? ????????? API ???????.?????? * @param accessToken ????? ??????????? ????????????? * @return Intent ?? ??????????????? ??????????? */ public static Intent createHistory(final Activity activity, String clientId, String accessToken) { checkMainParams(clientId, accessToken, activity); Intent intent = new Intent(activity, HistoryActivity.class); intent.putExtra(HistoryActivity.HISTORY_IN_CLIENT_ID, clientId); intent.putExtra(HistoryActivity.HISTORY_IN_ACCESS_TOKEN, accessToken); return intent; } public static Intent createHistoryDetail(final Activity activity, final String clientId, final String accessToken, String operationId) { Intent intent = new Intent(activity, DetailHistoryActivity.class); intent.putExtra(DetailHistoryActivity.DET_HIST_IN_OPERATION_ID, operationId); intent.putExtra(DetailHistoryActivity.DET_HIST_IN_ACCESS_TOKEN, accessToken); intent.putExtra(DetailHistoryActivity.DET_HIST_IN_CLIENT_ID, clientId); return intent; } /** * ???????? Intent'? ???????? ?? ????? ??????? ????????????? * * @param activity Activity, ?? ???????? ????? ??????????? Intent * @param clientId ????????????? ??????????? ? ????????? API ???????.?????? * @param accessToken ????? ??????????? ????????????? * @param accountTo ????? ?????? ??????????? ??????? (????? ???????.?????) * @param amount ?????? ????????. ?????????????? ?????? ?????? ?? ?????????????? ??????, * ??? ????? ?????? ?????. * @param comment ???????? ???????, ?????????????? ?????? ? ???????? ???????? * ????????????. * @param message ?????????? ?????????? ???????. * @param showResultDialog ?????????? ?? ? Activities ?????????? ????????? ??????????? ???????? (??????/??????), * ??? ?????????? ????? ????? ?????????? ????????? ????????. * @return Intent ?? ??????????????? ??????????? */ public static Intent createPaymentP2P(final Activity activity, String clientId, String accessToken, String accountTo, BigDecimal amount, String comment, String message, boolean showResultDialog) { checkMainParams(clientId, accessToken, activity); Intent intent = new Intent(activity, PaymentActivity.class); intent.putExtra(PaymentActivity.PAYMENT_IN_CLIENT_ID, clientId); intent.putExtra(PaymentActivity.PAYMENT_IN_ACCESS_TOKEN, accessToken); intent.putExtra(PaymentActivity.PAYMENT_IN_P2P_FLAG, true); intent.putExtra(PaymentActivity.PAYMENT_IN_SHOW_RESULT_DIALOG, showResultDialog); intent.putExtra(PaymentActivity.PAYMENT_P2P_IN_ACCOUNT, accountTo); intent.putExtra(PaymentActivity.PAYMENT_P2P_IN_AMOUNT, amount.doubleValue()); intent.putExtra(PaymentActivity.PAYMENT_P2P_IN_COMMENT, comment); intent.putExtra(PaymentActivity.PAYMENT_P2P_IN_MESSAGE, message); return intent; } /** * ???????? Intent'? ?????? ? ??????? * * @param activity Activity, ?? ???????? ????? ??????????? Intent * @param clientId ????????????? ??????????? ? ????????? API ???????.?????? * @param accessToken ????? ??????????? ????????????? * @param amount ?????? ?????? ?????? * @param patternId ????????????? ??????? ??????? * @param params ????????????????? ????????? ??????? ???????, ????????? * ?????????. * @param showResultDialog ?????????? ?? ? Activities ?????????? ????????? ??????????? ???????? (??????/??????), * ??? ?????????? ????? ????? ?????????? ????????? ????????. * @return Intent ?? ??????????????? ??????????? */ public static Intent createPaymentShop(final Activity activity, String clientId, String accessToken, BigDecimal amount, String patternId, Map<String, String> params, boolean showResultDialog) { checkMainParams(clientId, accessToken, activity); Intent intent = new Intent(activity, PaymentActivity.class); intent.putExtra(PaymentActivity.PAYMENT_IN_CLIENT_ID, clientId); intent.putExtra(PaymentActivity.PAYMENT_IN_ACCESS_TOKEN, accessToken); intent.putExtra(PaymentActivity.PAYMENT_IN_P2P_FLAG, false); intent.putExtra(PaymentActivity.PAYMENT_IN_SHOW_RESULT_DIALOG, showResultDialog); PaymentShopParcelable paramsParc = new PaymentShopParcelable(amount, patternId, params); intent.putExtra(PaymentActivity.PAYMENT_SHOP_IN_PARAMS, paramsParc); return intent; } private static void checkMainParams(String clientId, String accessToken, Context context) { if ((clientId == null) || (clientId.equals(""))) throw new IllegalArgumentException("client_id is empty"); if ((accessToken == null) || (accessToken.equals(""))) throw new IllegalArgumentException("access_token is empty"); if (context == null) throw new IllegalArgumentException("context is empty"); } }