SlideShare a Scribd company logo
1 of 1
Hello,
I need code written in the Java programming language for the following exercise:
Please compile and run the output to show validation of it working (if you could include a
sample output screenshot below would be appreciated) !
Thanks in advance for the help, it is much appreciated.
Solution
public static void processPayment(final String receipt) throws SystemException { final
BASE64Encoder encoder = new BASE64Encoder(); final String receiptData =
encoder.encode(receipt.getBytes()); final String jsonData = "{"receipt-data" : "" +
receiptData + ""}"; System.out.println(receipt); System.out.println(jsonData); try { final URL
url = new URL(_sandboxUriStr); final HttpURLConnection conn = (HttpsURLConnection)
url.openConnection(); conn.setRequestMethod("POST"); conn.setDoOutput(true); final
OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
wr.write(jsonData); wr.flush(); // Get the response final BufferedReader rd = new
BufferedReader(new InputStreamReader(conn.getInputStream())); String line; while ((line =
rd.readLine()) != null) { System.out.println(line); } wr.close(); rd.close(); } catch (IOException
e) { throw new SystemException("Error when trying to send request to '%s', %s",
_sandboxUriStr, e.getMessage()); } }

More Related Content

Similar to Hello- I need code written in the Java programming language for the fo.docx

33rd Degree 2013, Bad Tests, Good Tests
33rd Degree 2013, Bad Tests, Good Tests33rd Degree 2013, Bad Tests, Good Tests
33rd Degree 2013, Bad Tests, Good Tests
Tomek Kaczanowski
 
Quest 1 define a class batsman with the following specifications
Quest  1 define a class batsman with the following specificationsQuest  1 define a class batsman with the following specifications
Quest 1 define a class batsman with the following specifications
rajkumari873
 
database propertiesjdbc.url=jdbcderbyBigJavaDB;create=true # .pdf
database propertiesjdbc.url=jdbcderbyBigJavaDB;create=true # .pdfdatabase propertiesjdbc.url=jdbcderbyBigJavaDB;create=true # .pdf
database propertiesjdbc.url=jdbcderbyBigJavaDB;create=true # .pdf
fashiionbeutycare
 
Anton Moldovan "Load testing which you always wanted"
Anton Moldovan "Load testing which you always wanted"Anton Moldovan "Load testing which you always wanted"
Anton Moldovan "Load testing which you always wanted"
Fwdays
 
Jdk 7 4-forkjoin
Jdk 7 4-forkjoinJdk 7 4-forkjoin
Jdk 7 4-forkjoin
knight1128
 

Similar to Hello- I need code written in the Java programming language for the fo.docx (20)

2012 JDays Bad Tests Good Tests
2012 JDays Bad Tests Good Tests2012 JDays Bad Tests Good Tests
2012 JDays Bad Tests Good Tests
 
Expert JavaScript tricks of the masters
Expert JavaScript  tricks of the mastersExpert JavaScript  tricks of the masters
Expert JavaScript tricks of the masters
 
33rd Degree 2013, Bad Tests, Good Tests
33rd Degree 2013, Bad Tests, Good Tests33rd Degree 2013, Bad Tests, Good Tests
33rd Degree 2013, Bad Tests, Good Tests
 
How to make Ajax work for you
How to make Ajax work for youHow to make Ajax work for you
How to make Ajax work for you
 
Asynchronen Code testen
Asynchronen Code testenAsynchronen Code testen
Asynchronen Code testen
 
Quest 1 define a class batsman with the following specifications
Quest  1 define a class batsman with the following specificationsQuest  1 define a class batsman with the following specifications
Quest 1 define a class batsman with the following specifications
 
Webauthn Tutorial
Webauthn TutorialWebauthn Tutorial
Webauthn Tutorial
 
Mobile Open Day: React Native: Crossplatform fast dive
Mobile Open Day: React Native: Crossplatform fast diveMobile Open Day: React Native: Crossplatform fast dive
Mobile Open Day: React Native: Crossplatform fast dive
 
database propertiesjdbc.url=jdbcderbyBigJavaDB;create=true # .pdf
database propertiesjdbc.url=jdbcderbyBigJavaDB;create=true # .pdfdatabase propertiesjdbc.url=jdbcderbyBigJavaDB;create=true # .pdf
database propertiesjdbc.url=jdbcderbyBigJavaDB;create=true # .pdf
 
Ac2
Ac2Ac2
Ac2
 
Anton Moldovan "Load testing which you always wanted"
Anton Moldovan "Load testing which you always wanted"Anton Moldovan "Load testing which you always wanted"
Anton Moldovan "Load testing which you always wanted"
 
An Introduction to Property Based Testing
An Introduction to Property Based TestingAn Introduction to Property Based Testing
An Introduction to Property Based Testing
 
