use of com.braintreepayments.api.exceptions.BraintreeException in project braintree_android by braintree.
the class PayPal method requestBillingAgreement.
/**
* Starts the Billing Agreement flow for PayPal with custom PayPal approval handler.
*
* @param fragment A {@link BraintreeFragment} used to process the request.
* @param request A {@link PayPalRequest} used to customize the request.
* @param handler A {@link PayPalApprovalHandler} for custom approval handling.
*/
public static void requestBillingAgreement(BraintreeFragment fragment, PayPalRequest request, PayPalApprovalHandler handler) {
if (request.getAmount() == null) {
fragment.sendAnalyticsEvent("paypal.billing-agreement.selected");
if (request.shouldOfferCredit()) {
fragment.sendAnalyticsEvent("paypal.billing-agreement.credit.offered");
}
requestOneTimePayment(fragment, request, true, handler);
} else {
fragment.postCallback(new BraintreeException("There must be no amount specified for the Billing Agreement flow"));
}
}
use of com.braintreepayments.api.exceptions.BraintreeException in project braintree_android by braintree.
the class CardBuilder method buildGraphQL.
protected void buildGraphQL(Context context, JSONObject base, JSONObject input) throws BraintreeException, JSONException {
try {
base.put(GraphQLQueryHelper.QUERY_KEY, GraphQLQueryHelper.getQuery(context, R.raw.tokenize_credit_card_mutation));
} catch (Resources.NotFoundException | IOException e) {
throw new BraintreeException("Unable to read GraphQL query", e);
}
base.put(OPERATION_NAME_KEY, "TokenizeCreditCard");
JSONObject creditCard = new JSONObject().put(NUMBER_KEY, mCardnumber).put(EXPIRATION_MONTH_KEY, mExpirationMonth).put(EXPIRATION_YEAR_KEY, mExpirationYear).put(CVV_KEY, mCvv).put(CARDHOLDER_NAME_KEY, mCardholderName);
JSONObject billingAddress = new JSONObject().put(FIRST_NAME_KEY, mFirstName).put(LAST_NAME_KEY, mLastName).put(COMPANY_KEY, mCompany).put(COUNTRY_CODE_KEY, mCountryCode).put(COUNTRY_NAME_KEY, mCountryName).put(COUNTRY_CODE_ALPHA2_KEY, mCountryCodeAlpha2).put(COUNTRY_CODE_ALPHA3_KEY, mCountryCodeAlpha3).put(COUNTRY_CODE_NUMERIC_KEY, mCountryCodeNumeric).put(LOCALITY_KEY, mLocality).put(POSTAL_CODE_KEY, mPostalCode).put(REGION_KEY, mRegion).put(STREET_ADDRESS_KEY, mStreetAddress).put(EXTENDED_ADDRESS_KEY, mExtendedAddress);
if (billingAddress.length() > 0) {
creditCard.put(BILLING_ADDRESS_KEY, billingAddress);
}
input.put(CREDIT_CARD_KEY, creditCard);
}
Aggregations