https://github.com/bogdanp/mobilpay
A barebones implementation of mobilay's credit card ordering interface in Racket.
https://github.com/bogdanp/mobilpay
mobilpay payment payment-gateway racket
Last synced: 29 days ago
JSON representation
A barebones implementation of mobilay's credit card ordering interface in Racket.
- Host: GitHub
- URL: https://github.com/bogdanp/mobilpay
- Owner: Bogdanp
- License: bsd-3-clause
- Created: 2019-06-20T10:35:36.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2022-12-18T09:17:59.000Z (over 2 years ago)
- Last Synced: 2025-03-02T00:34:27.118Z (2 months ago)
- Topics: mobilpay, payment, payment-gateway, racket
- Language: Racket
- Size: 7.81 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# mobilpay
A barebones implementation of [mobilpay]'s credit card ordering
interface in Racket.## Setup
raco pkg install mobilpay
## Usage
Download the public certificate and your private key from the Mobilpay
dashboard and then convert the certificate into a public key:openssl x501 -noout -pubkey -in certificate.cer > certificate.pub
Ensure you have `libcrypto` in your `crypto-factories`:
```racket
(require crypto
crypto/libcrypto)(crypto-factories (list libcrypto-factory))
```Create a client instance:
```racket
(define mobilpay
(make-mobilpay #:signature "example"
#:pubk-path "/path/to/certificate.pub"
#:privk-path "/path/to/private.key"))
```Create an `xexpr?` representing an order:
```racket
(define order
(make-order mobilpay
#:order-id "unique-id"
#:currency 'RON
#:amount 1090 ;; in cents (i.e. this represents "10.90 RON")
#:description "Payment for widgets"
#:confirmation-url "https://example.com/confirmation"
#:return-url "https://example.com/return"))
```Encrypt it:
```racket
(define-values (encrypted-order-data encrypted-shared-key)
(order->data mobilpay order))
```Send the order to mobilpay:
```html
Pay now```
Mobilpay will send you payment notifications to the
`confirmation-url`. You can decrypt and turn those into `xexpr?`
values using `data->order`:```racket
(require xml/se-path)(define (confirmation-page req)
(define bindings (request-bindings req))
(define encrypted-order-data (binding:form-value (bindings-assq #"data" bindings)))
(define encrypted-shared-key (binding:form-value (bindings-assq #"env_key" bindings)))
(define order+mobilpay-data
(data->order mobilpay encrypted-order-data encrypted-shared-key))(displayln (se-path* '(mobilpay action) order+mobilpay-data))
(displayln (se-path* '(mobilpay error) order+mobilpay-data)))
```You will get multiple payment notifications per payment, each
representing an action that was taken.[mobilpay]: https://www.mobilpay.ro/public/