条纹支付安卓 [英] Stripe payment Android

查看:112
本文介绍了条纹支付安卓的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I want to create payment using Stripe Api i created every thing in android and now i can get the token but he said send it to your server the problem that i can't find the server code or web service that will take my token and go pay with it any help please

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();
            }
     }
    )

推荐答案

将令牌和其他信息传递到 php 文件:

Pass token and other information to a php file:

<?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>';
?>

这篇关于条纹支付安卓的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