From 2104b6361ef2671ebf9593bdeb1a9025b6e4bd80 Mon Sep 17 00:00:00 2001 From: u1168238 Date: Wed, 29 May 2019 21:09:38 +0530 Subject: [PATCH] [NM] Demo to change Stripe API endpoint --- src/main/java/com/stripe/Stripe.java | 2 +- src/test/java/com/stripe/MyStripeTest.java | 30 ++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 src/test/java/com/stripe/MyStripeTest.java diff --git a/src/main/java/com/stripe/Stripe.java b/src/main/java/com/stripe/Stripe.java index c6c0e532ca5..2217f47bd83 100644 --- a/src/main/java/com/stripe/Stripe.java +++ b/src/main/java/com/stripe/Stripe.java @@ -12,7 +12,7 @@ public abstract class Stripe { public static final String API_VERSION = "2019-05-16"; public static final String CONNECT_API_BASE = "https://connect.stripe.com"; - public static final String LIVE_API_BASE = "https://api.stripe.com"; + public static final String LIVE_API_BASE = "https://services.dev.api.m2digitalbroker.com/proxy/m2-stripe"; public static final String UPLOAD_API_BASE = "https://files.stripe.com"; public static final String VERSION = "10.0.1"; diff --git a/src/test/java/com/stripe/MyStripeTest.java b/src/test/java/com/stripe/MyStripeTest.java new file mode 100644 index 00000000000..03646ab8f99 --- /dev/null +++ b/src/test/java/com/stripe/MyStripeTest.java @@ -0,0 +1,30 @@ +package com.stripe; + +import com.stripe.exception.StripeException; +import com.stripe.model.Charge; +import org.junit.Test; + +import java.util.HashMap; +import java.util.Map; + +public class MyStripeTest { + + @Test + public void testCharges(){ + Stripe.apiKey = "sk_test_7CTiDS47hsbqVCU50gZdwFrr"; + + Map chargeMap = new HashMap(); + chargeMap.put("amount", 999); + chargeMap.put("currency", "usd"); + chargeMap.put("description", "Example charge"); + chargeMap.put("source", "tok_visa"); // obtained via Stripe.js + chargeMap.put("receipt_email", "25ae2a97be554c16e97ebc1e687f7558"); + + try { + Charge charge = Charge.create(chargeMap); + System.out.println(charge); + } catch (StripeException e) { + e.printStackTrace(); + } + } +}