buckaroo-it/BuckarooSDK_PHP

The AfterPay example is not working

Closed this issue · 7 comments

Introduction

The current example of Afterpay is incorrect or incomplete. This results in the following errors:

- Parameter "VatPercentage" missing
- Parameter "GrossUnitPrice" missing
- Parameter "Description" missing

Unfortunately, adding these parameters does not solve this problem

Environment

  • Exacte copy of the Afterpay example.
  • Valid Buckaroo account with AfterPay activated.
  • PHP 7.4

Hi @jurrienpiris, thanks for reporting this issue. The examples seem to be outdated, we'll update them on next release.
Meanwhile try to use the payload from the test file.

$payload = [
'amountDebit' => 50.30,
'order' => uniqid(),
'invoice' => uniqid(),
'billing' => [
'recipient' => [
'category' => RecipientCategory::PERSON,
'careOf' => 'John Smith',
'title' => 'Mrs',
'firstName' => 'John',
'lastName' => 'Do',
'birthDate' => '1990-01-01',
'conversationLanguage' => 'NL',
'identificationNumber' => 'IdNumber12345',
'customerNumber' => 'customerNumber12345'
],
'address' => [
'street' => 'Hoofdstraat',
'houseNumber' => '13',
'houseNumberAdditional' => 'a',
'zipcode' => '1234AB',
'city' => 'Heerenveen',
'country' => 'NL'
],
'phone' => [
'mobile' => '0698765433',
'landline' => '0109876543'
],
'email' => 'test@buckaroo.nl'
],
'shipping' => [
'recipient' => [
'category' => RecipientCategory::COMPANY,
'careOf' => 'John Smith',
'companyName' => 'Buckaroo B.V.',
'firstName' => 'John',
'lastName' => 'Do',
'chamberOfCommerce' => '12345678'
],
'address' => [
'street' => 'Kalverstraat',
'houseNumber' => '13',
'houseNumberAdditional' => 'b',
'zipcode' => '4321EB',
'city' => 'Amsterdam',
'country' => 'NL'
],
],
'articles' => [
[
'identifier' => 'Articlenumber1',
'description' => 'Blue Toy Car',
'vatPercentage' => '21',
'quantity' => '2',
'price' => '20.10'
],
[
'identifier' => 'Articlenumber2',
'description' => 'Red Toy Car',
'vatPercentage' => '21',
'quantity' => '1',
'price' => '10.10'
],
]
];

Thanks for this working example. Could you please also tell me whats the correct way to set the Shipping Cost? I get error message: AmountDoesNotMatch: Pay rejected. The following errors occurred:(order.totalGrossAmount). This is because of the shipping costs.

Hi @Skebantje try the following example.

$payload = [
            'amountDebit'       => 52.30,
            'order'             => uniqid(),
            'invoice'           => uniqid(),
            'clientIP'      => '127.0.0.1',
            'billing'       => [
                'recipient'        => [
                    'category'      => RecipientCategory::PERSON,
                    'careOf'        => 'John Smith',
                    'title'            => 'Mrs',
                    'firstName'      => 'John',
                    'lastName'      => 'Do',
                    'birthDate'     => '1990-01-01',
                    'conversationLanguage'  => 'NL',
                    'identificationNumber'  => 'IdNumber12345',
                    'customerNumber'        => 'customerNumber12345'
                ],
                'address'       => [
                    'street'                => 'Hoofdstraat',
                    'houseNumber'           => '13',
                    'houseNumberAdditional' => 'a',
                    'zipcode'               => '1234AB',
                    'city'                  => 'Heerenveen',
                    'country'               => 'NL'
                ],
                'phone'         => [
                    'mobile'        => '0698765433',
                    'landline'      => '0109876543'
                ],
                'email'         => 'test@buckaroo.nl'
            ],
            'shipping'      => [
                'recipient'        => [
                    'category'      => RecipientCategory::COMPANY,
                    'careOf'        => 'John Smith',
                    'companyName'   => 'Buckaroo B.V.',
                    'firstName'      => 'John',
                    'lastName'          => 'Do',
                    'chamberOfCommerce' => '12345678'
                ],
                'address'       => [
                    'street'                => 'Kalverstraat',
                    'houseNumber'           => '13',
                    'houseNumberAdditional' => 'b',
                    'zipcode'               => '4321EB',
                    'city'                  => 'Amsterdam',
                    'country'               => 'NL'
                ],
            ],
            'articles'      => [
                [
                    'identifier' => 'Articlenumber1',
                    'description' => 'Blue Toy Car',
                    'vatPercentage' => '21',
                    'quantity' => '2',
                    'price' => '20.10'
                ],
                [
                    'identifier' => 'Articlenumber2',
                    'description' => 'Red Toy Car',
                    'vatPercentage' => '21',
                    'quantity' => '1',
                    'price' => '10.10'
                ],
                [
                    'type'      => 'ShippingFee',
                    'identifier' => 'USPShippingID',
                    'description' => 'UPS',
                    'vatPercentage' => '21',
                    'quantity' => '1',
                    'price' => '2'
                ],
            ]
        ];

