Skip to content

Commit

Permalink
Initial version or multisafepay client
Browse files Browse the repository at this point in the history
  • Loading branch information
dedene committed Jul 25, 2024
0 parents commit b23aea0
Show file tree
Hide file tree
Showing 33 changed files with 4,960 additions and 0 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: build

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
ruby-version: ['2.7', '3.0', '3.1', '3.2', '3.3']

name: Ruby (${{ matrix.ruby-version }})
steps:
- uses: actions/checkout@v2
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
- name: Run tests
run: bundle install && bundle exec rake test
27 changes: 27 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Publish gem

on:
push:
tags:
- v[0-9]+.[0-9]+.[0-9]+*

jobs:
publish:
name: Push gem to RubyGems.org
runs-on: ubuntu-latest

permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
contents: write # IMPORTANT: this permission is required for `rake release` to push the release tag

steps:
# Set up
- uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
ruby-version: ruby

# Release
- uses: rubygems/release-gem@v1
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/.idea
.DS_Store
multisafepay-api-ruby*.gem
Gemfile.lock
.ruby-gemset
/mk-ca-bundle.pl
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Changelog

All notable changes to this project will be documented in this file.
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source 'https://rubygems.org'

gemspec
18 changes: 18 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
MIT License

Copyright (c) 2024 Zenjoy BV

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial
portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
lib/cacert.pem: certdata.txt
mv ca-bundle.crt lib/cacert.pem
rm certdata.txt

mk-ca-bundle.pl:
curl -q https://raw.githubusercontent.com/curl/curl/master/lib/mk-ca-bundle.pl --output mk-ca-bundle.pl
chmod +x mk-ca-bundle.pl

certdata.txt: mk-ca-bundle.pl
./mk-ca-bundle.pl
92 changes: 92 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<h1 align="center">Unofficial MultiSafePay API client for Ruby</h1>

[![Gem Version](https://badge.fury.io/rb/multisafepay-api-ruby.svg)](https://badge.fury.io/rb/multisafepay-api-ruby)
[![Build Status](https://github.com/zenjoy/multisafepay-api-ruby/actions/workflows/build.yml/badge.svg)](https://github.com/zenjoy/multisafepay-api-ruby/actions/workflows/build.yml)

## Installation

By far the easiest way to install the Multisafepay API client is to install it with
[gem](http://rubygems.org/).

```
# Gemfile
gem "multisafepay-api-ruby"
$ gem install multisafepay-api-ruby
```

You may also git checkout or
[download all the files](https://github.com/zenjoy/multisafepay-api-ruby/archive/main.zip), and
include the Multisafepay API client manually.

## Getting started

Require the Multisafepay API Client. _Not required when used with a Gemfile_

```ruby
require 'multisafepay-api-ruby'
```

Create an initializer and add the following line:

```ruby
MultiSafePay::Client.configure do |config|
config.api_key = '<your-api-key>'
config.environment = :test # or :live

# Timeouts (default - 60)
# config.open_timeout = 60
# config.read_timeout = 60
end
```

You can also include the API Key in each request you make, for instance if you are using the Connect
API:

```ruby
MultiSafePay::Order.get('order-id', api_key: '<your-api-key>', environment: :test)
```

If you need to do multiple calls with the same API Key, use the following helper:

```ruby
MultiSafePay::Client.with_api_key('<your-api-key>') do
MultiSafePay::Order.create(
order_id: '12345',
amount: 1000,
currency: 'EUR',
description: 'My first API payment',
redirect_url: 'https://webshop.example.org/order/12345/',
webhook_url: 'https://webshop.example.org/multisafepay-webhook/'
)
end
```

### Pagination

```ruby
payments = MultiSafePay::Transaction.all
payments.next
payments.previous
```

## API documentation

If you wish to learn more about the MultiSafePay API, please visit the
[API Documentation](https://docs.multisafepay.com/reference/).

## Contributing

Feel free to contribute and make things better by opening an
[Issue](https://github.com/zenjoy/multisafepay-api-ruby/issues) or
[Pull Request](https://github.com/zenjoy/multisafepay-api-ruby/pulls).

## License

View [license information](https://github.com/zenjoy/multisafepay-api-ruby/blob/main/LICENSE) for
the software contained in this image.

## Acknowledgements

This library is heavily inspired by the
[Mollie API client for Ruby](https://github.com/mollie/mollie-api-ruby).
7 changes: 7 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require 'bundler/gem_tasks'

task default: %w[test]

task :test do
ruby 'test/run-test.rb'
end
15 changes: 15 additions & 0 deletions bin/console
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env ruby

require 'bundler/setup'
require 'multisafepay'

# You can add fixtures and/or initialization code here to make experimenting
# with your gem easier. You can also use a different console, if you like.

# (If you use this, don't forget to add pry to your Gemfile!)
# require "pry"
# Pry.start

require 'irb'
require 'pp'
IRB.start(__FILE__)
8 changes: 8 additions & 0 deletions bin/setup
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
set -vx

bundle install

# Do any other automated setup that you need to do here
Loading

0 comments on commit b23aea0

Please sign in to comment.