I’m doing charges according to this guide: https://stripe.com/docs/connect/shared-customers
1) Store customer:
Map<String, Object> params = new HashMap<>();
params.put("email", "paying.user#example.com");
params.put("source", "tok_visa");
Customer customer = Customer.create(params);
2) Make token:
Map<String, Object> params = new HashMap<String, Object>();
params.put("customer", customer.getId());
RequestOptions requestOptions = RequestOptions.builder().setStripeAccount("{CONNECTED_STRIPE_ACCOUNT_ID}").build();
Token token = Token.create(params, requestOptions);`
3) Creating charge:
Map<String, Object> params = new HashMap<>();
params.put("amount", 1000);
params.put("currency", "usd");
params.put("source", token.getId());
RequestOptions requestOptions = RequestOptions.builder().setStripeAccount("{CONNECTED_STRIPE_ACCOUNT_ID}").build();
Charge charge = Charge.create(params, requestOptions);`
Charge created successfully.
But what I try to get list of all charges for this customer, I receive nothing:
Map<String, Object> params = new HashMap<>();
params.put("customer", customer.getId());
Charge.list(params); //no charges in response
So how to get all charges for this customer that was created in such way?
You need to list charges that were created on the connected account. Meaning, you need to pass along the same request options you used to create the charge.
RequestOptions requestOptions = RequestOptions.builder().setStripeAccount("{CONNECTED_STRIPE_ACCOUNT_ID}").build();
Map<String, Object> params = new HashMap<>();
params.put("customer", customer.getId());
Charge.list(params, requestOptions); //no charges in response
Related
This is my Testing Code. And I want that if my Other_comapanies field is empty then I should delete it or else I should leave it.
I am Creating an object and filling all the fields in it. And I am storing null in front of other_comapanies field. When I test my code So expected output like this [null] and my actual output is 'null' like this. So, How should I fix it?
#Test
public void shouldRemoveOtherCompaniesOnUpdatePreProcessing(){
List<BaseEntity> baseEntities = new ArrayList<>();
BaseEntity baseEntity = new ContactEntity();
Map<String, Object> data = new HashMap<>();
data.put("first_name", "Sample");
data.put("last_name", "Contact");
data.put("email", "sample.contact#gmail.com");
data.put("id", 12345);
data.put("company_id", 1234);
List<Map<String, Object>> secondaryCompaniesWithNotRemove = new ArrayList<>();
Map<String, Object> secondaryCompany1 = new HashMap<>();
secondaryCompany1.put("company_id",1234L);
secondaryCompaniesWithNotRemove.add(secondaryCompany1);
baseEntity.setData(data);
baseEntities.add(baseEntity);
Map<String, Object> options = new HashMap<>();
options.put(PreferenceKeyConstants.ENTITIES_TO_SYNC, "ACCOUNTS");
when(contactEntityEndpoint.findById(baseEntity.getId().toString(),null)).thenReturn((ContactEntity) baseEntity);
List<Map<String, Object>> expectedSecondaryCompaniesIsRemoved = new ArrayList<>();
expectedSecondaryCompaniesIsRemoved.add(null);
contactCompanyFieldsPreProcessor.doOnUpdatePreProcessing(baseEntities, new ArrayList<>(), options);
Map<String, Object> preProcessedBaseEntityData = baseEntities.get(0).getData();
assertEquals(expectedSecondaryCompaniesIsRemoved, preProcessedBaseEntityData.get("other_companies"));
}
My testing output is :
java.lang.AssertionError:
Expected :[null]
Actual :null
How Can I fix it? And what am I doing wrong?
I am able to pass the JSON data as Query Parameters in which I am passing particular kit_config_id in the form of HasMap. Now I want the API to return the data related to only specified kit_config_id but its giving me all records.
What wrong I am doing here?
// Request object using RestAssured
RequestSpecification httpRequest = RestAssured.given();
HashMap<String, String> params = new HashMap<String, String>();
params.put("kit_config_id", "60db53ec7a334172b005b692");
Response response = httpRequest.given().baseUri("https://qa-api-test.com").param("query", params).when().get("/imageProps");
Complete Url of GET call is : https://qa-api-tests.com/imageProps?params={"query": {"kit_config_id": "60db53ec7a334172b005b692"}}
If you want query like this
/imageProps?params={"query":{"kit_config_id":"60db0d5d7a334172b005b665"}}
Using this:
HashMap<String, Object> kit_config = new HashMap<>();
kit_config.put("kit_config_id", "60db0d5d7a334172b005b665");
HashMap<String, Object> query = new HashMap<>();
query.put("query", kit_config);
RestAssured.given().log().all().baseUri("your-url")
.queryParams("params", query)
.when().get("/imageProps");
If you want query like this
/imageProps?kit_config_id=60db53ec7a334172b005b692
Just need:
HashMap<String, Object> kit_config = new HashMap<>();
kit_config.put("kit_config_id", "60db0d5d7a334172b005b665");
RestAssured.given().log().all().baseUri("https://postman-echo.com")
.queryParams(kit_config)
.when().get("/imageProps");
I was trying to implemented stripe payment gateway. Every thing is going fine. I was able to create connected account for the user in my stripe dashboard, but the problem is I'm missing following parameter
Website
SSN
Industry
Now I want to know how to add these parameters while creating account.
I have add the screen shot from stripe dashboard and here is the code:
Map<String, Object> dob =
new HashMap<>();
dob.put("day", "12");
dob.put("month", "1");
dob.put("year", "1991");
Map<String, Object> address =
new HashMap<>();
Map<String, Object> address_pram =
new HashMap<>();
address_pram.put("city", "Baton Rouge");
address_pram.put("line1", "1 Calais Ave");
address_pram.put("postal_code", "70806");
address_pram.put("state", "Louisiana");
address.put("address", address_pram);
address.put("dob", dob);
address.put("email", "ahmad#example.com");
address.put("first_name", "ahmad");
address.put("last_name", "bajwa");
address.put("phone", "+12015551023");
//address.put("website", "www.goldenkeystone.com");
//address.put("industry", "");
// address.put("ssn", "000000000");
Map<String, Object> acceptance =
new HashMap<>();
acceptance.put("date", System.currentTimeMillis() / 1000L);
acceptance.put("ip", ipString);
Map<String, Object> cardPayments =
new HashMap<>();
cardPayments.put("requested", true);
Map<String, Object> transfers = new HashMap<>();
transfers.put("requested", true);
Map<String, Object> capabilities =
new HashMap<>();
capabilities.put("card_payments", cardPayments);
capabilities.put("transfers", transfers);
Map<String, Object> params = new HashMap<>();
params.put("type", "custom");
params.put("country", "US");
params.put("tos_acceptance", acceptance);
params.put("business_type", "individual");
params.put("individual", address);
params.put("capabilities", capabilities);
Account account = Account.create(params, requestOptions);
Note: If still question is unclear, I would be glad if you add your contribution.
That data and other sensitive information would be collected by Stripe during the onboarding via Account Links: stripe.com/docs/connect/connect-onboarding
It's not something that you can pass to the Accounts API. See here for more information: https://stripe.com/docs/connect/collect-then-transfer-guide?platform=web#create-an-account-link
I'm currently migrating my app from using the Stripe Charges API to use the Stripe PaymentIntents API, in order to comply with SCA regulations.
My subscription creation code roughly looks like this:
Map<String, Object> srchOpts = new HashMap<>();
srchOpts.put("email", userEmail);
List<Customer> matchingCustomers = Customer.list(srchOpts).getData();
Customer customer = null;
Subscription subscription = null;
if ( matchingCustomers.isEmpty() ){
Map<String, Object> params = new HashMap<String, Object>();
params.put("email", userEmail);
params.put("payment_token", stripeToken);
customer = Customer.create(params);
}
else if (matchingCustomers.size() == 1) {
customer = matchingCustomers.get(0);
Map<String, Object> params = new HashMap<String, Object>();
params.put("source", stripeToken);
PaymentSourceCollection paymentSources = customer.getSources();
paymentSources.create(params);
}
Map<String, Object> item = new HashMap<String, Object>();
item.put("plan", planId); // e.g. my-pro-plan (no trial days)
Map<String, Object> items = new HashMap<String, Object>();
items.put("0", item);
Map<String, Object> params = new HashMap<String, Object>();
params.put("items", items);
params.put("customer", customer.getId());
params.put("off_session", false);
subscription = Subscription.create(params);
I can see on the Stripe dashboard (in test mode) that the customer is created and has the card which I specified, but the Subscription.create call fails with:
com.stripe.exception.InvalidRequestException: This customer has no attached payment source; code: resource_missing
The customer has a card set (there is only 1 so it has to be the default card), the customer creation call happens before the subscription creation call and the customer ID is being passed to the sub creation call. Is there some other parameter I need to pass in?
I've tried setting Customer.invoice_settings.default_payment_method when the customer is being created, and that gets me past the subscription creation. Everything looks fine from the Stripe dashboard, except that I'm testing with an SCA test card, so the transaction is incomplete until the customer has authenticated further.
I need the client secret token from the response to continue, and I thought that I would get it from #Subscription.getLatestInvoiceObject().getPaymentIntentObject().getClientSecret() but the getLatestInvoiceObject() call is returning null.
I'm not setting collection_method on the Subscription object which defaults to charge_automatically. This is what I want because the customer is on-session and so the Invoice being null probably makes sense, but how do I get the client secret to pass back to the frontend? The SetupIntent object returned by the subscription response exposes a client secret, but that object is null too.
Subscription Invoices will use whichever of these three payment options are available (in order of preference):
The Subscription's default_payment_method (reference) or default_source (reference)
The Customer's invoice_settings.default_payment_method (reference)
The Customer's default_source (note: there is no concept of a default PaymentMethod on Customers)
Also worth noting is that PaymentMethods and Sources are two distinct resources. Cards (objects with ids prefixed with card_) can be used as either type.
Trying to retrieve all marketing accounts of a Facebook business account using the spring social framework for Facebook .
I want to know if there is any better way to it other than what i did below ?
Does what i did for paging the query result is the right way to do it ?
Is there another way to retrieve data from the Facebook Marketing API ?
I really appreciate any help you can provide.
public List<String> getListAdAccountsId(String businessAccountId) {
final List<String> accountsId = new ArrayList<String>();
final MultiValueMap<String, String> queryParameters = new LinkedMultiValueMap<String, String>();
queryParameters.add("fields", "account_id");
queryParameters.add("offset", "0");
PagedList<Map> pagedResultSubSet = facebook.fetchConnections(businessAccountId, "adaccounts", Map.class,
queryParameters);
do {
queryParameters.set("offset", pagedResultSubSet.getNextPage().getOffset().toString());
pagedResultSubSet = facebook.fetchConnections(businessAccountId, "adaccounts", Map.class, queryParameters);
accountsId.addAll(pagedResultSubSet.parallelStream().map(e -> e.get("id").toString())
.collect(Collectors.toList()));
} while (pagedResultSubSet.getNextPage() != null);
return accountsId;
}