2. Redirect your customer to Flospay Checkout
...
// This example sets up an endpoint using the Slim framework.// Watch this xxvideo to get started: https://youtu.be/sGcNPFX1Ph4.use Slim\Http\Request;use Slim\Http\Response;use Flospay\Flospay;require 'vendor/autoload.php';$app = new \Slim\App;$app->add(function ($request, $response, $next) {\Flospay\Flospay::setApiKey('sk_test_4eC39HqLyjWDarjtT1zdp7dc');return $next($request, $response);});$app->post('/create-checkout-session', function (Request $request, Response $response) {$session = \Flospay\Checkout\Session::create(['payment_method_types' => ['card'],'line_items' => [['price_data' => ['currency' => 'usd','product_data' => ['name' => 'T-shirt',],'unit_amount' => 2000,],'quantity' => 1,]],'mode' => 'payment','success_url' => 'https://example.com/success','cancel_url' => 'https://example.com/cancel',]);return $response->withHeader('Location', $session->url)->withStatus(303);});
....
import java.util.HashMap;
import java.util.Map;
import static spark.Spark.get;
import static spark.Spark.post;
import static spark.Spark.port;
import static spark.Spark.staticFiles;
import com.stripe.Stripe;
import com.stripe.model.checkout.Session;
import com.stripe.param.checkout.SessionCreateParams;
public class Server {
public static void main(String[] args) {
port(4242);
Stripe.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"
post("/create-checkout-session", (request, response) -> {
SessionCreateParams params =
SessionCreateParams.builder()
.addPaymentMethodType(SessionCreateParams.PaymentMethodType.CARD)
.setMode(SessionCreateParams.Mode.PAYMENT)
.setSuccessUrl("https://example.com/success")
.setCancelUrl("https://example.com/cancel")
.addLineItem(
SessionCreateParams.LineItem.builder()
.setQuantity(1L)
.setPriceData(
SessionCreateParams.LineItem.PriceData.builder()
.setCurrency("usd")
.setUnitAmount(2000L)
.setProductData(
SessionCreateParams.LineItem.PriceData.ProductData.builder()
.setName("T-shirt")
.build())
.build())
.build())
.build();
Session session = Session.create(params);
response.redirect(session.getUrl(), 303);
return "";
});
}
}
2. redirect
url
//
-============ 2 ===========--
-===========0= 2.0:PHP ===========--
success.html
//
or
-============ 3 ===========--
// This example sets up an endpoint using the Slim framework.// Watch this xxvideo to get started: https://youtu.be/sGcNPFX1Ph4.use Slim\Http\Request;use Slim\Http\Response;use Flospay\Flospay;require 'vendor/autoload.php';$app = new \Slim\App;$app->add(function ($request, $response, $next) {\Flospay\Flospay::setApiKey('sk_test_4eC39HqLyjWDarjtT1zdp7dc');return $next($request, $response);});$app->post('/create-checkout-session', function (Request $request, Response $response) {$session = \Flospay\Checkout\Session::create(['payment_method_types' => ['card'],'line_items' => [['price_data' => ['currency' => 'usd','product_data' => ['name' => 'T-shirt',],'unit_amount' => 2000,],'quantity' => 1,]],'mode' => 'payment','success_url' => 'https://example.com/success','cancel_url' => 'https://example.com/cancel',]);return $response->withHeader('Location', $session->url)->withStatus(303);});