Advertisement
Guest User

Untitled

a guest
Feb 21st, 2020
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.         Source sourceCreate;
  2.         try {
  3.             Map<String, Object> sourceParams = new HashMap<String, Object>();
  4.             sourceParams.put("type", "klarna");
  5.             sourceParams.put("amount", 500);
  6.             sourceParams.put("currency", "gbp");
  7.  
  8.             Map<String, Object> klarnaParams = new HashMap<String, Object>();
  9.             klarnaParams.put("product","payment");
  10.             klarnaParams.put("purchase_country","GB");
  11.  
  12.             sourceParams.put("klarna", klarnaParams);
  13.            
  14.     /*
  15.             Source.OrderItem item = new Source.OrderItem();
  16.             item.setAmount((long) 500);
  17.             item.setType("sku");
  18.             item.setCurrency("gbp");
  19.     */     
  20.             Map<String, Object> orderItem = new HashMap<String, Object>();
  21.             orderItem.put("amount", 500);
  22.             orderItem.put("type", "sku");
  23.             orderItem.put("currency", "gbp");
  24.             ArrayList<Object> items = new ArrayList<Object>();
  25.             items.add(orderItem);
  26.  
  27.             Map<String, Object> orderParams = new HashMap<String, Object>();
  28.             orderParams.put("items", items);
  29.  
  30.             sourceParams.put("source_order", orderParams);
  31.  
  32.             sourceCreate = Source.create(sourceParams);
  33.  
  34.         } catch (StripeException err) {
  35.             System.out.println("Error :" + err.toString() + err.getCode());
  36.             responseObject.setError(err.toString());
  37.         } catch (Exception ex) {
  38.             System.out.println("Error : " + ex.toString());
  39.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement