我正在尝试通过 Stripe 整合 Plaid。请耐心等待,因为我对 javascript 不是很熟悉。
我想知道如何将 public_token 和 account_ID 放入 PHP 变量中,以便可以包含在 curl 调用中。
JS
<button id='linkButton'>Open Plaid Link</button>
<script src="https://cdn.plaid.com/link/stable/link-initialize.js"></script>
<script>
var linkHandler = Plaid.create({
env: 'tartan',
clientName: 'Stripe / Plaid Test',
key: '[Plaid key]',
product: 'auth',
selectAccount: true,
onSuccess: function(public_token, metadata) {
// Send the public_token and account ID to your app server.
console.log('public_token: ' + public_token); // HOW DO I PLACE THIS IN PHP/curl?**
console.log('account ID: ' + metadata.account_id); // HOW DO I PLACE THIS IN PHP/curl?**
},
});
PHP/卷曲
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_URL => 'https://tartan.plaid.com/exchange_token',
CURLOPT_POST => true,
CURLOPT_HTTPHEADER, array(
'Content-Type: application/x-www-form-urlencoded',
),
CURLOPT_POSTFIELDS => http_build_query(array(
'client_id' => '[Plaid client ID]',
'secret' => '[Plaid secret]',
'public_token' => '[Plaid Link public_token]', // HOW DO I CREATE A VARIABLE FROM THE ABOVE JS ( console.log('public_token: ' + public_token);) to place here**
'account_id' => '[Plaid Link account_id]', // HOW DO I CREATE A VARIABLE FROM THE ABOVE JS ( console.log('public_token: ' + public_token);) to place here
)),
));