{"id":19892172,"url":"https://github.com/broadleafcommerce/blc-sample-payment-gateway","last_synced_at":"2025-05-02T18:31:39.388Z","repository":{"id":48874469,"uuid":"46384043","full_name":"BroadleafCommerce/blc-sample-payment-gateway","owner":"BroadleafCommerce","description":"Broadleaf Null Payment Gateway Integration - a sample payment gateway integration that does not integrate with an actual payment gateway. Its sole purpose is to demonstrate how the framework may integrate with a real gateway and demonstrate a sample implementation for many of the gateway interfaces.","archived":false,"fork":false,"pushed_at":"2025-05-02T14:57:23.000Z","size":385,"stargazers_count":1,"open_issues_count":0,"forks_count":14,"subscribers_count":26,"default_branch":"develop-3.0.x","last_synced_at":"2025-05-02T15:47:35.013Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BroadleafCommerce.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2015-11-18T00:16:13.000Z","updated_at":"2025-04-17T13:58:43.000Z","dependencies_parsed_at":"2024-02-23T12:30:35.815Z","dependency_job_id":"305cd242-4880-41e4-b370-5cbcc66e6407","html_url":"https://github.com/BroadleafCommerce/blc-sample-payment-gateway","commit_stats":null,"previous_names":[],"tags_count":29,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BroadleafCommerce%2Fblc-sample-payment-gateway","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BroadleafCommerce%2Fblc-sample-payment-gateway/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BroadleafCommerce%2Fblc-sample-payment-gateway/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BroadleafCommerce%2Fblc-sample-payment-gateway/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BroadleafCommerce","download_url":"https://codeload.github.com/BroadleafCommerce/blc-sample-payment-gateway/tar.gz/refs/heads/develop-3.0.x","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252088544,"owners_count":21692813,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-12T18:22:05.791Z","updated_at":"2025-05-02T18:31:38.029Z","avatar_url":"https://github.com/BroadleafCommerce.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"blc-sample-payment-gateway\n=============\n\nBroadleaf Sample Payment Gateway Integration - a sample payment gateway integration that does not integrate with an actual payment gateway. Its sole purpose is to demonstrate how the framework may integrate with a real gateway and demonstrate a sample implementation for many of the gateway interfaces.\n\n### Sample Nonce Payment Submission\n\nIn order to set up the payment submission using a payment nonce and ajax request, you will need to include a CheckoutEndpoint\nlike the following:\n\n```java\n@RestController\n@RequestMapping(value = \"/cart/checkout\",\n    produces = {MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE})\npublic class SamplePaymentNonceCheckoutEndpoint extends com.broadleafcommerce.rest.api.endpoint.checkout.CheckoutEndpoint {\n    \n    @RequestMapping(method = RequestMethod.POST, value = \"/complete\")\n    public String performCheckout(HttpServletRequest request,\n                                        @RequestParam(\"cartId\") Long cartId,\n                                        @RequestParam(\"payment_method_nonce\") String nonce) {\n        Order cart = orderService.findOrderById(cartId);\n\n        if (cart != null) {\n            try {\n                //Create a new PAYMENT_NONCE Order Payment\n                OrderPayment paymentNonce = orderPaymentService.create();\n                paymentNonce.setType(PaymentType.CREDIT_CARD);\n                paymentNonce.setPaymentGatewayType(SamplePaymentGatewayType.NULL_GATEWAY);\n                paymentNonce.setAmount(cart.getTotalAfterAppliedPayments());\n                paymentNonce.setOrder(cart);\n\n                //Populate Billing Address per UI requirements\n                //For this example, we'll copy the address from the temporary Credit Card's Billing address and archive the payment,\n                // (since Heat Clinic's checkout template saves and validates the address in a previous section).\n                OrderPayment tempPayment = null;\n                for (OrderPayment payment : cart.getPayments()) {\n                    if (PaymentGatewayType.TEMPORARY.equals(payment.getGatewayType()) \u0026\u0026\n                            PaymentType.CREDIT_CARD.equals(payment.getType())) {\n                        tempPayment = payment;\n                        break;\n                    }\n                }\n                if (tempPayment != null){\n                    paymentNonce.setBillingAddress(addressService.copyAddress(tempPayment.getBillingAddress()));\n                    orderService.removePaymentFromOrder(cart, tempPayment);\n                }\n\n                // Create the UNCONFIRMED transaction for the payment\n                PaymentTransaction transaction = orderPaymentService.createTransaction();\n                transaction.setAmount(cart.getTotalAfterAppliedPayments());\n                transaction.setRawResponse(\"Sample Payment Nonce\");\n                transaction.setSuccess(true);\n                transaction.setType(PaymentTransactionType.UNCONFIRMED);\n                transaction.getAdditionalFields().put(SamplePaymentGatewayConstants.PAYMENT_METHOD_NONCE, nonce);\n\n                transaction.setOrderPayment(paymentNonce);\n                paymentNonce.addTransaction(transaction);\n                orderService.addPaymentToOrder(cart, paymentNonce, null);\n\n                cart = orderService.save(cart, true);\n\n                return paymentGatewayCheckoutService.initiateCheckout(cart.getId());\n            } catch (Exception e) {\n                throw BroadleafWebServicesException.build(HttpStatus.SC_INTERNAL_SERVER_ERROR)\n                        .addMessage(BroadleafWebServicesException.CHECKOUT_PROCESSING_ERROR);\n            }\n        }\n\n        throw BroadleafWebServicesException.build(HttpStatus.SC_NOT_FOUND)\n                .addMessage(BroadleafWebServicesException.CART_NOT_FOUND);\n    }\n}\n```\n\nHere is an example of a checkout request using the `superagent` javascript library:\n\n```javascript\nimport request from 'core/util/superagent'\n\nconst SamplePaymentService = {\n    \n    tokenizeCard: (paymentForm) =\u003e {\n        // This is where you would tokenize the card\n        const nonce = `${paymentForm.creditCardNumber}|${paymentForm.creditCardName}|${paymentForm.expirationDate}|${paymentForm.cvv}`\n        return Promise.resolve(nonce)\n    },\n\n    performCheckout: (order, payment_method_nonce) =\u003e {\n        return new Promise((resolve, reject) =\u003e {\n            request.post('/api/cart/checkout/complete')\n                .query({ cartId: order.id, payment_method_nonce })\n                .end((err, response) =\u003e {\n                    if (err) {\n                        reject(err)\n                    }\n\n                    if (response.body) {\n                        resolve(response.body)\n                    }\n                })\n        })\n    }\n}\n\nexport default SamplePaymentService\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbroadleafcommerce%2Fblc-sample-payment-gateway","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbroadleafcommerce%2Fblc-sample-payment-gateway","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbroadleafcommerce%2Fblc-sample-payment-gateway/lists"}