The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Net::API::Stripe::Charge - The Charge object of Stripe API

SYNOPSIS

    my $charge = $stripe->charge({
        amount => 2000,
        application_fee => $stripe->application_fee({
            amount => 2000,
            currency => 'jpy',
        }),
        card => $card_object,
        currency => 'jpy',
        customer => $customer_object,
        description => 'Description of the charge',
        invoice => $invoice_object,
        metadata => { transaction_id => 144, customer_id => 123 },
        order => $order_object,
        payment_intent => $payment_intent_object,
        receipt_email => 'john.doe@example.com',
        receipt_number => 'RCP2020040103-123',
    });

VERSION

    v0.101.0

DESCRIPTION

To charge a credit or a debit card, you create a Charge object. You can retrieve and refund individual charges as well as list all charges. Charges are identified by a unique, random ID.

CONSTRUCTOR

new( %ARG )

Creates a new Net::API::Stripe::Charge object. It may also take an hash like arguments, that also are method of the same name.

METHODS

id string

Unique identifier for the object.

object string, value is "charge"

String representing the object’s type. Objects of the same type share the same value.

amount positive integer or zero

A positive integer representing how much to charge in the smallest currency unit (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). The minimum amount is $0.50 US or equivalent in charge currency. The amount value supports up to eight digits (e.g., a value of 99999999 for a USD charge of $999,999.99).

amount_captured positive integer or zero

Amount in JPY captured (can be less than the amount attribute on the charge if a partial capture was made).

amount_refunded positive integer or zero

Amount in JPY refunded (can be less than the amount attribute on the charge if a partial refund was issued).

application string expandable "application"

ID of the Connect application that created the charge. This represents a Net::API::Stripe::Connect::Account object

application_fee string (expandable)

The application fee (if any) for the charge. See the Connect documentation for details. This is a Net::API::Stripe::Connect::ApplicationFee object.

application_fee_amount integer

The amount of the application fee (if any) for the charge. See the Connect documentation for details.

balance_transaction string (expandable)

ID of the balance transaction that describes the impact of this charge on your account balance (not including refunds or disputes).

This is an Net::API::Stripe::Balance::Transaction object.

billing_details hash

Billing information associated with the payment method at the time of the transaction. This is a Net::API::Stripe::Billing::Details object.

Hash properties are:

address This is a Net::API::Stripe::Address
email String
name String
phone String

calculated_statement_descriptor string

The full statement descriptor that is passed to card networks, and that is displayed on your customers’ credit card and bank statements. Allows you to see what the statement descriptor looks like after the static and dynamic portions are combined.

captured boolean

If the charge was created without capturing, this Boolean represents whether it is still uncaptured or has since been captured.

card

This is a Net::API::Stripe::Payment::Card object. It seems it is no documented, but from experience, Stripe has replied with data containing this property.

created timestamp

Time at which the object was created. Measured in seconds since the Unix epoch.

currency currency

Three-letter ISO currency code, in lowercase. Must be a supported currency.

customer string (expandable)

ID of the customer this charge is for if one exists.

This is a Net::API::Stripe::Customer object.

description string

An arbitrary string attached to the object. Often useful for displaying to users.

destination

This is a Net::API::Stripe::Connect::Account object. But, as of 2019-10-16, it seems absent from Stripe API documentation, so maybe it was removed?

dispute string (expandable)

Details about the dispute if the charge has been disputed.

When expanded, this is a Net::API::Stripe::Dispute object.

disputed boolean

Whether the charge has been disputed.

failure_balance_transaction expandable

ID of the balance transaction that describes the reversal of the balance on your account due to payment failure.

When expanded this is an Net::API::Stripe::Balance::Transaction object.

failure_code string

Error code explaining reason for charge failure if available (see the errors section for a list of codes).

failure_message string

Message to user further explaining reason for charge failure if available.

fraud_details hash

Information on fraud assessments for the charge.

stripe_report string

Assessments from Stripe. If set, the value is fraudulent.

user_report string

Assessments reported by you. If set, possible values of are safe and fraudulent.

invoice string (expandable)

ID of the invoice this charge is for if one exists.

When expanded, this is a Net::API::Stripe::Billing::Invoice object.

livemode boolean

Has the value true if the object exists in live mode or the value false if the object exists in test mode.

metadata hash

Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format.

on_behalf_of string (expandable)

The account (if any) the charge was made on behalf of without triggering an automatic transfer. See the Connect documentation for details.

When expanded, this is a Net::API::Stripe::Connect::Account object

order string (expandable)

ID of the order this charge is for if one exists.

When expanded, this is a Net::API::Stripe::Order object.

outcome hash

Details about whether the payment was accepted, and why. See understanding declines for details.

This is a Net::API::Stripe::Charge::Outcome object.

true if the charge succeeded, or was successfully authorized for later capture.

payment_intent string

ID of the PaymentIntent associated with this charge, if one exists.

This is a <Net::API::Stripe::Payment::Intent> object if any.

payment_method string

ID of the payment method used in this charge.

payment_method_details hash

Details about the payment method at the time of the transaction.

This is a Net::API::Stripe::Payment::Method::Details object.

radar_options object

