Reputation: 387
I want to collect application fees in direct charge concept with Stripe Terminal but Am getting error" Can only apply an application_fee_amount when the PaymentIntent is attempting a direct payment (using an OAuth key or Stripe-Account header)". when i use destination charge its work fine but i want to use direct charge. below code is for destination code.Please help me how i can get application fee in direct charge.
public void paymentIntent() {
PaymentIntentParameters params = new PaymentIntentParameters.Builder()
.setAmount(usdamount)
.setCurrency("usd")
.setApplicationFeeAmount(usdapplicationfee)
.setDescription("Order#" + orderref)
.setMetadata(initialMetadata)
.setOnBehalfOf(accountid)
.setTransferDataDestination(accountid)
.build();
Terminal.getInstance().createPaymentIntent(params, new PaymentIntentCallback() {
@Override
public void onSuccess(PaymentIntent paymentIntent) {
collecetpayment(paymentIntent);
}
@Override
public void onFailure(TerminalException exception) {
accounterror(exception.getErrorMessage(), exception.getMessage());
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
finish();
}
});
}
Upvotes: 0
Views: 348
Reputation: 738
So it's a little complex, because for direct charges to succeed the PaymentIntent, Reader, Location, and Connection must exist on the connected account. That means that you must pass the Stripe-Account header when creating these objects.
If you use direct charges, all Terminal API objects belong to connected accounts.
Here's the flow to create a direct charge with application fee with Terminal:
Note that steps 2 & 3 only apply to the Verifone reader—the bluetooth-based reader will register itself and your app's current location when integrated with the Stripe Terminal SDK.
After initializing Terminal with the Connection from step 4, you can pass the PaymentIntent from Step1 to Terminal.instance().collectPaymentMethod(), .processPayment(). Because the Connection and PaymentIntent are both attached to the connected account, the Terminal SDK will be able to process the direct charges.
There doesn't seem to be an example of this in the Stripe docs at the moment, so if you get stuck I'd recommend asking on their IRC channel (#stripe on freenode) or emailing Stripe support.
Upvotes: 0