PaypalResponse paypalResponse = new PaypalResponse(message); if (paypalResponse.isSuccess()) { Payment payment = new Payment(); payment.userId = user.id; payment.totalAmount = totalAmount; payment.token = paypalResponse.getToken(); payment.correlationID = paypalResponse.getCorrelationID(); payment.save();
/** * Gets currency pair of the base currency and counter currency. * <p> * This currency pair is conventional, thus indifferent to the direction of FX. * * @return the currency pair */ public CurrencyPair getCurrencyPair() { return CurrencyPair.of(baseCurrencyPayment.getCurrency(), counterCurrencyPayment.getCurrency()); }
/** * Returns a copy of this payment with the value negated. * <p> * This takes this payment and negates it. * <p> * This instance is immutable and unaffected by this method. * * @return a payment based on this with the value negated */ public AdjustablePayment negated() { return AdjustablePayment.of(value.negated(), date); }
public void test_minus_MultiCurrencyAmount_empty() { CurrencyAmount ca = CurrencyAmount.of(Currency.AUD, 117); CurrencyAmount cb = CurrencyAmount.of(Currency.USD, 12); MultiCurrencyAmount mc1 = MultiCurrencyAmount.of(ca, cb); MultiCurrencyAmount mc2 = MultiCurrencyAmount.of(); MultiCurrencyAmount test = mc1.minus(mc2); assertMCA(test, ca, cb); }
public void test_plus_MultiCurrencyAmount_empty() { CurrencyAmount ca = CurrencyAmount.of(Currency.AUD, 117); CurrencyAmount cb = CurrencyAmount.of(Currency.USD, 12); MultiCurrencyAmount mc1 = MultiCurrencyAmount.of(ca, cb); MultiCurrencyAmount mc2 = MultiCurrencyAmount.of(); MultiCurrencyAmount test = mc1.plus(mc2); assertMCA(test, ca, cb); }
public void test_mapCurrencyAmounts() { MultiCurrencyAmount base = MultiCurrencyAmount.of(CA1, CA2); MultiCurrencyAmount test = base.mapCurrencyAmounts(a -> CurrencyAmount.of(CCY3, 1)); assertMCA(test, CurrencyAmount.of(CCY3, 2)); }
public void test_multipliedBy() { MultiCurrencyAmount base = MultiCurrencyAmount.of(CA1, CA2); MultiCurrencyAmount test = base.multipliedBy(2.5); assertMCA(test, CA1.multipliedBy(2.5), CA2.multipliedBy(2.5)); }
public void test_mapAmounts() { MultiCurrencyAmount base = MultiCurrencyAmount.of(CA1, CA2); MultiCurrencyAmount test = base.mapAmounts(a -> a * 2.5 + 1); assertMCA(test, CA1.mapAmount(a -> a * 2.5 + 1), CA2.mapAmount(a -> a * 2.5 + 1)); }
/** * Obtains an instance representing an amount to be paid where the date is adjustable. * <p> * The sign of the amount will be normalized to be negative, indicating a payment. * * @param value the amount of the payment * @param date the date that the payment is made * @return the adjustable payment instance */ public static AdjustablePayment ofPay(CurrencyAmount value, AdjustableDate date) { return new AdjustablePayment(value.negative(), date); }
public void test_minus_CurrencyDouble_add() { CurrencyAmount ca = CurrencyAmount.of(Currency.AUD, 117); CurrencyAmount cb = CurrencyAmount.of(Currency.USD, 12); MultiCurrencyAmount mc1 = MultiCurrencyAmount.of(ca, cb); MultiCurrencyAmount test = mc1.minus(Currency.NZD, 3); assertMCA(test, ca, cb, CurrencyAmount.of(Currency.NZD, -3)); }
public void test_plus_CurrencyAmount_add() { CurrencyAmount ca = CurrencyAmount.of(Currency.AUD, 117); CurrencyAmount cb = CurrencyAmount.of(Currency.USD, 12); CurrencyAmount cc = CurrencyAmount.of(Currency.NZD, 3); MultiCurrencyAmount mc1 = MultiCurrencyAmount.of(ca, cb); MultiCurrencyAmount test = mc1.plus(cc); assertMCA(test, ca, cb, cc); }
/** * Gets currency pair of the base currency and counter currency. * <p> * This currency pair is conventional, thus indifferent to the direction of FX. * * @return the currency pair */ @Override public CurrencyPair getCurrencyPair() { return CurrencyPair.of(baseCurrencyPayment.getCurrency(), counterCurrencyPayment.getCurrency()); }
public void test_minus_CurrencyAmount_merge() { CurrencyAmount ca = CurrencyAmount.of(Currency.AUD, 117); CurrencyAmount cb = CurrencyAmount.of(Currency.USD, 12); CurrencyAmount cc = CurrencyAmount.of(Currency.AUD, 3); MultiCurrencyAmount mc1 = MultiCurrencyAmount.of(ca, cb); MultiCurrencyAmount test = mc1.minus(cc); assertMCA(test, cb, CurrencyAmount.of(Currency.AUD, 114)); }
public void test_plus_CurrencyDouble_add() { CurrencyAmount ca = CurrencyAmount.of(Currency.AUD, 117); CurrencyAmount cb = CurrencyAmount.of(Currency.USD, 12); MultiCurrencyAmount mc1 = MultiCurrencyAmount.of(ca, cb); MultiCurrencyAmount test = mc1.plus(Currency.NZD, 3); assertMCA(test, ca, cb, CurrencyAmount.of(Currency.NZD, 3)); }
public void test_minus_CurrencyAmount_add() { CurrencyAmount ca = CurrencyAmount.of(Currency.AUD, 117); CurrencyAmount cb = CurrencyAmount.of(Currency.USD, 12); CurrencyAmount cc = CurrencyAmount.of(Currency.NZD, 3); MultiCurrencyAmount mc1 = MultiCurrencyAmount.of(ca, cb); MultiCurrencyAmount test = mc1.minus(cc); assertMCA(test, ca, cb, cc.negated()); }
public void test_plus_CurrencyAmount_merge() { CurrencyAmount ca = CurrencyAmount.of(Currency.AUD, 117); CurrencyAmount cb = CurrencyAmount.of(Currency.USD, 12); CurrencyAmount cc = CurrencyAmount.of(Currency.AUD, 3); MultiCurrencyAmount mc1 = MultiCurrencyAmount.of(ca, cb); MultiCurrencyAmount test = mc1.plus(cc); assertMCA(test, cb, CurrencyAmount.of(Currency.AUD, 120)); }
public void test_minus_CurrencyDouble_merge() { CurrencyAmount ca = CurrencyAmount.of(Currency.AUD, 117); CurrencyAmount cb = CurrencyAmount.of(Currency.USD, 12); MultiCurrencyAmount mc1 = MultiCurrencyAmount.of(ca, cb); MultiCurrencyAmount test = mc1.minus(Currency.AUD, 3); assertMCA(test, cb, CurrencyAmount.of(Currency.AUD, 114)); }
public void test_plus_MultiCurrencyAmount_mergeAndAdd() { CurrencyAmount ca = CurrencyAmount.of(Currency.AUD, 117); CurrencyAmount cb = CurrencyAmount.of(Currency.USD, 12); CurrencyAmount cc = CurrencyAmount.of(Currency.AUD, 3); CurrencyAmount cd = CurrencyAmount.of(Currency.NZD, 3); MultiCurrencyAmount mc1 = MultiCurrencyAmount.of(ca, cb); MultiCurrencyAmount mc2 = MultiCurrencyAmount.of(cc, cd); MultiCurrencyAmount test = mc1.plus(mc2); assertMCA(test, cb, cd, CurrencyAmount.of(Currency.AUD, 120)); }
public void test_minus_MultiCurrencyAmount_mergeAndAdd() { CurrencyAmount ca = CurrencyAmount.of(Currency.AUD, 117); CurrencyAmount cb = CurrencyAmount.of(Currency.USD, 12); CurrencyAmount cc = CurrencyAmount.of(Currency.AUD, 3); CurrencyAmount cd = CurrencyAmount.of(Currency.NZD, 3); MultiCurrencyAmount mc1 = MultiCurrencyAmount.of(ca, cb); MultiCurrencyAmount mc2 = MultiCurrencyAmount.of(cc, cd); MultiCurrencyAmount test = mc1.minus(mc2); assertMCA(test, cb, cd.negated(), CurrencyAmount.of(Currency.AUD, 114)); }
public void test_plus_CurrencyDouble_merge() { CurrencyAmount ca = CurrencyAmount.of(Currency.AUD, 117); CurrencyAmount cb = CurrencyAmount.of(Currency.USD, 12); MultiCurrencyAmount mc1 = MultiCurrencyAmount.of(ca, cb); MultiCurrencyAmount test = mc1.plus(Currency.AUD, 3); assertMCA(test, cb, CurrencyAmount.of(Currency.AUD, 120)); }