Stripe payment Android

本小妞迷上赌 提交于 2019-12-07 19:51:16

问题


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

回答1:


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


来源:https://stackoverflow.com/questions/36568177/stripe-payment-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!