gpt4 book ai didi

angular - Paypal Plus 成功数据

转载 作者:太空狗 更新时间:2023-10-29 17:27:21 25 4
gpt4 key购买 nike

我在我的 Angular 项目中使用 Paypal Plus。一切正常。

如何确认支付成功?我必须将哪些数据保存在我的数据库中。简而言之,我在等待哪些数据成功?

<div id="payments-container"></div>

export class PaypalComponent implements OnInit {
paypalConfig = {
env: 'sandbox',
client: {
sandbox: 'ATvgtyEZznsHf...',
production: '<insert production client id>'
},
style: {
layout: 'vertical',
label: 'pay',
size: 'responsive',
shape: 'rect',
color: 'gold'
},
commit: true,
payment: (data, actions) => {
return actions.payment.create({
payment: {
transactions: [{
amount: {
total: 10.5,
currency: "EUR",
}
}]
}
});
},
onAuthorize: (data, actions) => {
return actions.payment.execute().then((response) => {
console.log('response', response);
console.log('data', data);
console.log('actions', actions);
});
},
onCancel: (data, actions) => {
console.log('Canceled!');
}
};

ngOnInit() {
paypal.Button.render(this.paypalConfig, '#payments-container');
}
}

最佳答案

来自 docs :

A successful response returns confirmation of the transaction, with the approved state and a transaction ID. See the complete list of response values in the Payments API Reference.

看看 response docs具体来说:

id string

The ID of the payment. Read only.

intent enum

The payment intent. Value is: sale. Makes an immediate payment. authorize. Authorizes a payment for capture later. order. Creates an order. Possible values: sale, authorize, order.

payer object

The source of the funds for this payment. Payment method is PayPal Wallet payment or bank direct debit.

application_context object

Use the application context resource to customize payment flow experience for your buyers.

transactions array (contains the transaction object)

An array of payment-related transactions. A transaction defines what the payment is for and who fulfills the payment. For update and execute payment calls, the transactions object accepts the amount object only.

state enum

The state of the payment, authorization, or order transaction. Value is:

  • created. The transaction was successfully created.

  • approved. The customer approved the transaction. The state changes from created to approved on generation of the sale_id for sale transactions, authorization_id for authorization transactions, or order_id for order transactions.

  • failed. The transaction request failed. Read only.

Possible values: created, approved, failed.

experience_profile_id string

The PayPal-generated ID for the merchant's payment experience profile. For information, see create web experience profile. note_to_payer string A free-form field that clients can use to send a note to the payer. Maximum length: 165.

redirect_urls object

A set of redirect URLs that you provide for PayPal-based payments.

failure_reason enum

The reason code for a payment failure. Read only.

Possible values: UNABLE_TO_COMPLETE_TRANSACTION, INVALID_PAYMENT_METHOD, PAYER_CANNOT_PAY, CANNOT_PAY_THIS_PAYEE, REDIRECT_REQUIRED, PAYEE_FILTER_RESTRICTIONS.

create_time string

The date and time when the payment was created, in Internet date and time format. Read only.

update_time string

The date and time when the payment was updated, in Internet date and time format. Read only.

links array (contains the link_description object)

An array of request-related HATEOAS links. Read only.

您肯定会寻找要批准状态

根据您的审计需要,您可能希望保存任何或所有其他字段。 id、intent、payer、transactions 和 failure_reason 至少都可能值得考虑。

关于angular - Paypal Plus 成功数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52413025/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com