You can't cancel a transaction but you can ask for a refund.
Here's how to request an app or media refund from Apple (From: Request a refund for apps or content that you bought from Apple - Apple Support - see the article for more detail.)
1. Sign in to https://reportaproblem.apple.com
2. Tap or click "I'd like to," then choose "Request a refund."
3. Choose the reason why you want a refund, then choose Next.
4. Choose the app, subscription, or other item, then choose Submit.
If you were charged for a subscription that you no longer want, you can also cancel the subscription using the directions in this article --> If you want to cancel a subscription from Apple - Apple Support