예제 #1
0
  @Test
  public void updateUpdatesCoinbaseAccount() {
    Result<Customer> customerResult = gateway.customer().create(new CustomerRequest());
    String customerId = customerResult.getTarget().getId();

    PaymentMethodRequest venmoRequest =
        new PaymentMethodRequest().customerId(customerId).paymentMethodNonce(Nonce.VenmoAccount);
    Result<? extends PaymentMethod> venmoResult = gateway.paymentMethod().create(venmoRequest);
    VenmoAccount venmoAccount = (VenmoAccount) venmoResult.getTarget();
    assertTrue(venmoAccount.isDefault());

    PaymentMethodRequest request =
        new PaymentMethodRequest().customerId(customerId).paymentMethodNonce(Nonce.Coinbase);
    Result<? extends PaymentMethod> paymentMethodResult = gateway.paymentMethod().create(request);

    assertTrue(paymentMethodResult.isSuccess());
    String token = paymentMethodResult.getTarget().getToken();

    PaymentMethodRequest updatePaymentMethodRequest =
        new PaymentMethodRequest().options().makeDefault(true).done();

    Result<? extends PaymentMethod> result =
        gateway.paymentMethod().update(token, updatePaymentMethodRequest);

    assertTrue(result.isSuccess());
    assertTrue(result.getTarget() instanceof CoinbaseAccount);
    CoinbaseAccount coinbaseAccount = (CoinbaseAccount) result.getTarget();
    assertTrue(coinbaseAccount.isDefault());
  }
예제 #2
0
  @Test
  public void onCustomer() {
    Result<Customer> customerResult =
        gateway.customer().create(new CustomerRequest().paymentMethodNonce(Nonce.Coinbase));
    assertTrue(customerResult.isSuccess());
    Customer customer = customerResult.getTarget();

    List<CoinbaseAccount> accounts =
        gateway.customer().find(customer.getId()).getCoinbaseAccounts();
    assertEquals(1, accounts.size());

    CoinbaseAccount account = accounts.get(0);
    assertNotNull(account);
    assertNotNull(account.getToken());
    assertNotNull(account.getUserId());
    assertThat(account.getUserId(), not(equalTo("")));
    assertNotNull(account.getUserName());
    assertThat(account.getUserName(), not(equalTo("")));
    assertNotNull(account.getUserEmail());
    assertThat(account.getUserEmail(), not(equalTo("")));

    String token = account.getToken();

    gateway.paymentMethod().delete(token);

    exception.expect(NotFoundException.class);
    gateway.paymentMethod().find(token);
  }
예제 #3
0
  @Test
  public void canVault() {
    Result<Customer> customerResult = gateway.customer().create(new CustomerRequest());
    String customerId = customerResult.getTarget().getId();

    Result<? extends PaymentMethod> paymentMethodResult =
        gateway
            .paymentMethod()
            .create(
                new PaymentMethodRequest()
                    .customerId(customerId)
                    .paymentMethodNonce(Nonce.Coinbase));
    assertTrue(paymentMethodResult.isSuccess());

    CoinbaseAccount account = (CoinbaseAccount) paymentMethodResult.getTarget();
    assertNotNull(account);
    assertNotNull(account.getToken());
    assertNotNull(account.getUserId());
    assertThat(account.getUserId(), not(equalTo("")));
    assertNotNull(account.getUserName());
    assertThat(account.getUserName(), not(equalTo("")));
    assertNotNull(account.getUserEmail());
    assertThat(account.getUserEmail(), not(equalTo("")));
  }