Skip to content

Commit

Permalink
update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
vildanbina committed Nov 15, 2023
1 parent 3853279 commit 9763fcc
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 51 deletions.
4 changes: 2 additions & 2 deletions example/additional_services/creditManagment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ const invoice = creditManagement.createCombinedInvoice({
},
});

const sepadirectdebit = buckaroo.method('sepadirectdebit');
sepadirectdebit
buckaroo
.method('sepadirectdebit')
.combine(invoice.data)
.pay({
invoice: '',
Expand Down
27 changes: 12 additions & 15 deletions example/additional_services/subscription.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
require('../buckarooClient');
import Subscriptions from '../../src/PaymentMethods/Subscriptions';
import Ideal from '../../src/PaymentMethods/Ideal';
import buckaroo from '../buckarooClient';

const subscription = buckaroo.method('CreditManagement3');

const subscription = new Subscriptions();
subscription.createCombined({
address: undefined,
allowedServices: '',
Expand All @@ -26,14 +25,12 @@ subscription.createCombined({
transactionVatPercentage: 0,
});

(async () => {
const combinedPayment = await new Ideal()
.combine(subscription)
.pay({
amountDebit: 1,
currency: 'EUR',
description: 'test',
})
.request();
console.log(combinedPayment);
})();
buckaroo
.method('ideal')
.combine(subscription)
.pay({
amountDebit: 1,
currency: 'EUR',
description: 'test',
})
.request();
22 changes: 12 additions & 10 deletions example/buckarooClient.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import Buckaroo from '@buckaroo/buckaroo_sdk';

const buckaroo = Buckaroo.InitializeClient({
secretKey: 'secret',
websiteKey: 'website',
});
const buckaroo = Buckaroo.InitializeClient(
{
secretKey: process.env.BPE_SECRET_KEY || '',
websiteKey: process.env.BPE_WEBSITE_KEY || '',
},
{
mode: 'TEST',
currency: 'EUR',
returnURL: 'https://example.com/return',
pushURL: 'https://example.com/push',
}
);

buckaroo.config = {
mode: 'TEST',
currency: 'EUR',
returnURL: 'https://example.com/return',
pushURL: 'https://example.com/push',
};
export default buckaroo;
10 changes: 5 additions & 5 deletions example/response/push.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import buckaroo from "../buckarooClient";
import { ReplyHandler } from "../../src/Handlers/Reply/ReplyHandler";
import buckaroo from '../buckarooClient';
import { ReplyHandler } from '../../src/Handlers/Reply/ReplyHandler';

//START HTTP POST PUSH
let post_data = `{
Expand Down Expand Up @@ -32,10 +32,10 @@ reply_handler.isValid(); // Return either true or false
//END HTTP POST PUSH

//START JSON PUSH
const auth_header = "IBjihN7Fhp:0YvyjYAzDQ28W+hQi80f2nhe0Z1QFJLbz7IH//6LsAU=:cad1832100784f57a6e6de835d9f3638:1658227572";
const auth_header = 'IBjihN7Fhp:0YvyjYAzDQ28W+hQi80f2nhe0Z1QFJLbz7IH//6LsAU=:cad1832100784f57a6e6de835d9f3638:1658227572';
post_data =
"{\"transaction\":{\"Key\":\"5340604668D74435AA344E1428ED1292\",\"Invoice\":\"62d68b6c8ab0c\",\"ServiceCode\":\"ideal\",\"Status\":{\"Code\":{\"Code\":190,\"Description\":\"Success\"},\"SubCode\":{\"Code\":\"S001\",\"Description\":\"transaction successfully processed\"},\"DateTime\":\"2022-07-19T12:46:12\"},\"IsTest\":true,\"Order\":\"ORDER_NO_62d68b6ca2df3\",\"Currency\":\"EUR\",\"AmountDebit\":10.1,\"TransactionType\":\"C021\",\"Services\":[{\"Name\":\"ideal\",\"Action\":null,\"Parameters\":[{\"Name\":\"consumerIssuer\",\"Value\":\"ABN AMRO\"},{\"Name\":\"transactionId\",\"Value\":\"0000000000000001\"},{\"Name\":\"consumerName\",\"Value\":\"J. de Tèster\"},{\"Name\":\"consumerIBAN\",\"Value\":\"NL44RABO0123456789\"},{\"Name\":\"consumerBIC\",\"Value\":\"RABONL2U\"}],\"VersionAsProperty\":2}],\"CustomParameters\":null,\"AdditionalParameters\":{\"List\":[{\"Name\":\"initiated_by_magento\",\"Value\":\"1\"},{\"Name\":\"service_action\",\"Value\":\"something\"}]},\"MutationType\":1,\"RelatedTransactions\":null,\"IsCancelable\":false,\"IssuingCountry\":null,\"StartRecurrent\":false,\"Recurring\":false,\"CustomerName\":\"J. de Tèster\",\"PayerHash\":\"2d26d34584a4eafeeaa97eed10cfdae22ae64cdce1649a80a55fafca8850e3e22cb32eb7c8fc95ef0c6f96669a21651d4734cc568816f9bd59c2092911e6c0da\",\"PaymentKey\":\"AEC974D455FF4A4B9B4C21E437A04838\",\"Description\":null}}";
const uri = "https://buckaroo.dev/push";
'{"transaction":{"Key":"5340604668D74435AA344E1428ED1292","Invoice":"62d68b6c8ab0c","ServiceCode":"ideal","Status":{"Code":{"Code":190,"Description":"Success"},"SubCode":{"Code":"S001","Description":"transaction successfully processed"},"DateTime":"2022-07-19T12:46:12"},"IsTest":true,"Order":"ORDER_NO_62d68b6ca2df3","Currency":"EUR","AmountDebit":10.1,"TransactionType":"C021","Services":[{"Name":"ideal","Action":null,"Parameters":[{"Name":"consumerIssuer","Value":"ABN AMRO"},{"Name":"transactionId","Value":"0000000000000001"},{"Name":"consumerName","Value":"J. de Tèster"},{"Name":"consumerIBAN","Value":"NL44RABO0123456789"},{"Name":"consumerBIC","Value":"RABONL2U"}],"VersionAsProperty":2}],"CustomParameters":null,"AdditionalParameters":{"List":[{"Name":"initiated_by_magento","Value":"1"},{"Name":"service_action","Value":"something"}]},"MutationType":1,"RelatedTransactions":null,"IsCancelable":false,"IssuingCountry":null,"StartRecurrent":false,"Recurring":false,"CustomerName":"J. de Tèster","PayerHash":"2d26d34584a4eafeeaa97eed10cfdae22ae64cdce1649a80a55fafca8850e3e22cb32eb7c8fc95ef0c6f96669a21651d4734cc568816f9bd59c2092911e6c0da","PaymentKey":"AEC974D455FF4A4B9B4C21E437A04838","Description":null}}';
const uri = 'https://buckaroo.dev/push';

reply_handler = new ReplyHandler(buckaroo.credentials, post_data, auth_header, uri);
reply_handler.validate();
Expand Down
20 changes: 5 additions & 15 deletions example/transaction/creditCard.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
require('../buckarooClient');
import CreditCard from '../../src/PaymentMethods/CreditCard';
import buckaroo from '../buckarooClient';

const paymentMethod = new CreditCard('nexi');

(async () => {
try {
const info = await paymentMethod.pay({
invoice: 'test1',
amountDebit: 12,
});
console.log(info);
} catch (error) {
console.warn(error);
}
})();
buckaroo.method('nexi').pay({
invoice: 'test1',
amountDebit: 12,
});
8 changes: 4 additions & 4 deletions example/transaction/ideal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ const ideal = buckarooClient.method('ideal');
ideal
.pay({
amountDebit: 10.1,
issuer: "ABNANL2A",
description: "Ideal Payment",
issuer: 'ABNANL2A',
description: 'Ideal Payment',
})
.request();
//Refund
ideal
.refund({
originalTransactionKey: "",
originalTransactionKey: '',
amountCredit: 10.1,
invoice: "",
invoice: '',
})
.request();

Expand Down

0 comments on commit 9763fcc

Please sign in to comment.