|
405 | 405 | to be_a_kind_of Hash |
406 | 406 | end |
407 | 407 |
|
| 408 | + it "makes a capture call" do |
| 409 | + request_body = JSON.parse(json_from_file("mocks/requests/Checkout/capture.json")) |
| 410 | + |
| 411 | + response_body = json_from_file("mocks/responses/Checkout/capture.json") |
| 412 | + |
| 413 | + url = @shared_values[:client].service_url(@shared_values[:service], "payments/12345/captures", @shared_values[:client].checkout.version) |
| 414 | + WebMock.stub_request(:post, url). |
| 415 | + with( |
| 416 | + body: request_body, |
| 417 | + headers: { |
| 418 | + "x-api-key" => @shared_values[:client].api_key |
| 419 | + } |
| 420 | + ) |
| 421 | + .to_return(body: response_body, status: 201) |
| 422 | + |
| 423 | + result = @shared_values[:client].checkout.modifications.capture("12345", request_body) |
| 424 | + response_hash = result.response |
| 425 | + |
| 426 | + expect(result.status). |
| 427 | + to eq(201) |
| 428 | + expect(response_hash). |
| 429 | + to eq(JSON.parse(response_body)) |
| 430 | + expect(response_hash). |
| 431 | + to be_a Adyen::HashWithAccessors |
| 432 | + expect(response_hash). |
| 433 | + to be_a_kind_of Hash |
| 434 | + expect(response_hash.reference). |
| 435 | + to eq("123456789") |
| 436 | + expect(response_hash.pspReference). |
| 437 | + to eq("12345") |
| 438 | + end |
| 439 | + |
| 440 | + it "makes a psp specific cancel call" do |
| 441 | + request_body = JSON.parse(json_from_file("mocks/requests/Checkout/psp_cancel.json")) |
| 442 | + |
| 443 | + response_body = json_from_file("mocks/responses/Checkout/psp_cancel.json") |
| 444 | + |
| 445 | + url = @shared_values[:client].service_url(@shared_values[:service], "payments/12345/cancels", @shared_values[:client].checkout.version) |
| 446 | + WebMock.stub_request(:post, url). |
| 447 | + with( |
| 448 | + body: request_body, |
| 449 | + headers: { |
| 450 | + "x-api-key" => @shared_values[:client].api_key |
| 451 | + } |
| 452 | + ) |
| 453 | + .to_return(body: response_body, status: 201) |
| 454 | + |
| 455 | + result = @shared_values[:client].checkout.modifications.cancel("12345", request_body) |
| 456 | + response_hash = result.response |
| 457 | + |
| 458 | + expect(result.status). |
| 459 | + to eq(201) |
| 460 | + expect(response_hash). |
| 461 | + to eq(JSON.parse(response_body)) |
| 462 | + expect(response_hash). |
| 463 | + to be_a Adyen::HashWithAccessors |
| 464 | + expect(response_hash). |
| 465 | + to be_a_kind_of Hash |
| 466 | + expect(response_hash.reference). |
| 467 | + to eq("123456789") |
| 468 | + expect(response_hash.pspReference). |
| 469 | + to eq("12345") |
| 470 | + end |
| 471 | + |
| 472 | + it "makes a psp specific refunds call" do |
| 473 | + request_body = JSON.parse(json_from_file("mocks/requests/Checkout/refund.json")) |
| 474 | + |
| 475 | + response_body = json_from_file("mocks/responses/Checkout/refund.json") |
| 476 | + |
| 477 | + url = @shared_values[:client].service_url(@shared_values[:service], "payments/12345/refunds", @shared_values[:client].checkout.version) |
| 478 | + WebMock.stub_request(:post, url). |
| 479 | + with( |
| 480 | + body: request_body, |
| 481 | + headers: { |
| 482 | + "x-api-key" => @shared_values[:client].api_key |
| 483 | + } |
| 484 | + ) |
| 485 | + .to_return(body: response_body, status: 201) |
| 486 | + |
| 487 | + result = @shared_values[:client].checkout.modifications.refund("12345", request_body) |
| 488 | + response_hash = result.response |
| 489 | + |
| 490 | + expect(result.status). |
| 491 | + to eq(201) |
| 492 | + expect(response_hash). |
| 493 | + to eq(JSON.parse(response_body)) |
| 494 | + expect(response_hash). |
| 495 | + to be_a Adyen::HashWithAccessors |
| 496 | + expect(response_hash). |
| 497 | + to be_a_kind_of Hash |
| 498 | + expect(response_hash.reference). |
| 499 | + to eq("123456789") |
| 500 | + expect(response_hash.pspReference). |
| 501 | + to eq("12345") |
| 502 | + end |
| 503 | + |
| 504 | + it "makes a psp specific reversals call" do |
| 505 | + request_body = JSON.parse(json_from_file("mocks/requests/Checkout/psp_cancel.json")) |
| 506 | + |
| 507 | + response_body = json_from_file("mocks/responses/Checkout/psp_cancel.json") |
| 508 | + |
| 509 | + url = @shared_values[:client].service_url(@shared_values[:service], "payments/12345/reversals", @shared_values[:client].checkout.version) |
| 510 | + WebMock.stub_request(:post, url). |
| 511 | + with( |
| 512 | + body: request_body, |
| 513 | + headers: { |
| 514 | + "x-api-key" => @shared_values[:client].api_key |
| 515 | + } |
| 516 | + ) |
| 517 | + .to_return(body: response_body, status: 201) |
| 518 | + |
| 519 | + result = @shared_values[:client].checkout.modifications.reversal("12345", request_body) |
| 520 | + response_hash = result.response |
| 521 | + |
| 522 | + expect(result.status). |
| 523 | + to eq(201) |
| 524 | + expect(response_hash). |
| 525 | + to eq(JSON.parse(response_body)) |
| 526 | + expect(response_hash). |
| 527 | + to be_a Adyen::HashWithAccessors |
| 528 | + expect(response_hash). |
| 529 | + to be_a_kind_of Hash |
| 530 | + expect(response_hash.reference). |
| 531 | + to eq("123456789") |
| 532 | + expect(response_hash.pspReference). |
| 533 | + to eq("12345") |
| 534 | + end |
| 535 | + |
| 536 | + it "makes a psp specific amountUpdates call" do |
| 537 | + request_body = JSON.parse(json_from_file("mocks/requests/Checkout/amount_updates.json")) |
| 538 | + |
| 539 | + response_body = json_from_file("mocks/responses/Checkout/amount_updates.json") |
| 540 | + |
| 541 | + url = @shared_values[:client].service_url(@shared_values[:service], "payments/12345/amountUpdates", @shared_values[:client].checkout.version) |
| 542 | + WebMock.stub_request(:post, url). |
| 543 | + with( |
| 544 | + body: request_body, |
| 545 | + headers: { |
| 546 | + "x-api-key" => @shared_values[:client].api_key |
| 547 | + } |
| 548 | + ) |
| 549 | + .to_return(body: response_body, status: 201) |
| 550 | + |
| 551 | + result = @shared_values[:client].checkout.modifications.amountUpdate("12345", request_body) |
| 552 | + response_hash = result.response |
| 553 | + |
| 554 | + expect(result.status). |
| 555 | + to eq(201) |
| 556 | + expect(response_hash). |
| 557 | + to eq(JSON.parse(response_body)) |
| 558 | + expect(response_hash). |
| 559 | + to be_a Adyen::HashWithAccessors |
| 560 | + expect(response_hash). |
| 561 | + to be_a_kind_of Hash |
| 562 | + expect(response_hash.reference). |
| 563 | + to eq("123456789") |
| 564 | + expect(response_hash.pspReference). |
| 565 | + to eq("12345") |
| 566 | + end |
| 567 | + |
| 568 | + it "makes a generic cancel call" do |
| 569 | + request_body = JSON.parse(json_from_file("mocks/requests/Checkout/generic_cancel.json")) |
| 570 | + |
| 571 | + response_body = json_from_file("mocks/responses/Checkout/generic_cancel.json") |
| 572 | + |
| 573 | + url = @shared_values[:client].service_url(@shared_values[:service], "cancels", @shared_values[:client].checkout.version) |
| 574 | + WebMock.stub_request(:post, url). |
| 575 | + with( |
| 576 | + body: request_body, |
| 577 | + headers: { |
| 578 | + "x-api-key" => @shared_values[:client].api_key |
| 579 | + } |
| 580 | + ) |
| 581 | + .to_return(body: response_body, status: 201) |
| 582 | + |
| 583 | + result = @shared_values[:client].checkout.modifications.genericCancel(request_body) |
| 584 | + response_hash = result.response |
| 585 | + |
| 586 | + expect(result.status). |
| 587 | + to eq(201) |
| 588 | + expect(response_hash). |
| 589 | + to eq(JSON.parse(response_body)) |
| 590 | + expect(response_hash). |
| 591 | + to be_a Adyen::HashWithAccessors |
| 592 | + expect(response_hash). |
| 593 | + to be_a_kind_of Hash |
| 594 | + expect(response_hash.reference). |
| 595 | + to eq("123456789") |
| 596 | + expect(response_hash.pspReference). |
| 597 | + to eq("12345") |
| 598 | + end |
| 599 | + |
408 | 600 | # create client for automated tests |
409 | 601 | client = create_client(:api_key) |
410 | 602 |
|
|
0 commit comments