Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Deepu K Sasidharan deepu105

🏠
Working from home
View GitHub Profile
View payment-api-bobpay.js
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;
}
View payment-api-shell.sh
# 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
View 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.
View 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 Mar 5, 2021
payment-api-button.html
View payment-api-button.html
<a onclick="checkout()">
<p class="button">Checkout</p>
</a>
View 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
View adyen-react-blog-6.sh
export ADYEN_API_KEY=yourAdyenApiKey
export ADYEN_MERCHANT_ACCOUNT=yourAdyenMerchantAccount
export ADYEN_ORIGIN_KEY=yourAdyenOriginKeyForCorrectDomain
View adyen-react-blog-5.tsx
//import ...;
export interface ICheckoutProp extends StateProps, DispatchProps {}
class CheckoutContainer extends React.Component<ICheckoutProp> {
private paymentContainer = React.createRef<HTMLDivElement>();
//...
componentDidMount() {
this.props.getEntityForCurrentUser();
View adyen-react-blog-4.gradle
implementation group: "com.adyen", name: "adyen-java-api-library", version: "5.0.0"
View adyen-react-blog-3.jdl
application {
config {
baseName store
packageName com.adyen.demo.store
authenticationType jwt
prodDatabaseType mysql
buildTool gradle
clientFramework react
useSass true
enableTranslation false