Stripe plugin: Invalid identifier when adding payment method

272 views
Skip to first unread message

Dominik Meister

unread,
Mar 11, 2016, 4:04:16 AM3/11/16
to Kill Bill users mailing-list
Hi all

I'm trying to associate a stripe token with one of my accounts, but I keep getting an HTTP 400 with error message "Invalid identifier":

curl -v \
     -X POST \
     -u XXX:XXX \
     -H 'X-Killbill-ApiKey: XXX' \
     -H 'X-Killbill-ApiSecret: XXX' \
     -H 'X-Killbill-CreatedBy: XXX' \
     -H 'Content-Type: application/json' \
     -d '{
       "pluginName": "killbill-stripe",
       "pluginInfo": {
         "properties": [{
           "key": "token",
           "value": "tok_XXX"
         }]
       }
     }' \
     "http://localhost:8080/1.0/kb/accounts/7c37b24a-6c24-463f-b8c9-0fd7e55daa0c/paymentMethods?isDefault=true"


< HTTP/1.1 400 Bad Request
< Server: Apache-Coyote/1.1
< Set-Cookie: JSESSIONID=7; Path=/; HttpOnly
< Set-Cookie: rememberMe=deleteMe; Path=/; Max-Age=0; Expires=Thu, 10-Mar-2016 08:51:05 GMT
< Access-Control-Allow-Origin: *
< Access-Control-Allow-Methods: GET, POST, DELETE, PUT, OPTIONS
< Access-Control-Allow-Headers: Authorization,Content-Type,X-Killbill-ApiKey,X-Killbill-ApiSecret,X-Killbill-Comment,X-Killbill-CreatedBy,X-Killbill-Pagination-CurrentOffset,X-Killbill-Pagination-MaxNbRecords,X-Killbill-Pagination-NextOffset,X-Killbill-Pagination-NextPageUri,X-Killbill-Pagination-TotalNbRecords,X-Killbill-Reason
< Vary: Accept-Encoding
< Content-Type: application/json
< Transfer-Encoding: chunked
< Date: Fri, 11 Mar 2016 08:51:06 GMT
< Connection: close
<
* Closing connection 0
{"className":"org.killbill.billing.payment.api.PaymentApiException","code":7005,"message":"Failed to add payment method for account 7c37b24a-6c24-463f-b8c9-0fd7e55daa0c : Invalid identifier","causeClassName":null,"causeMessage":null,"stackTrace":[]}

What am I doing wrong?

Thanks in advance,
Dominik

Dominik Meister

unread,
Mar 11, 2016, 4:56:56 AM3/11/16
to Kill Bill users mailing-list
Additionally, here's the stack trace I see in Kill Bill's log file:

