本文整理汇总了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();
}
}
}
}
示例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));
}
});
}
示例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");
}
}
示例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());
}
示例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);
}
}
示例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));
}
});
}
示例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();
}
示例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);
}
}
});
}
}
示例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);
}
示例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();
}
示例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();
}
示例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);
}
}
示例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());
}
}