Skip to content

Commit

Permalink
Add stripe receipt url to charge
Browse files Browse the repository at this point in the history
  • Loading branch information
mguidetti committed Apr 18, 2022
1 parent 674e98a commit 5d639c1
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions app/models/pay/charge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class Charge < Pay::ApplicationRecord

# Store the payment method kind (card, paypal, etc)
store_accessor :data, :paddle_receipt_url
store_accessor :data, :stripe_receipt_url
store_accessor :data, :stripe_account

# Payment method attributes
Expand Down
5 changes: 3 additions & 2 deletions docs/5_charges.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,13 @@ The details saved will vary depending upon the payment method used.
@charge.bank #=> Bank name
```

## Paddle
## Receipt URL

Paddle provides a receipt URL for each payment.
Paddle and Stripe provide a receipt URL for each payment.

```ruby
@charge.paddle_receipt_url
@charge.stripe_receipt_url
```

## Next
Expand Down
1 change: 1 addition & 0 deletions lib/pay/stripe/charge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def self.sync(charge_id, object: nil, stripe_account: nil, try: 0, retries: 1)
created_at: Time.at(object.created),
currency: object.currency,
stripe_account: pay_customer.stripe_account,
stripe_receipt_url: object.receipt_url,
metadata: object.metadata,
payment_method_type: object.payment_method_details.type,
brand: payment_method.try(:brand)&.capitalize,
Expand Down
3 changes: 2 additions & 1 deletion test/pay/stripe/charge_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ def fake_stripe_charge(**values)
},
metadata: {
license_id: 1
}
},
receipt_url: "https://pay.stripe.com/receipts/test_receipt"
)
::Stripe::Charge.construct_from(values)
end
Expand Down
3 changes: 2 additions & 1 deletion test/support/fixtures/stripe/charge.succeeded.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"last4": "4444"
}
},
"stripe_account": null
"stripe_account": null,
"receipt_url": "https://pay.stripe.com/receipts/test_receipt"
}
}

0 comments on commit 5d639c1

Please sign in to comment.