You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A while ago, I wrote out some pseudo code while thinking about how we could improve the API for developers using it. Idea is to support all of Buckaroo's NVP actions, while keeping the code as Ruby-ish as possible.
This is a work in progress and I'm very much open to suggestions.
# Create a Transaction object, specify the gateway action latert=BuckarooClient.transaction(invoicenumber: 'F2014.0001')t.select_service(:pay_per_email)do |s|
# Add main transaction variables here...end# Support for custom and additional variables (see Buckaroo docs for explanation)t.custom_variables={key: 'value'}t.additional_variables={key: 'value'}t.additional_variables << key: 'value',another_key: 'another_value'# Create an NVP transaction request afterwards and send it outreq=t.transaction_requestreq.send!# ... or, use one of the other available requests# Drawback: this doesn't really fit for all request types.# E.g. `invoice_info` does not need to know what kind of payment service is used.t.invoice_infot.transaction_statust.refund_infot.transaction_request_specificationt.cancel_transaction# Optional batch support...# ...but I think we shouldn't support this.# Sending transactions one by one gives one-on-one success and error messages.batch=BuckarooClient.batchbatch << transactionbatch.to_csv# Another possible approach: expose a `gateway` object with all of the # available request types as public methodsgateway=BuckarooClient.gatewaygateway.invoice_info(invoicenumber: 'F00001')gateway.invoice_info(customercode: 'ABC123')# ...or, skip the `gateway` object altogether.# Simply expose all NVP gateway request types as class-level methodst=BuckarooClient.transaction_requestt.invoicenumber='F0001't.amount='2.34't.culture='nl-BE't.select_service(:pay_per_email)do |s|
# ... set necessary variables for this serviceend# Another approach: simply set all transaction variables in the initializer# and fire the request right way.response=BuckarooClient.transaction_request(invoicenumber: 'F0001',amount: '2.34',services: [{type: :pay_per_email,foo: 'bar',x: 'y'},{type: :credit_management,a: 'b'}])
The text was updated successfully, but these errors were encountered:
A while ago, I wrote out some pseudo code while thinking about how we could improve the API for developers using it. Idea is to support all of Buckaroo's NVP actions, while keeping the code as Ruby-ish as possible.
This is a work in progress and I'm very much open to suggestions.
The text was updated successfully, but these errors were encountered: