Skip to content

Instantly share code, notes, and snippets.

@keikubo
keikubo / get_charge.rb
Created April 6, 2013 20:59
Ruby1.8.5でWebPayのRest APIを使う例。
#!/usr/bin/env ruby
require 'net/https'
require 'uri'
require 'rubygems'
require 'json'
url = URI.parse('https://api.webpay.jp/v1/charges/ch_WO14ib0ANJiSHn')
req = Net::HTTP::Get.new(url.path)
req.basic_auth 'vtUQeOtUnYr7PGCLQ96Ul4zqpDUO4sOE', ''
@keikubo
keikubo / test.php
Last active December 15, 2015 17:39
<?php
require_once("lib/Stripe.php");
Stripe::setApiKey('webpay_api_key');
Stripe::$apiBase = "https://api.webpay.jp";
$myCard = array('number' => '4242424242424242', 'exp_month' => 5, 'exp_year' => 2015, 'name' => 'Kei Kubo', 'cvc' => 123);
$charge = Stripe_Charge::create(array('card' => $myCard, 'amount' => 2000, 'currency' => 'jpy'));
echo $charge;
echo $charge["id"];
@keikubo
keikubo / plan.py
Last active December 15, 2015 00:49
>>> customer = stripe.Customer.create(
... card="tok_1SxLsd4YtToozX")
>>> plan = stripe.Plan.create(
... amount=2000,
... interval='month',
... name='Amazing Gold Plan',
... currency='usd',
... id='gold')
>>> customer.update_subscription(
... plan="gold")
var key = 'pk_test_czwzkTp2tactuLOEOqbMTRzG';
var params = {
'card[number]': '4242 4242 4242 4242',
'card[exp_month]': '01',
'card[exp_year]': '2050'
};
$.ajax({
url: 'https://api.stripe.com/v1/tokens',
method: 'POST',
@keikubo
keikubo / customer.json
Created October 1, 2012 07:21
定期購読のステータスの非同期な確認方法
{
"id": "cus_LG0Lf1WTDaDlbQ",
"livemode": false,
"object": "customer",
"created": 1347547188,
"description": "1人目の顧客(WebPayスタッフ)",
"subscription": {
"object":"subscription",
"status":"trialing",
"plan": {
@keikubo
keikubo / README.md
Created September 16, 2012 09:16
use Webpay through Stripe gem

Stripeのgemをそのまま修正せずに使ってWebpayにアクセスする例。

普通にアクセスすると、Stripeにアクセスするため、'jpy'に対応していないというエラーがでる。下のコマンドは通常のapi_baseを指定しないスクリプトを実行するコマンド。

curl -s -L https://raw.github.com/gist/3731714/2302c7644f8b2d2d51127efd4da6f7eb4c65185b/create_charge.rb | ruby

で、api_baseで 'https://api.webpay.jp/v1' を指定してあげると、Webpayにアクセスするので、きちんと日本円で決済ができることが確認できる。逆に'usd'での取引はできない。

curl -s -L https://raw.github.com/gist/3731714/654e3d408e604b289481cee87ce7dc7a4d30fe98/create_charge.rb | ruby
@keikubo
keikubo / stripe_webpay_gem.diff
Created September 11, 2012 04:25
Diff between Stripe gem and Webpay gem.
diff --git a/lib/stripe.rb b/lib/stripe.rb
index fb4a6a6..7e77804 100644
--- a/lib/stripe.rb
+++ b/lib/stripe.rb
@@ -46,7 +46,7 @@ require 'stripe/errors/authentication_error'
module Stripe
@@ssl_bundle_path = File.join(File.dirname(__FILE__), 'data/ca-certificates.crt')
@@api_key = nil
- @@api_base = 'https://api.stripe.com/v1'
+ @@api_base = 'https://api.webpay.jp/v1'
@keikubo
keikubo / charge.rb
Created September 4, 2012 19:52
webpay.jp curl example to create a new charge
require 'stripe'
Stripe.api_key = "vtUQeOtUnYr7PGCLQ96Ul4zqpDUO4sOE"
Stripe.api_base = "https://api.webpay.jp/v1"
charges = Stripe::Charge.create(
:amount => 400,
:currency => "jpy",
:card => {
:number => "4242424242424242",
:exp_month => 1,
:exp_year => 2015,
@keikubo
keikubo / README.md
Created July 21, 2012 02:49
unixbench for some major VPS services

unixbench for major VPS services and FLX::VPS

compared services

  • 1GB FLX::VPS (KVM) -> flx_vps_1g.txt
  • 2GB FLX::VPS (KVM) -> flx_vps_2g.txt
  • 4GB FLX::VPS (KVM) -> flx_vps_4g.txt
  • 8GB FLX::VPS (KVM) -> flx_vps_8g.txt
  • 2GB Linode VPS (Xen) -> linode.txt
@keikubo
keikubo / README.md
Created June 28, 2012 07:17
一般ユーザーの登録手順 - Rackhub:FI

一般ユーザーの登録手順

1. 管理者に招待状を送ってもらってください。

ユーザーの追加(招待)は、管理者権限を持ったユーザーのみが行うことができます。もしユーザーの登録が必要で、招待状をまだもらっていない方は、まず管理者の方に問い合わせて、招待状を送ってもらってください。

2. 招待状に記載のURLへアクセスする。

Rackhub:FIへの招待状はメールで送られてきます。メールで送られてきた招待状には、あなたが登録するための登録用URLが記載されています。