braintree / braintree_php

Braintree PHP library
https://developer.paypal.com/braintree/docs/start/overview
MIT License
546 stars 224 forks source link

Feature request: set properties on webhookTesting()->sampleNotification() #274

Closed steffenbrand closed 2 years ago

steffenbrand commented 4 years ago

General information

Issue description

I really like the webhookTesting feature of your php-sdk. But currently I'm only able to set the ID of the "additional attribute". In my case a subscription.

$gateway = new Gateway([
    'merchantId' => $_ENV['BRAINTREE_MERCHANT_ID'],
    'environment' => $_ENV['BRAINTREE_ENVIRONMENT'],
    'publicKey' => $_ENV['BRAINTREE_API_PUBLIC_KEY'],
    'privateKey' => $_ENV['BRAINTREE_API_PRIVATE_KEY']
]);

$sampleNotification = $gateway->webhookTesting()->sampleNotification(
    WebhookNotification::SUBSCRIPTION_CANCELED,
    'unknownSubscriptionId'
);

I would really like to be able to set all properties, so I can simulate all states. I would allow me to use the sdk even for integration testing. Maybe it could look like this:

$gateway = new Gateway([
    'merchantId' => $_ENV['BRAINTREE_MERCHANT_ID'],
    'environment' => $_ENV['BRAINTREE_ENVIRONMENT'],
    'publicKey' => $_ENV['BRAINTREE_API_PUBLIC_KEY'],
    'privateKey' => $_ENV['BRAINTREE_API_PRIVATE_KEY']
]);

$sampleNotification = $gateway->webhookTesting()->sampleNotification(
    WebhookNotification::SUBSCRIPTION_CANCELED,
    [
        'id' => 'mySubscriptionId',
        'status' => \Braintree\Subscription::CANCELED,
        'updatedAt' => new \DateTimeImmutable()
    ]
);
hollabaq86 commented 4 years ago

đź‘‹ @steffenbrand thanks for the request! We've had similar requests in some of our other server SDKs, and we're brainstorming solutions.

I don't have an ETA on when this would be added to the SDK, but in the meantime, I'm going to leave this issue open to track interest.

Surf-N-Code commented 4 years ago

+1

mkraemer commented 4 years ago

+1 :)

xyNNN commented 4 years ago

+1

acfo commented 4 years ago

+1

DPoplin commented 2 years ago

This issue has been forwarded to the engineering team that owns our webhooks platform. I'm going to close this issue as no additional work will take place within the SDK at this time.