Options to configure Radar. See Radar Session for more information.

This is a Net::API::Stripe::Fraud::Review object.

receipt_email string

This is the email address that the receipt for this charge was sent to.

receipt_number string

This is the transaction number that appears on email receipts sent for this charge. This attribute will be null until a receipt has been sent.

receipt_url string

This is the URL to view the receipt for this charge. The receipt is kept up-to-date to the latest state of the charge, including any refunds. If the charge is for an Invoice, the receipt will be stylized as an Invoice receipt.

refunded boolean

Whether the charge has been fully refunded. If the charge is only partially refunded, this attribute will still be false.

refunds list

A list of refunds that have been applied to the charge.

This is a Net::API::Stripe::Charge::Refunds object.

review string (expandable)

ID of the review associated with this charge if one exists.

When expanded, this is a Net::API::Stripe::Fraud::Review object.

shipping hash

Shipping information for the charge. This is a Net::API::Stripe::Shipping object.

source

This represents a Net::API::Stripe::Payment::Card object.

It was present before, or at least used in Stripe response, but it is not anymore on the API documentation as of 2019-10-16.

source_transfer string (expandable)

The transfer ID which created this charge. Only present if the charge came from another Stripe account. See the Connect documentation for details here: https://stripe.com/docs/connect/destination-charges

When expanded, this is a Net::API::Stripe::Connect::Transfer object.

statement_description

This is an alternative found in data returned by Stripe. Probably an old property deprecated?

statement_descriptor string

For card charges, use statement_descriptor_suffix instead. Otherwise, you can use this value as the complete description of a charge on your customers’ statements. Must contain at least one letter, maximum 22 characters.

statement_descriptor_suffix string

Provides information about the charge that customers see on their statements. Concatenated with the prefix (shortened descriptor) or statement descriptor that’s set on the account to form the complete statement descriptor. Maximum 22 characters for the concatenated descriptor.

status string

The status of the payment is either succeeded, pending, or failed.

transfer string (expandable)

ID of the transfer to the destination account (only applicable if the charge was created using the destination parameter).

When expanded, this is a Net::API::Stripe::Connect::Transfer object.

transfer_data hash

An optional dictionary including the account to automatically transfer to as part of a destination charge. See the Connect documentation for details.

This is a Net::API::Stripe::Connect::Transfer object, although in the documentation only the following 2 properties are used:

amount integer

The amount transferred to the destination account, if specified. By default, the entire charge amount is transferred to the destination account.

destination string (expandable)

ID of an existing, connected Stripe account to transfer funds to if transfer_data was specified in the charge request.

If expanded, this is a Net::API::Stripe::Connect::Account object.

transfer_group string

A string that identifies this transaction as part of a group. See the Connect documentation for details.

API SAMPLE

    {
      "id": "ch_fake123456789",
      "object": "charge",
      "amount": 100,
      "amount_refunded": 0,
      "application": null,
      "application_fee": null,
      "application_fee_amount": null,
      "balance_transaction": "txn_fake123456789",
      "billing_details": {
        "address": {
          "city": null,
          "country": null,
          "line1": null,
          "line2": null,
          "postal_code": null,
          "state": null
        },
        "email": null,
        "name": null,
        "phone": null
      },
      "captured": false,
      "created": 1571176460,
      "currency": "jpy",
      "customer": null,
      "description": "My First Test Charge (created for API docs)",
      "dispute": null,
      "failure_code": null,
      "failure_message": null,
      "fraud_details": {},
      "invoice": null,
      "livemode": false,
      "metadata": {},
      "on_behalf_of": null,
      "order": null,
      "outcome": null,
      "paid": true,
      "payment_intent": null,
      "payment_method": "card_fake123456789",
      "payment_method_details": {
        "card": {
          "brand": "visa",
          "checks": {
            "address_line1_check": null,
            "address_postal_code_check": null,
            "cvc_check": null
          },
          "country": "US",
          "exp_month": 4,
          "exp_year": 2024,
          "fingerprint": "fake123456789",
          "funding": "credit",
          "installments": null,
          "last4": "4242",
          "network": "visa",
          "three_d_secure": null,
          "wallet": null
        },
        "type": "card"
      },
      "receipt_email": null,
      "receipt_number": null,
      "receipt_url": "https://pay.stripe.com/receipts/acct_fake123456789/ch_fake123456789/rcpt_fake123456789",
      "refunded": false,
      "refunds": {
        "object": "list",
        "data": [],
        "has_more": false,
        "url": "/v1/charges/ch_fake123456789/refunds"
      },
      "review": null,
      "shipping": null,
      "source_transfer": null,
      "statement_descriptor": null,
      "statement_descriptor_suffix": null,
      "status": "succeeded",
      "transfer_data": null,
      "transfer_group": null
    }

HISTORY

v0.1

Initial version

AUTHOR

Jacques Deguest <jack@deguest.jp>

SEE ALSO

Stripe API documentation:

https://stripe.com/docs/api/charges, https://stripe.com/docs/charges

COPYRIGHT & LICENSE

Copyright (c) 2019-2020 DEGUEST Pte. Ltd.

You can use, copy, modify and redistribute this package and associated files under the same terms as Perl itself.