我正在使用Stripe Connect在woocommerce网站上收取销售佣金。
我需要在付款请求JSON中添加以下内容。
\'application_fee_amount\' => (Gateway Based Fees Amount),
\'transfer_data\' => [
\'destination\' => \'{{CONNECTED_STRIPE_ACCOUNT_ID}}\',
],
我找到并修改了这段代码,以符合我的目的。编辑:我已经完全重写了这个,我只需要将额外的变量数组值添加到请求中。
//add_filter( \'woocommerce_stripe_request_body\', \'add_application_fee\', 20, 2 );
add_filter(\'wc_stripe_generate_payment_request\', \'add_application_fee\', 20, 3 );
function add_application_fee( $post_data ) {
//$applicationFee = (int)apply_filters(\'vnm_wc_stripe_connect_application_fee\', $order, $request);
$applicationFee = 25; // <- Use this for testing, I
$post_data[\'application_fee_amount\'] = $applicationFee;
$post_data[\'on_behalf_of\'] = \'acct_1GQjzOHenYA2KZ8B\';
$post_data[\'transfer_data\'][\'destination\'] = \'acct_1GQjzOHenYA2KZ8B\';
return $post_data;
}
这不会产生任何错误,但是信息不会添加到条带支付中。
{
"amount": "12766",
"currency": "USD",
"description": "Order 35215",
"metadata": {
"instance": "example.com",
"order_id": "35215",
"order_email": "[email protected]",
"cart_hash": ""
},
"setup_future_usage": "off_session",
"capture_method": "automatic",
"confirmation_method": "manual",
"customer": "cus_H1VGhq2aNJWokc"
}