当前位置: 首页>>代码示例>>Java>>正文


Java Payment类代码示例

本文整理汇总了Java中com.mercadopago.model.Payment的典型用法代码示例。如果您正苦于以下问题:Java Payment类的具体用法?Java Payment怎么用?Java Payment使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Payment类属于com.mercadopago.model包,在下文中一共展示了Payment类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onActivityResult

import com.mercadopago.model.Payment; //导入依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    LayoutUtil.showRegularLayout(this);

    if (requestCode == MercadoPagoCheckout.CHECKOUT_REQUEST_CODE) {
        if (resultCode == MercadoPagoCheckout.PAYMENT_RESULT_CODE) {
            Payment payment = JsonUtil.getInstance().fromJson(data.getStringExtra("payment"), Payment.class);
            Toast.makeText(mActivity, "Pago con status: " + payment.getStatus(), Toast.LENGTH_SHORT).show();
        } else if (resultCode == RESULT_CANCELED) {
            if (data != null && data.getStringExtra("mercadoPagoError") != null) {
                MercadoPagoError mercadoPagoError = JsonUtil.getInstance().fromJson(data.getStringExtra("mercadoPagoError"), MercadoPagoError.class);
                Toast.makeText(mActivity, "Error: " + mercadoPagoError.getMessage(), Toast.LENGTH_SHORT).show();
            } else {
                Toast.makeText(mActivity, "Cancel", Toast.LENGTH_SHORT).show();
            }
        }
    }
}
 
开发者ID:mercadopago,项目名称:px-android,代码行数:19,代码来源:CheckoutExampleActivity.java

示例2: createPaymentInMerchantServer

import com.mercadopago.model.Payment; //导入依赖的package包/类
private void createPaymentInMerchantServer(String transactionId, PaymentData paymentData, final OnResourcesRetrievedCallback<Payment> onResourcesRetrievedCallback) {
    Map<String, Object> paymentInfoMap = new HashMap<>();
    paymentInfoMap.putAll(servicePreference.getCreatePaymentAdditionalInfo());

    MerchantPayment merchantPayment = new MerchantPayment(paymentData);
    String payLoadJson = JsonUtil.getInstance().toJson(merchantPayment);

    Type type = new TypeToken<Map<String, Object>>() {
    }.getType();
    Map<String, Object> paymentDataMap = new Gson().fromJson(payLoadJson, type);

    paymentInfoMap.putAll(paymentDataMap);

    CustomServer.createPayment(context, transactionId, servicePreference.getCreatePaymentURL(), servicePreference.getCreatePaymentURI(), paymentInfoMap, new HashMap<String, String>(), new Callback<Payment>() {
        @Override
        public void success(Payment payment) {
            onResourcesRetrievedCallback.onSuccess(payment);
        }

        @Override
        public void failure(ApiException apiException) {
            onResourcesRetrievedCallback.onFailure(new MercadoPagoError(apiException, ApiUtil.RequestOrigin.CREATE_PAYMENT));
        }
    });
}
 
开发者ID:mercadopago,项目名称:px-android,代码行数:26,代码来源:CheckoutProviderImpl.java

示例3: createPayment

import com.mercadopago.model.Payment; //导入依赖的package包/类
public void createPayment(final PaymentBody paymentBody, final Callback<Payment> callback) {
    if (this.mKeyType.equals(KEY_TYPE_PUBLIC)) {
        Retrofit paymentsRetrofitAdapter = new Retrofit.Builder()
                .baseUrl(MP_API_BASE_URL)
                .addConverterFactory(GsonConverterFactory.create(JsonUtil.getInstance().getGson()))
                .client(HttpClientUtil.getClient(this.mContext, 10, 40, 40))
                .addCallAdapterFactory(new ErrorHandlingCallAdapter.ErrorHandlingCallAdapterFactory())
                .build();

        CheckoutService service = paymentsRetrofitAdapter.create(CheckoutService.class);
        service.createPayment(paymentBody.getTransactionId(), paymentBody).enqueue(callback);

    } else {
        throw new RuntimeException("Unsupported key type for this method");
    }
}
 
