我正在构建一个基于 Stripe 的应用程序,用于从仓库下订单。然而,我在正确处理税收方面遇到了问题。这是我迄今为止遵循的过程:
$account = $stripe->accounts->create([
'type' => 'custom',
'country' => 'US',
'email' => $email,
'capabilities' => [
'card_payments' => ['requested' => true],
'transfers' => ['requested' => true],
'us_bank_account_ach_payments' => ['requested' => true],
],
]);
$session = $stripe->accountLinks->create([
'account' => $account['id'],
'refresh_url' => $url,
'return_url' => $url,
'type' => 'account_onboarding',
'collection_options' => [
'fields' => 'eventually_due',
'future_requirements' => 'include',
],
]);
header('Location: ' . $session['url']);
exit();
$stripe->tax->settings->update([
'defaults' => [
'tax_behavior' => 'exclusive',
],
'head_office' => [
'address' => [
'line1' => $account->company->address->line1,
'city' => $account->company->address->city,
'state' => $account->company->address->state,
'postal_code' => $account->company->address->postal_code,
'country' => $account->company->address->country,
]
],
],
['stripe_account' => $account->id]
);
$stripe->tax->registrations->create([
'country' => 'US',
'country_options' => [
'us' => [
'state' => $account->company->address->state,
'type' => 'state_sales_tax',
],
],
'active_from' => 'now',
], ['stripe_account' => $account->id]);
function checkout($application_fee, $amount, $customer_id, $account_id){
global $stripe;
$tax_settings = $stripe->tax->settings->retrieve([], ['stripe_account' => $account_id]);
$stripe->customers->update(
$customer_id,
['address' =>
[
'postal_code' => $tax_settings->head_office->address->postal_code,
'country' => $tax_settings->head_office->address->country,
]
]
);
$invoice = $stripe->invoices->create([
'customer' => $customer_id,
'auto_advance' => false, // Do not auto-finalize the invoice
'collection_method' => 'charge_automatically',
'application_fee_amount' => $application_fee,
'automatic_tax' => [
'enabled' => true,
'liability' => [
'type' => 'account',
'account' => $account_id
],
],
'description' => "Order",
'footer' => "Thank you for using TextToTableAI!",
'issuer' => [
'type' => 'account',
'account' => $account_id
],
'on_behalf_of' => $account_id,
'transfer_data' => [
'destination' => $account_id,
],
]);
$stripe->invoiceItems->create([
'customer' => $customer_id,
'currency' => 'usd',
'description' => 'Test purchase",
'invoice' => $invoice->id,
'quantity' => 1,
'unit_amount' => $amount,
'tax_behavior' => 'exclusive',
'tax_code' => 'txcd_41052001'
]);
$finalized_invoice = $invoice->finalizeInvoice();
$paid_invoice = $finalized_invoice->pay();
$stripe->customers->update(
$customer_id,
['address' =>
[
'postal_code' => null,
'country' => null,
]
]
);
return $paid_invoice;
}
这不可能是处理所有这一切的正确方法。鉴于上述,我有两个关键问题:
有没有一种方法可以简化流程,以便可以同时完成连接账户的入职和税务配置设置,而不是分步进行?
对于不涉及运输的取货订单,使用保存的客户信息自动计算税费而不需要临时地址操作的正确方法是什么?
有没有一种方法可以简化流程,以便可以同时完成连接账户的入职和税务配置设置,而不是分步进行?
看起来您正在遵循此集成指南。创建帐户后,您应该能够设置税务设置并使用他们自己的 API 同时启动入门。它们无法通过一个 API 来完成。
对于不涉及运输的取货订单,使用保存的客户信息自动计算税费而不需要临时地址操作的正确方法是什么?
这是关于如何计算税费的地址层次结构的指南:https://docs.stripe.com/tax/customer-locations#address-hierarchy
如果未提供送货地址,将使用帐单地址。