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

會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
中 央社
 
The basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptxThe basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptx
heathfieldcps1
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
中 央社
 

Recently uploaded (20)

Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45
Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45
Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45
 
size separation d pharm 1st year pharmaceutics
size separation d pharm 1st year pharmaceuticssize separation d pharm 1st year pharmaceutics
size separation d pharm 1st year pharmaceutics
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
 
An Overview of the Odoo 17 Discuss App.pptx
An Overview of the Odoo 17 Discuss App.pptxAn Overview of the Odoo 17 Discuss App.pptx
An Overview of the Odoo 17 Discuss App.pptx
 
“O BEIJO” EM ARTE .
“O BEIJO” EM ARTE                       .“O BEIJO” EM ARTE                       .
“O BEIJO” EM ARTE .
 
Navigating the Misinformation Minefield: The Role of Higher Education in the ...
Navigating the Misinformation Minefield: The Role of Higher Education in the ...Navigating the Misinformation Minefield: The Role of Higher Education in the ...
Navigating the Misinformation Minefield: The Role of Higher Education in the ...
 
Word Stress rules esl .pptx
Word Stress rules esl               .pptxWord Stress rules esl               .pptx
Word Stress rules esl .pptx
 
ANTI PARKISON DRUGS.pptx
ANTI         PARKISON          DRUGS.pptxANTI         PARKISON          DRUGS.pptx
ANTI PARKISON DRUGS.pptx
 
The basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptxThe basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptx
 
UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024
 
Dementia (Alzheimer & vasular dementia).
Dementia (Alzheimer & vasular dementia).Dementia (Alzheimer & vasular dementia).
Dementia (Alzheimer & vasular dementia).
 
The Last Leaf, a short story by O. Henry
The Last Leaf, a short story by O. HenryThe Last Leaf, a short story by O. Henry
The Last Leaf, a short story by O. Henry
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
 
Graduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptxGraduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptx
 
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...
 
Capitol Tech Univ Doctoral Presentation -May 2024
Capitol Tech Univ Doctoral Presentation -May 2024Capitol Tech Univ Doctoral Presentation -May 2024
Capitol Tech Univ Doctoral Presentation -May 2024
 
MOOD STABLIZERS DRUGS.pptx
MOOD     STABLIZERS           DRUGS.pptxMOOD     STABLIZERS           DRUGS.pptx
MOOD STABLIZERS DRUGS.pptx
 
How to Manage Closest Location in Odoo 17 Inventory
How to Manage Closest Location in Odoo 17 InventoryHow to Manage Closest Location in Odoo 17 Inventory
How to Manage Closest Location in Odoo 17 Inventory
 
MichaelStarkes_UncutGemsProjectSummary.pdf
MichaelStarkes_UncutGemsProjectSummary.pdfMichaelStarkes_UncutGemsProjectSummary.pdf
MichaelStarkes_UncutGemsProjectSummary.pdf
 
PSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptxPSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.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()); } }