开发者ID:mercadopago,项目名称:px-android,代码行数:17,代码来源:MercadoPago.java

示例4: setCallbackHolderPaymentCallback

import com.mercadopago.model.Payment; //导入依赖的package包/类
@Test
public void setCallbackHolderPaymentCallback() {
    PaymentCallback paymentCallback = new PaymentCallback() {
        @Override
        public void onSuccess(Payment payment) {

        }

        @Override
        public void onCancel() {

        }

        @Override
        public void onFailure(MercadoPagoError exception) {

        }
    };

    CallbackHolder.getInstance().setPaymentCallback(paymentCallback);

    Assert.assertEquals(paymentCallback, CallbackHolder.getInstance().getPaymentCallback());
}
 
开发者ID:mercadopago,项目名称:px-android,代码行数:24,代码来源:CallbackHolderTest.java

示例5: paymentToMap

import com.mercadopago.model.Payment; //导入依赖的package包/类
private WritableMap paymentToMap(@NonNull Payment payment) {
    final String paymentId = payment.getId().toString();
    final String paymentStatus = payment.getStatus();

    final WritableMap map = Arguments.createMap();

    map.putString(PAYMENT_ID, paymentId);
    map.putString(PAYMENT_STATUS, paymentStatus);

    return map;
}
 
开发者ID:BlackBoxVision,项目名称:react-native-mercadopago-checkout,代码行数:12,代码来源:MercadoPagoCheckoutEventListener.java

示例6: onActivityResult

import com.mercadopago.model.Payment; //导入依赖的package包/类
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (currentPromise == null || requestCode != MercadoPagoCheckout.CHECKOUT_REQUEST_CODE) {
        return;
    }

    if (resultCode == MercadoPagoCheckout.PAYMENT_DATA_RESULT_CODE) {
        final PaymentData paymentData = this.getData(data, MP_PAYMENT_DATA, PaymentData.class);
        final WritableMap paymentDataMap = this.paymentDataToMap(paymentData);

        //Resolve values as map
        currentPromise.resolve(paymentDataMap);
    }
    else if (resultCode == MercadoPagoCheckout.PAYMENT_RESULT_CODE) {
        final Payment payment = this.getData(data, MP_PAYMENT, Payment.class);
        final WritableMap paymentMap = this.paymentToMap(payment);

        //Resolve values as map
        currentPromise.resolve(paymentMap);
    }
    else if (resultCode == RESULT_CANCELED) {
        if (data != null && data.getStringExtra(MP_PAYMENT_ERROR) != null) {
            final MercadoPagoError mercadoPagoError = this.getData(data, MP_PAYMENT_ERROR, MercadoPagoError.class);
            final Throwable wrappedError = new Throwable(mercadoPagoError.getErrorDetail());

            //Reject promise on MPError, and bubble error data to react-native
            currentPromise.reject(PAYMENT_ERROR, "Payment failed.", wrappedError);
        }
        else {
            //Reject promise on user cancellation
            currentPromise.reject(PAYMENT_CANCELLED, "Payment was cancelled by the user.");
        }
    }

    this.clearCurrentPromise();
}
 
开发者ID:BlackBoxVision,项目名称:react-native-mercadopago-checkout,代码行数:37,代码来源:MercadoPagoCheckoutEventListener.java

示例7: createPayment

import com.mercadopago.model.Payment; //导入依赖的package包/类
@Override
public void createPayment(String transactionId, CheckoutPreference checkoutPreference, PaymentData paymentData, Boolean binaryMode, String customerId, OnResourcesRetrievedCallback<Payment> onResourcesRetrievedCallback) {
    if (servicePreference != null && servicePreference.hasCreatePaymentURL()) {
        createPaymentInMerchantServer(transactionId, paymentData, onResourcesRetrievedCallback);
    } else {
        createPaymentInMercadoPago(transactionId, checkoutPreference, paymentData, binaryMode, customerId, onResourcesRetrievedCallback);
    }
}
 
