gpt4 book ai didi

php - Stripe 支付安卓

转载 作者:搜寻专家 更新时间:2023-11-01 09:49:49 25 4
gpt4 key购买 nike

我想使用 Stripe Api 创建付款 我在 android 中创建了所有东西,现在我可以获得 token ,但他说将它发送到您的服务器,问题是我找不到服务器代码或网络服务,这将占用我的请代币并用它支付任何帮助

https://stripe.com/docs/mobile/android

    Card card = new Card("4242424242424242", 12, 2017, "123");

Stripe stripe = new Stripe("pk_test_6pRNASCoBOKtIshFeQd4XMUh");
stripe.createToken(
card,
new TokenCallback() {
public void onSuccess(Token token) {
// Send token to your server
//what should i do in this step i want any code in php that do this job
}
public void onError(Exception error) {
// Show localized error message
Toast.makeText(getContext(),
error.getLocalizedString(getContext()),
Toast.LENGTH_LONG
).show();
}
}
)

最佳答案

将 token 和其他信息传递给 php 文件:

<?php
require_once('./config.php');

$token = $_POST['stripeToken'];

$customer = \Stripe\Customer::create(array(
'email' => 'customer@example.com',
'card' => $token
));

$charge = \Stripe\Charge::create(array(
'customer' => $customer->id,
'amount' => 5000,
'currency' => 'usd'
));

echo '<h1>Successfully charged $50.00!</h1>';
?>

关于php - Stripe 支付安卓,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36568177/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com