Skip to content

Instantly share code, notes, and snippets.

View deepu105's full-sized avatar
🏠
Working from home

Deepu K Sasidharan deepu105

🏠
Working from home
View GitHub Profile
const payment = await request.show();
// This payment method handles everything and returns a final result
if (payment.details.bobpay_token_id) {
await payment.complete("success");
window.location.href = "/result/success";
return false;
}
# Clone this repo
$ git clone https://github.com/deepu105/payment-request-api-example
$ cd payment-request-api-example
# Install dependencies
$ npm install
# create a file named `.env` with values `API_KEY="your_Adyen_API_key"` and `MERCHANT_ACCOUNT="your_Adyen_merchant_account"`
$ vi .env
# start application
$ npm start
@deepu105
deepu105 / payment-api-payment.js
Created March 5, 2021 13:12
payment-api-payment.js
async function checkout() {
try {
const adyenPaymentMethods = await callServer("/api/getPaymentMethods");
// create a new payment request
const request = new PaymentRequest(buildSupportedPaymentMethodData(adyenPaymentMethods), buildShoppingCartDetails());
// show payment sheet
const payment = await request.show();
// Here we would process the payment.
const response = await callServer("/api/initiatePayment", {
// This works only for PCI compliant credit card payments.
@deepu105
deepu105 / payment-api-checkout.js
Created March 5, 2021 13:10
payment-api-checkout.js
async function checkout() {
try {
const adyenPaymentMethods = await callServer("/api/getPaymentMethods");
// create a new payment request
const request = new PaymentRequest(buildSupportedPaymentMethodData(adyenPaymentMethods), buildShoppingCartDetails());
// payment logic goes here
} catch (error) {
console.error(error);
alert(`Error occurred: ${error.message}`);
@deepu105
deepu105 / payment-api-button.html
Last active March 5, 2021 13:09
payment-api-button.html
<a onclick="checkout()">
<p class="button">Checkout</p>
</a>
@deepu105
deepu105 / MdToHtml.html
Created July 7, 2020 14:55
MdToHtml.html
<p>E-commerce applications are the backbone of today&#39;s online shopping world. In this post, we will see how to build an e-commerce application easily using Java, JHipster, Spring Boot, and React. Since we will be scaffolding the application, the post will focus on how to build a shopping cart and payment integration rather than how to build a Java web application.</p>
<h2 id="tools-and-technology-we-will-use">Tools and technology we will use</h2>
<p>We will use the below tools and technology to build this application:</p>
<ul>
<li><a href="https://www.jhipster.tech/"><strong>JHipster</strong></a>: JHipster is a rapid application development platform. It can quickly create web applications and microservices with production-grade code. Head over to the <a href="https://www.jhipster.tech/installation/">installation instructions</a> to set it up. JHipster can scaffold applications with a wide variety of languages, frameworks, and configurations. For this tutorial, we will stick with the following major option
export ADYEN_API_KEY=yourAdyenApiKey
export ADYEN_MERCHANT_ACCOUNT=yourAdyenMerchantAccount
export ADYEN_ORIGIN_KEY=yourAdyenOriginKeyForCorrectDomain
//import ...;
export interface ICheckoutProp extends StateProps, DispatchProps {}
class CheckoutContainer extends React.Component<ICheckoutProp> {
private paymentContainer = React.createRef<HTMLDivElement>();
//...
componentDidMount() {
this.props.getEntityForCurrentUser();
implementation group: "com.adyen", name: "adyen-java-api-library", version: "5.0.0"