2016-03-11 09:49:00,400 [Thread-6] WARN  o.k.b.k.0.19.0 - [stripe-plugin] Failure in add_payment_method: Invalid identifier
/var/lib/killbill/bundles/plugins/ruby/killbill-stripe/3.0.2/ROOT/gems/gems/tzinfo-1.2.2/lib/tzinfo/zoneinfo_data_source.rb:208:in `load_timezone_info'
/var/lib/killbill/bundles/plugins/ruby/killbill-stripe/3.0.2/ROOT/gems/gems/tzinfo-1.2.2/lib/tzinfo/timezone.rb:92:in `get'
/var/lib/killbill/bundles/plugins/ruby/killbill-stripe/3.0.2/ROOT/gems/gems/killbill-7.0.0/lib/killbill/gen/api/account.rb:150:in `to_ruby'
/var/lib/killbill/bundles/plugins/ruby/killbill-stripe/3.0.2/ROOT/gems/gems/killbill-7.0.0/lib/killbill/gen/api/account_user_api.rb:100:in `get_account_by_id'
/var/lib/killbill/bundles/plugins/ruby/killbill-stripe/3.0.2/ROOT/lib/stripe/api.rb:102:in `add_payment_method'
/var/lib/killbill/bundles/plugins/ruby/killbill-stripe/3.0.2/ROOT/gems/gems/killbill-7.0.0/lib/killbill/gen/plugin-api/payment_plugin_api.rb:443:in `addPaymentMethod'
Killbill$$Plugin$$Api$$PaymentPluginApi_746532261.gen:13:in `addPaymentMethod'
2016-03-11 09:49:00,402 [Plugin-th-101] WARN  o.k.b.p.core.PaymentMethodProcessor - Error adding payment method 49e4d42e-74db-4962-9ead-591e78e16cb1 for plugin killbill-stripe
org.killbill.billing.payment.plugin.api.PaymentPluginApiException: null
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
        at org.jruby.javasupport.JavaConstructor.newInstanceDirect(JavaConstructor.java:284)
        at org.jruby.java.invokers.ConstructorInvoker.call(ConstructorInvoker.java:97)
        at org.jruby.java.invokers.ConstructorInvoker.call(ConstructorInvoker.java:193)
        at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:356)
        at org.jruby.runtime.callsite.CachingCallSite.callBlock(CachingCallSite.java:213)
        at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:217)
        at org.jruby.java.proxies.ConcreteJavaProxy$InitializeMethod.call(ConcreteJavaProxy.java:60)
        at org.jruby.runtime.callsite.CachingCallSite.callBlock(CachingCallSite.java:211)
        at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:217)
        at org.jruby.RubyClass.newInstance(RubyClass.java:863)
        at org.jruby.RubyClass$INVOKER$i$newInstance.call(RubyClass$INVOKER$i$newInstance.gen)
        at org.jruby.internal.runtime.methods.JavaMethod$JavaMethodZeroOrOneOrTwoOrNBlock.call(JavaMethod.java:318)
        at org.jruby.java.proxies.ConcreteJavaProxy$NewMethod.call(ConcreteJavaProxy.java:162)
        at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:202)
        at org.jruby.ast.CallTwoArgNode.interpret(CallTwoArgNode.java:59)
        at org.jruby.ast.FCallOneArgNode.interpret(FCallOneArgNode.java:36)
        at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105)
        at org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
        at org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
        at org.jruby.ast.RescueBodyNode.interpret(RescueBodyNode.java:108)
        at org.jruby.ast.RescueNode.handleException(RescueNode.java:174)
        at org.jruby.ast.RescueNode.interpret(RescueNode.java:120)
        at org.jruby.ast.EnsureNode.interpret(EnsureNode.java:96)
        at org.jruby.ast.BeginNode.interpret(BeginNode.java:83)
        at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105)
        at org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
        at org.jruby.evaluator.ASTInterpreter.INTERPRET_METHOD(ASTInterpreter.java:74)
        at org.jruby.internal.runtime.methods.InterpretedMethod.call(InterpretedMethod.java:112)
        at org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:169)
        at Killbill$$Plugin$$Api$$PaymentPluginApi_746532261.addPaymentMethod(Killbill$$Plugin$$Api$$PaymentPluginApi_746532261.gen:13)
        at org.killbill.billing.osgi.bundles.jruby.JRubyPaymentPlugin$9.doCall(JRubyPaymentPlugin.java:142)

Dominik Meister

unread,
Mar 11, 2016, 5:19:30 AM3/11/16
to Kill Bill users mailing-list
I digged a bit further and found the following issue which looks like the same: https://github.com/killbill/killbill-stripe-plugin/issues/7

It basically boils down to missing line breaks and indentation in the plugin config, but as far as I can tell my config looks OK:

MariaDB [killbill]> select * from tenant_kvs;
+-----------+--------------------------------------+------------------+-------------------------------+---------------------------------------------------------------------------------------------------------------------------+-----------+---------------------+------------+---------------------+------------+
| record_id | id                                   | tenant_record_id | tenant_key                    | tenant_value                                                                                                              | is_active | created_date        | created_by | updated_date        | updated_by |
+-----------+--------------------------------------+------------------+-------------------------------+---------------------------------------------------------------------------------------------------------------------------+-----------+---------------------+------------+---------------------+------------+
|         6 | 1969b845-7b25-43e7-ad45-1b22b332a01b |                1 | PLUGIN_CONFIG_killbill-stripe | :stripe:
  :api_secret_key: "sk_test_XXX"
  :api_publishable_key: "pk_test_XXX" |         1 | 2016-03-11 10:07:31 | admin      | 2016-03-11 10:07:31 | admin      |
+-----------+--------------------------------------+------------------+-------------------------------+---------------------------------------------------------------------------------------------------------------------------+-----------+---------------------+------------+---------------------+------------+
1 row in set (0.01 sec)

MariaDB [killbill]>

On Friday, March 11, 2016 at 10:04:16 AM UTC+1, Dominik Meister wrote:
On Friday, March 11, 2016 at 10:04:16 AM UTC+1, Dominik Meister wrote:

Dominik Meister

unread,
Mar 11, 2016, 5:42:09 AM3/11/16
to Kill Bill users mailing-list
I figured it out. Problem was that I tried to add the payment method for an account which has its currency configured as CHF (swiss francs). When I tried it with an account with currency USD, it worked.

Stripe is currently running in private beta in Switzerland, so at least theoretically I guess it should be supported. Is there anything that needs to be changed on the plugin side?

Not to mention that the error message is quite cryptic and does not really help in analyzing the problem ;)


On Friday, March 11, 2016 at 10:04:16 AM UTC+1, Dominik Meister wrote:

Pierre-Alexandre Meyer

unread,
Mar 11, 2016, 9:24:59 AM3/11/16
to Dominik Meister, Kill Bill users mailing-list
Hi Dominik,

On Fri, Mar 11, 2016 at 4:56 AM, Dominik Meister <nep...@gmail.com> wrote:
Additionally, here's the stack trace I see in Kill Bill's log file:

2016-03-11 09:49:00,400 [Thread-6] WARN  o.k.b.k.0.19.0 - [stripe-plugin] Failure in add_payment_method: Invalid identifier
/var/lib/killbill/bundles/plugins/ruby/killbill-stripe/3.0.2/ROOT/gems/gems/tzinfo-1.2.2/lib/tzinfo/zoneinfo_data_source.rb:208:in `load_timezone_info'
/var/lib/killbill/bundles/plugins/ruby/killbill-stripe/3.0.2/ROOT/gems/gems/tzinfo-1.2.2/lib/tzinfo/timezone.rb:92:in `get'
/var/lib/killbill/bundles/plugins/ruby/killbill-stripe/3.0.2/ROOT/gems/gems/killbill-7.0.0/lib/killbill/gen/api/account.rb:150:in `to_ruby'
/var/lib/killbill/bundles/plugins/ruby/killbill-stripe/3.0.2/ROOT/gems/gems/killbill-7.0.0/lib/killbill/gen/api/account_user_api.rb:100:in `get_account_by_id'
/var/lib/killbill/bundles/plugins/ruby/killbill-stripe/3.0.2/ROOT/lib/stripe/api.rb:102:in `add_payment_method'