开发者ID:mercadopago,项目名称:px-android,代码行数:9,代码来源:CheckoutProviderImpl.java

示例8: createPaymentInMercadoPago

import com.mercadopago.model.Payment; //导入依赖的package包/类
private void createPaymentInMercadoPago(String transactionId, CheckoutPreference checkoutPreference, PaymentData paymentData, Boolean binaryMode, String customerId, final OnResourcesRetrievedCallback<Payment> onResourcesRetrievedCallback) {
    PaymentBody paymentBody = createPaymentBody(transactionId, checkoutPreference, paymentData, binaryMode, customerId);

    mercadoPagoServicesAdapter.createPayment(paymentBody, new Callback<Payment>() {
        @Override
        public void success(Payment payment) {
            onResourcesRetrievedCallback.onSuccess(payment);
        }

        @Override
        public void failure(ApiException apiException) {
            onResourcesRetrievedCallback.onFailure(new MercadoPagoError(apiException, ApiUtil.RequestOrigin.CREATE_PAYMENT));
        }
    });
}
 
开发者ID:mercadopago,项目名称:px-android,代码行数:16,代码来源:CheckoutProviderImpl.java

示例9: shouldSkipResult

import com.mercadopago.model.Payment; //导入依赖的package包/类
private boolean shouldSkipResult(final String paymentStatus) {
    return !mFlowPreference.isPaymentResultScreenEnabled()
            || (mFlowPreference.getCongratsDisplayTime() != null && mFlowPreference.getCongratsDisplayTime() == 0 && Payment.StatusCodes.STATUS_APPROVED.equals(paymentStatus))
            || Payment.StatusCodes.STATUS_APPROVED.equals(paymentStatus) && !mFlowPreference.isPaymentApprovedScreenEnabled()
            || Payment.StatusCodes.STATUS_REJECTED.equals(paymentStatus) && !mFlowPreference.isPaymentRejectedScreenEnabled()
            || Payment.StatusCodes.STATUS_PENDING.equals(paymentStatus) && !mFlowPreference.isPaymentPendingScreenEnabled();
}
 
开发者ID:mercadopago,项目名称:px-android,代码行数:8,代码来源:CheckoutPresenter.java

示例10: createPayment

import com.mercadopago.model.Payment; //导入依赖的package包/类
private void createPayment() {

        final PaymentData paymentData = createPaymentData();

        if (hasPaymentPlugin()) {
            CheckoutStore.getInstance().setPaymentData(paymentData);
            getView().showPaymentPlugin();
        } else {
            final String transactionId = getTransactionID();
            getResourcesProvider().createPayment(transactionId, mCheckoutPreference,
                    paymentData, mBinaryMode, mCustomerId, new OnResourcesRetrievedCallback<Payment>() {
                @Override
                public void onSuccess(final Payment payment) {
                    mCreatedPayment = payment;
                    PaymentResult paymentResult = createPaymentResult(payment, paymentData);
                    checkStartPaymentResultActivity(paymentResult);
                    cleanTransactionId();
                }
                @Override
                public void onFailure(final MercadoPagoError error) {
                    if (error.isApiException() && error.getApiException().getStatus().equals(ApiUtil.StatusCodes.BAD_REQUEST)) {
                        List<Cause> causes = error.getApiException().getCause();
                        if (causes != null && !causes.isEmpty()) {
                            Cause cause = causes.get(0);
                            if (ApiException.ErrorCodes.INVALID_PAYMENT_WITH_ESC.equals(cause.getCode()) &&
                                    paymentData.getToken().getCardId() != null) {
                                deleteESC(paymentData);
                                continuePaymentWithoutESC();
                            } else {
                                recoverCreatePayment(error);
                            }
                        }
                    } else {
                        recoverCreatePayment(error);
                    }
                }
            });
        }
    }
 
开发者ID:mercadopago,项目名称:px-android,代码行数:40,代码来源:CheckoutPresenter.java

示例11: continuePaymentWithoutESC

