Пример #1
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);
  }
Пример #2
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("")));
  }