An abstraction layer over various payment services like Paypal, AuthorizeNet, Stripe… payment4j allows you to create a shopping site without the heavy part of dealing with a custom API.
Simple purchase
CreditCard creditCard = new CreditCard().setNumber("4007000000027")
.setType(CreditCardType.VISA).setFirstName("John")
.setLastName("Doe").setMonth(12).setYear(2015)
.setVerificationValue("000");
AuthorizeNetGateway
.build(true, “authorizenet.apiLoginId”,“authorizenet.transactionKey”).
transaction
.purchase(Money.of(CurrencyUnit.EUR, 10), creditCard);Recurring
CreditCard creditCard = new CreditCard().setNumber("4007000000027")
.setType(CreditCardType.VISA).setFirstName("John")
.setLastName("Doe").setMonth(12).setYear(2015)
.setVerificationValue("000");
Schedule schedule = new Schedule();
schedule.setEach(ScheduleUnit.MONTH);
schedule.setTotalOccurences(3);
AuthorizeNetGateway
.build(true, “authorizenet.apiLoginId”,“authorizenet.transactionKey”)
.recurring
.recurring(Money.of(CurrencyUnit.EUR, 10), creditCard, schedule);Each provider gateway can expose one or more gateways:
| Gateway | Features |
|---|---|
| TransactionGateway | Basic features: purchase, cancel, authorize, refund, credit |
| RecurringGateway | Reccuring payment |
| HistoryGateway | View the last transaction, query and list transactions |
| CreditCardStoreGateway | Manage credit card on a provider for your customers |
| DirectTransferGateway | Deal with direct transfer like IBAN |
| MobileGateway | Special payment on mobile via SMS premium, in-app micro payment… |
| Provider | Progession |
|---|---|
| Paypal | 80% |
| AuthorizeNet | 80% |
| Stripe | 60% |
| WebPay | 60% |
| App55 | 60% |
| Litle | 30% |
| BrainTree | 10% |
| PayBox | 0% |
| Paymill | 30% |
| Simplify | 10% |
| Samourai | 30% |
| Balanced | 10% |
| MerchantesSolutions | 30% |
Payscape (https://payscape.com/developers/icode.php)
Amazon Payments (http://services.amazon.com/amazon-payments/pricing-plan.html?ld=AS)
Fortumo (http://developers.fortumo.com/)
mvn clean install -DskipTests
(Yeah, all tests are not fixed yet…)
Since we need some accounts for testing and we can’t expose them in public, you have to create a properties file in src/main/test named “accounts.properties”. A template is already present in the folder, just remane it “accouts.properties” and fill the blank inside.
# BrainTree braintree.merchantId=xxxxx braintree.publicKey=xxxxx braintree.privateKey=xxxxx # AuthorizeNet authorizenet.apiLoginId=xxxxx authorizenet.transactionKey=xxxxx