Introduction to Stripe International Payments
Founded by Patrick and John Collison, two brothers in their 20s, Stripe provides companies with online payment solutions. Stripe charges companies 2.9 percent of each transaction plus 30 cents.
Many Chinese sellers want to use Stripe, now known as the “PayPal of the mobile age,” to set up and collect money. Our current clients include well-known companies like Facebook, Twitter, Shopify, Kickstarter, Target, Wish, Digitalocean, Pinterest, Docker, Sap, Stripe also has a large number of individual, small and mid-sized businesses. Stripe is used by more than 100,000 businesses around the world and generates over $1 billion in annual transactions. Stripe has grown rapidly in recent years and has a strong presence in foreign markets. Stripe offers a simple, easy-to-use, and in-site payment method that provides everything you need to create a fast and effective mobile commerce experience.
Stripe is introduced
Stripe is dedicated to solving the problem of online merchant Payments. Stripe’s products cover all aspects of online merchant Payments, including Payments, Subscription, and Connect, and Sigma, Atlas, and Radar.
Payments
Payments is Stripe’s first and most fundamental product. Payments provides an API and Toolkit that allows developers to develop payment flows to suit their needs. Payments accepts credit cards and common online payment methods (ACH debits, Bitcoin, Alipay, WeChat Pay). By providing tokens that comply with pCI-DSS specifications to its clients, Payments does not allow sensitive information to pass through their servers (exempt from liability). Stripe aims to make it easy for developers to integrate Payments as quickly as one line of javascript code (including the UI).
Subscription
Subscription addresses the question of how to efficiently process recurring billing. Stripe has identified many pain points in periodic billing processing and provides an all-in-one solution. Subscription automatically calculates post-Cancel refunds for periods and supports trial and usage-based plans. For enterprise users, per-seat (base price + user fee * number of users) pricing scheme can be supported. Another recurring pain point for paying bills is expired credit cards, Subscription works with credit card networks to automatically update new card information when old cards have expired, thus avoiding payment failures due to expired credit cards.
Connect
Connect services are targeted at marketplace or platform (similar to Taobao, ebay, EventTribe). The payment requirements of such platforms are to link buyers and sellers, including one-to-one (for example, Uber), one-to-many (for example, one order on Taobao.com comes from different merchants), many-to-many (for example, Google Play provides HBO, ShowTime and other additional services for all users), temporary deposit of funds (for example, the payment occurs after the concert, Similar to the role of Alipay). In the United States, there are tax legal issues associated with platform payments, and Connect notifies the platform of legal procedures when certain users’ payments exceed a certain threshold.
Sigma
Sigma is a data analysis product based on all the data a user already has on Stripe. Instead of building complex pipelines to analyze their own payment data, Sigma users (enterprises) can directly analyze complex data through Stripe’s Own Web UI and SQL statements to make fast and accurate business decisions.
Atlas
To help more people start a company quickly, Atlas takes all the steps of starting a company all at once. With a one-time fee, Stripe will arrange for one Incorporation in Delaware and a business Bank account with Silicon Valley Bank within one week, with one complimentary legal session, plus additional legal and tax services. Through previously acquired Indie Hackers, Atlas also offers a community of entrepreneurs to help users get started quickly
Radar
A self-developed risk control engine system helps enterprises avoid risks.
Integrated Stripe Payment
Before we can integrate Stripe payments, we need to understand Stripe’s management platform.
- Registration management platform, test environment registration address
- After success, the admin platform will generate a secret key for us
- Bring the key with you and the money will be transferred to the admin account you have signed up for
- If you bind the card on the management platform, you can withdraw cash and other operations
After successful registration, we can see the management page as follows, including our secret key and the flow of funds.
We chose the easiest way to integrate Stripe’s Chekcout page, which only takes a few lines of code to integrate Stripe’s ability to pay. The general process is shown in the sequence diagram as follows:
The CheckOut page is a Stripe page that we don’t need to change. The following page is displayed.
Without further ado, directly on the code, I use Java for integration, which generates Session code as follows
1@GetMapping("/pay")
2@ResponseBody
3public Map<String.String> pay(HttpServletRequest httpRequest, HttpServletResponse httpResponse){
4 Map<String.String> resultMap = new HashMap<>();
5 try {
6 Stripe.apiKey = privateKey;
7 Map<String.Object> params = new HashMap<String.Object> ();
8 ArrayList<String> paymentMethodTypes = new ArrayList<>();
9 paymentMethodTypes.add("card");
10 params.put("payment_method_types", paymentMethodTypes);
11 ArrayList<HashMap<String.Object>> lineItems = new ArrayList<>();
12 HashMap<String.Object> lineItem = new HashMap<String.Object> ();
13 lineItem.put("name"."Hu Pengfei test goods");
14 lineItem.put("description"."This is a test sheet description.");
15 lineItem.put("amount".500); // Amount to be paid
16 lineItem.put("currency"."usd"); // Currency of payment
17 lineItem.put("quantity".1);
18 lineItems.add(lineItem);
19 params.put("line_items", lineItems);
20 //TODO must use the callback address returned by HTTPS
21 String uuid = UUID.randomUUID().toString();
22 params.put("client_reference_id", uuid);// The unique identifier of the business system is the unique order number
23 log.info("uuid:{}",uuid);
24 params.put("success_url", URLUtils.getBaseURl(httpRequest)+"/paySuccess");// The payment is successful
25 params.put("cancel_url", URLUtils.getBaseURl(httpRequest)+"/payError");// Failed to pay the page
26 Session session = Session.create(params);
27 String sessionId = session.getId();
28 log.info("sessionId :{}",session.getId());
29 resultMap.put("sessionId",sessionId);
30 } catch (StripeException e) {
31 e.printStackTrace();
32 }
33 return resultMap;
34}
Copy the code
One merchant information I did not let the front end to pass, I wrote dead in the background, just for the convenience of call. You can see that the generated sessionId is passed to the front end, which then makes the following call. You can jump directly to the checkOut page to pay.
1stripe.redirectToCheckout({
2 sessionId: data.sessionId
3}).then(function (result) {
4 console.log(result);
5});
Copy the code
So far, we’ve integrated Stripe payment with just a few lines of code. There are many other features that Stripe supports, including subscription payment, and the ability to use a custom checkout page instead of a checkout page, which I won’t cover here. Specific requirements can be viewed in its documentation is very detailed. The relevant documentation is listed below.
GitHub code is also related to the refund, callback interface information, I will not be introduced here, you can go to GitHub above the code to check it out.
Interested can pay attention to my new public number, search [program ape 100 treasure bag]. Or just scan the code below.
The code address
The relevant data
- Stripe test management platform
- Stripe document
- Stripe – ApI-based easy payment Channel
- Create a session
- A refund
- About the account of the test card
- The latest Stripe JAR package
- Set up Apple Pay test related