Jdk 7 4-forkjoin
Jdk 7 4-forkjoinJdk 7 4-forkjoin
Jdk 7 4-forkjoin
 
All you need to know about Callbacks, Promises, Generators
All you need to know about Callbacks, Promises, GeneratorsAll you need to know about Callbacks, Promises, Generators
All you need to know about Callbacks, Promises, Generators
 
Nodejs do teste de unidade ao de integração
Nodejs  do teste de unidade ao de integraçãoNodejs  do teste de unidade ao de integração
Nodejs do teste de unidade ao de integração
 
assigemt calculater.docx
assigemt calculater.docxassigemt calculater.docx
assigemt calculater.docx
 
Introduction to Unit Testing with PHPUnit
Introduction to Unit Testing with PHPUnitIntroduction to Unit Testing with PHPUnit
Introduction to Unit Testing with PHPUnit
 
Cnam azure 2014 mobile services
Cnam azure 2014   mobile servicesCnam azure 2014   mobile services
Cnam azure 2014 mobile services
 
CGI.ppt
CGI.pptCGI.ppt
CGI.ppt
 
Creating a Facebook Clone - Part XLV.pdf
Creating a Facebook Clone - Part XLV.pdfCreating a Facebook Clone - Part XLV.pdf
Creating a Facebook Clone - Part XLV.pdf
 

More from deant5

Harris Fell- CPA and member of the AICPA- was engaged to audit the fin.docx
Harris Fell- CPA and member of the AICPA- was engaged to audit the fin.docxHarris Fell- CPA and member of the AICPA- was engaged to audit the fin.docx
Harris Fell- CPA and member of the AICPA- was engaged to audit the fin.docx
deant5
 
Gwen and Paul are deciding how to split their time between writing mus.docx
Gwen and Paul are deciding how to split their time between writing mus.docxGwen and Paul are deciding how to split their time between writing mus.docx
Gwen and Paul are deciding how to split their time between writing mus.docx
deant5
 
1- A buyout involving the target firms current management is called a.docx
1- A buyout involving the target firms current management is called a.docx1- A buyout involving the target firms current management is called a.docx
1- A buyout involving the target firms current management is called a.docx
deant5
 
1)What are the advantages and disadvantages for MNEs to provide post-a.docx
1)What are the advantages and disadvantages for MNEs to provide post-a.docx1)What are the advantages and disadvantages for MNEs to provide post-a.docx
1)What are the advantages and disadvantages for MNEs to provide post-a.docx
deant5
 

More from deant5 (20)

Hello- please use EULERS METHOD to solve and graph this- Please show -.docx
Hello- please use EULERS METHOD to solve and graph this- Please show -.docxHello- please use EULERS METHOD to solve and graph this- Please show -.docx
Hello- please use EULERS METHOD to solve and graph this- Please show -.docx
 
he above pictures best represents a solid lonic A) picture (a) B) pict.docx
he above pictures best represents a solid lonic A) picture (a) B) pict.docxhe above pictures best represents a solid lonic A) picture (a) B) pict.docx
he above pictures best represents a solid lonic A) picture (a) B) pict.docx
 
Heidi Design acquired 20- of the outstanding common stock of Quigly Co (1).docx
Heidi Design acquired 20- of the outstanding common stock of Quigly Co (1).docxHeidi Design acquired 20- of the outstanding common stock of Quigly Co (1).docx
Heidi Design acquired 20- of the outstanding common stock of Quigly Co (1).docx
 
Heidi Design acquired 20- of the outstanding common stock of Quigly Co.docx
Heidi Design acquired 20- of the outstanding common stock of Quigly Co.docxHeidi Design acquired 20- of the outstanding common stock of Quigly Co.docx
Heidi Design acquired 20- of the outstanding common stock of Quigly Co.docx
 
Halogens tend to have high- I- electronegativities II- solublity in a.docx
Halogens tend to have high-  I- electronegativities II- solublity in a.docxHalogens tend to have high-  I- electronegativities II- solublity in a.docx
Halogens tend to have high- I- electronegativities II- solublity in a.docx
 
Heat transfer summary questionsSolutionThermal energy is related to th.docx
Heat transfer summary questionsSolutionThermal energy is related to th.docxHeat transfer summary questionsSolutionThermal energy is related to th.docx
Heat transfer summary questionsSolutionThermal energy is related to th.docx
 
he following accounts were taken from ABC CompanySolutionCalculation o.docx
he following accounts were taken from ABC CompanySolutionCalculation o.docxhe following accounts were taken from ABC CompanySolutionCalculation o.docx
he following accounts were taken from ABC CompanySolutionCalculation o.docx
 
he following accounts were taken from ABC CompanySolutionCalculation o (1).docx
he following accounts were taken from ABC CompanySolutionCalculation o (1).docxhe following accounts were taken from ABC CompanySolutionCalculation o (1).docx
he following accounts were taken from ABC CompanySolutionCalculation o (1).docx
 