import com.mercadopago.model.Payment; //导入依赖的package包/类
private void continuePaymentWithoutESC() {
    mPaymentRecovery = new PaymentRecovery(mCreatedToken, mSelectedPaymentMethod,
            mSelectedPayerCost, mSelectedIssuer, Payment.StatusCodes.STATUS_REJECTED,
            Payment.StatusCodes.STATUS_DETAIL_INVALID_ESC);

    getView().startPaymentRecoveryFlow(mPaymentRecovery);
}
 
开发者ID:mercadopago,项目名称:px-android,代码行数:8,代码来源:CheckoutPresenter.java

示例12: resolveProcessingPaymentStatus

import com.mercadopago.model.Payment; //导入依赖的package包/类
private void resolveProcessingPaymentStatus() {
    mCreatedPayment = new Payment();
    mCreatedPayment.setStatus(Payment.StatusCodes.STATUS_IN_PROCESS);
    mCreatedPayment.setStatusDetail(Payment.StatusCodes.STATUS_DETAIL_PENDING_CONTINGENCY);
    PaymentResult paymentResult = createPaymentResult(mCreatedPayment, createPaymentData());
    getView().showPaymentResult(paymentResult);
    cleanTransactionId();
}
 
开发者ID:mercadopago,项目名称:px-android,代码行数:9,代码来源:CheckoutPresenter.java

示例13: createPaymentResult

import com.mercadopago.model.Payment; //导入依赖的package包/类
private PaymentResult createPaymentResult(final Payment payment, final PaymentData paymentData) {
    return new PaymentResult.Builder()
            .setPaymentData(paymentData)
            .setPaymentId(payment.getId())
            .setPaymentStatus(payment.getStatus())
            .setPaymentStatusDetail(payment.getStatusDetail())
            .setPayerEmail(mCheckoutPreference.getPayer().getEmail())
            .setStatementDescription(payment.getStatementDescriptor())
            .build();
}
 
开发者ID:mercadopago,项目名称:px-android,代码行数:11,代码来源:CheckoutPresenter.java

示例14: onValidStart

import com.mercadopago.model.Payment; //导入依赖的package包/类
private void onValidStart() {
    if (paymentResult.getPaymentStatusDetail() != null && paymentResult.getPaymentStatusDetail().equals(Payment.StatusCodes.STATUS_DETAIL_PENDING_WAITING_PAYMENT)) {
        getView().showInstructions(site, amount, paymentResult);
    } else if (paymentResult.getPaymentStatus().equals(Payment.StatusCodes.STATUS_IN_PROCESS) ||
            paymentResult.getPaymentStatus().equals(Payment.StatusCodes.STATUS_PENDING)) {
        getView().showPending(paymentResult);
    } else if (isCardOrAccountMoney() || isPlugin()) {
        startPaymentsOnResult();
    } else if (paymentResult.getPaymentStatus().equals(Payment.StatusCodes.STATUS_REJECTED)) {
        getView().showRejection(paymentResult);
    }
}
 
开发者ID:mercadopago,项目名称:px-android,代码行数:13,代码来源:PaymentResultPresenter.java

示例15: startPaymentsOnResult

import com.mercadopago.model.Payment; //导入依赖的package包/类
private void startPaymentsOnResult() {
    if (paymentResult.getPaymentStatus().equals(Payment.StatusCodes.STATUS_APPROVED)) {
        getView().showCongrats(site, amount, paymentResult, discountEnabled);
    } else if (paymentResult.getPaymentStatus().equals(Payment.StatusCodes.STATUS_REJECTED)) {
        if (isStatusDetailValid() && paymentResult.getPaymentStatusDetail().equals(Payment.StatusCodes.STATUS_DETAIL_CC_REJECTED_CALL_FOR_AUTHORIZE)) {
            getView().showCallForAuthorize(site, paymentResult);
        } else {
            getView().showRejection(paymentResult);
        }
    } else {
        getView().showError(getResourcesProvider().getStandardErrorMessage());
    }
}
 
开发者ID:mercadopago,项目名称:px-android,代码行数:14,代码来源:PaymentResultPresenter.java


注:本文中的com.mercadopago.model.Payment类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。