Looking at the stack trace, it seems like the timezone on the account is invalid or cannot be loaded. What is the content of your accounts table for that particular record?

--
Pierre

Dominik Meister

unread,
Mar 11, 2016, 10:03:26 AM3/11/16
to Kill Bill users mailing-list, nep...@gmail.com
Hi Pierre-Alexandre
Thanks, that's exactly it. Here's my account list:

MariaDB [killbill]> select id, name, time_zone, currency from accounts;
+--------------------------------------+-----------------+-----------+----------+
| id                                   | name            | time_zone | currency |
+--------------------------------------+-----------------+-----------+----------+
| 7c37b24a-6c24-463f-b8c9-0fd7e55daa0c | Dominik Meister | +01:00    | CHF      |
| b502f1e6-c9ba-4f9c-9382-b21865436624 | Donald Trump    | UTC       | USD      |
| 8143b939-5a38-44a4-ae6b-72558ff7ff4b | Luke Skywalker  | UTC       | CHF      |
+--------------------------------------+-----------------+-----------+----------+
3 rows in set (0.00 sec)

MariaDB [killbill]>

The stripe plugin works for both accounts in time zone UTC, no matter whether USD or CHF. For the account in time zone +01:00 I do get the error. So it's probably an issue within the ruby library which cannot parse the time zone offset. 
 
Thanks,
Dominik

Pierre-Alexandre Meyer

unread,
Mar 11, 2016, 12:46:16 PM3/11/16
to Dominik Meister, Kill Bill users mailing-list
On Fri, Mar 11, 2016 at 10:03 AM, Dominik Meister <nep...@gmail.com> wrote:
The stripe plugin works for both accounts in time zone UTC, no matter whether USD or CHF. For the account in time zone +01:00 I do get the error. So it's probably an issue within the ruby library which cannot parse the time zone offset.

I've created https://github.com/killbill/killbill-plugin-framework-ruby/issues/54 for tracking. The issue is that the timezone cannot be determined just from the offset. Could you use the timezone identifier instead?

--
Pierre

Dominik Meister

unread,
Mar 14, 2016, 3:37:54 AM3/14/16
to Kill Bill users mailing-list, nep...@gmail.com


On Friday, March 11, 2016 at 6:46:16 PM UTC+1, Pierre-Alexandre Meyer wrote:

I've created https://github.com/killbill/killbill-plugin-framework-ruby/issues/54 for tracking. The issue is that the timezone cannot be determined just from the offset. Could you use the timezone identifier instead?


Thanks a lot. I manually updated the time zone of the account to be CET and I could successfully add the payment method. FYI, I initially created the account using Kaui which seems to use the offset format for time zones instead of the identifier. So it looks more like a Kaui issue to me.

Regards,
Dominik 
Reply all
Reply to author
Forward
0 new messages