Harriet Pandel- an employer- is subject to FICA taxes but exempt from.docx
Harriet Pandel- an employer- is subject to FICA taxes but exempt from.docxHarriet Pandel- an employer- is subject to FICA taxes but exempt from.docx
Harriet Pandel- an employer- is subject to FICA taxes but exempt from.docx
 
Harris Fell- CPA and member of the AICPA- was engaged to audit the fin.docx
Harris Fell- CPA and member of the AICPA- was engaged to audit the fin.docxHarris Fell- CPA and member of the AICPA- was engaged to audit the fin.docx
Harris Fell- CPA and member of the AICPA- was engaged to audit the fin.docx
 
Gwen and Paul are deciding how to split their time between writing mus.docx
Gwen and Paul are deciding how to split their time between writing mus.docxGwen and Paul are deciding how to split their time between writing mus.docx
Gwen and Paul are deciding how to split their time between writing mus.docx
 
Gordon Corporation reported the following equity section on its curren.docx
Gordon Corporation reported the following equity section on its curren.docxGordon Corporation reported the following equity section on its curren.docx
Gordon Corporation reported the following equity section on its curren.docx
 
Goodwill would appear in which balance sheet section- a- Investments b.docx
Goodwill would appear in which balance sheet section- a- Investments b.docxGoodwill would appear in which balance sheet section- a- Investments b.docx
Goodwill would appear in which balance sheet section- a- Investments b.docx
 
1- A genetic map is a(an) set of identical copies of DNA segments from.docx
1- A genetic map is a(an) set of identical copies of DNA segments from.docx1- A genetic map is a(an) set of identical copies of DNA segments from.docx
1- A genetic map is a(an) set of identical copies of DNA segments from.docx
 
1- A buyout involving the target firms current management is called a.docx
1- A buyout involving the target firms current management is called a.docx1- A buyout involving the target firms current management is called a.docx
1- A buyout involving the target firms current management is called a.docx
 
1- 2- 3- 5- Part B Constants- Periodic Table nteractive 3D display mod.docx
1- 2- 3- 5- Part B Constants- Periodic Table nteractive 3D display mod.docx1- 2- 3- 5- Part B Constants- Periodic Table nteractive 3D display mod.docx
1- 2- 3- 5- Part B Constants- Periodic Table nteractive 3D display mod.docx
 
1- (TCO 5) Which form type displays records in a tabular format simila.docx
1- (TCO 5) Which form type displays records in a tabular format simila.docx1- (TCO 5) Which form type displays records in a tabular format simila.docx
1- (TCO 5) Which form type displays records in a tabular format simila.docx
 
1- (TCO F) Which of the following is correct with respect to Internal.docx
1- (TCO F) Which of the following is correct with respect to Internal.docx1- (TCO F) Which of the following is correct with respect to Internal.docx
1- (TCO F) Which of the following is correct with respect to Internal.docx
 
1- (Learning Objective 2- Describe components of internal control) Lis.docx
1- (Learning Objective 2- Describe components of internal control) Lis.docx1- (Learning Objective 2- Describe components of internal control) Lis.docx
1- (Learning Objective 2- Describe components of internal control) Lis.docx
 
1)What are the advantages and disadvantages for MNEs to provide post-a.docx
1)What are the advantages and disadvantages for MNEs to provide post-a.docx1)What are the advantages and disadvantages for MNEs to provide post-a.docx
1)What are the advantages and disadvantages for MNEs to provide post-a.docx
 

Recently uploaded

Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
KarakKing
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 

Recently uploaded (20)

UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 

Hello- I need code written in the Java programming language for the fo.docx

  • 1. Hello, I need code written in the Java programming language for the following exercise: Please compile and run the output to show validation of it working (if you could include a sample output screenshot below would be appreciated) ! Thanks in advance for the help, it is much appreciated. Solution public static void processPayment(final String receipt) throws SystemException { final BASE64Encoder encoder = new BASE64Encoder(); final String receiptData = encoder.encode(receipt.getBytes()); final String jsonData = "{"receipt-data" : "" + receiptData + ""}"; System.out.println(receipt); System.out.println(jsonData); try { final URL url = new URL(_sandboxUriStr); final HttpURLConnection conn = (HttpsURLConnection) url.openConnection(); conn.setRequestMethod("POST"); conn.setDoOutput(true); final OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream()); wr.write(jsonData); wr.flush(); // Get the response final BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream())); String line; while ((line = rd.readLine()) != null) { System.out.println(line); } wr.close(); rd.close(); } catch (IOException e) { throw new SystemException("Error when trying to send request to '%s', %s", _sandboxUriStr, e.getMessage()); } }