Thank you very much! I have it all worked right now. I have only 1 issue left. When we use a discount code we get the error 'AmountDoesNotMatch: Pay rejected.'. What is the right way to use a discount code? It would be almost the same as the ShippingFee. I hope you can provide me an example.

Hi there @Skebantje, for adding a discount or additional fee you can add it as an article in the payload. Don't forget to adjust 'amountDebit' aswell to match the articles total amount.

Here's an example

$response = $buckaroo->method('afterpay')->pay([
    'amountDebit'       => 40.30,
    'order'             => uniqid(),
    'invoice'           => uniqid(),
    'clientIP'      => '127.0.0.1',
    'billing'       => [
        'recipient'        => [
            'category'      => RecipientCategory::PERSON,
            'careOf'        => 'John Smith',
            'title'            => 'Mrs',
            'firstName'      => 'John',
            'lastName'      => 'Do',
            'birthDate'     => '1990-01-01',
            'conversationLanguage'  => 'NL',
            'identificationNumber'  => 'IdNumber12345',
            'customerNumber'        => 'customerNumber12345'
        ],
        'address'       => [
            'street'                => 'Hoofdstraat',
            'houseNumber'           => '13',
            'houseNumberAdditional' => 'a',
            'zipcode'               => '1234AB',
            'city'                  => 'Heerenveen',
            'country'               => 'NL'
        ],
        'phone'         => [
            'mobile'        => '0698765433',
            'landline'      => '0109876543'
        ],
        'email'         => 'test@buckaroo.nl'
    ],
    'shipping'      => [
        'recipient'        => [
            'category'      => RecipientCategory::COMPANY,
            'careOf'        => 'John Smith',
            'companyName'   => 'Buckaroo B.V.',
            'firstName'      => 'John',
            'lastName'          => 'Do',
            'chamberOfCommerce' => '12345678'
        ],
        'address'       => [
            'street'                => 'Kalverstraat',
            'houseNumber'           => '13',
            'houseNumberAdditional' => 'b',
            'zipcode'               => '4321EB',
            'city'                  => 'Amsterdam',
            'country'               => 'NL'
        ],
    ],
    'articles'      => [
        [
            'identifier' => 'Articlenumber1',
            'description' => 'Blue Toy Car',
            'vatPercentage' => '21',
            'quantity' => '2',
            'price' => '20.10'
        ],
        [
            'identifier' => 'Articlenumber2',
            'description' => 'Red Toy Car',
            'vatPercentage' => '21',
            'quantity' => '1',
            'price' => '10.10'
        ],
        [
            'identifier' => 'Discount',
            'description' => 'Discount Amount',
            'vatPercentage' => 0,
            'quantity' => '1',
            'price' => '-10'
        ]
    ]
]);

Thank you! I got it all worked right now!

@Skebantje ,

Thank you for the confirmation. Good to hear that it is all working now 👍🏻 .
We'll close this issue .